Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

commit: remember branchop return value

Changeset b3160d14d0dd

Parent e8f197f5769a

by Steve Borho

Changes to 2 files · Browse files at b3160d14d0dd Showing diff from parent e8f197f5769a Diff from another changeset...

 
18
19
20
21
 
22
23
24
 
37
38
39
40
 
41
42
43
 
46
47
48
 
49
50
51
52
53
54
55
56
57
58
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
61
62
 
67
68
69
 
70
71
72
 
78
79
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
19
20
 
21
22
23
24
 
37
38
39
 
40
41
42
43
 
46
47
48
49
50
51
52
53
54
55
 
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 
81
82
83
84
85
86
87
 
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
@@ -18,7 +18,7 @@
   class BranchOpDialog(QtGui.QDialog):   'Dialog for manipulating wctx.branch()' - def __init__(self, repo, parent=None): + def __init__(self, repo, oldbranchop, parent=None):   QtGui.QDialog.__init__(self, parent)   layout = QtGui.QVBoxLayout()   self.setLayout(layout) @@ -37,7 +37,7 @@
  layout.addWidget(lbl)     grid = QtGui.QGridLayout() - nochange = QtGui.QRadioButton(_('No Branch Changes')) + nochange = QtGui.QRadioButton(_('No branch changes'))   newbranch = QtGui.QRadioButton(_('Open a new named branch'))   closebranch = QtGui.QRadioButton(_('Close current named branch'))   branchCombo = QtGui.QComboBox() @@ -46,17 +46,31 @@
  if name == wctx.branch():   continue   branchCombo.addItem(hglib.tounicode(name)) + branchCombo.activated.connect(self.accept)   grid.addWidget(nochange, 0, 0)   grid.addWidget(newbranch, 1, 0)   grid.addWidget(branchCombo, 1, 1)   grid.addWidget(closebranch, 2, 0)   layout.addLayout(grid)   - nochange.setChecked(True)   newbranch.toggled.connect(branchCombo.setEnabled)   branchCombo.setEnabled(False)   if wctx.branch() == 'default':   closebranch.setEnabled(False) + if oldbranchop is None: + nochange.setChecked(True) + elif oldbranchop == False: + closebranch.setChecked(True) + else: + bc = branchCombo + names = [bc.itemText(i) for i in xrange(bc.count())] + if oldbranchop in names: + bc.setCurrentIndex(names.index(oldbranchop)) + else: + bc.addItem(oldbranchop) + bc.setCurrentIndex(len(names)) + newbranch.setChecked(True) + self.closebranch = closebranch     BB = QtGui.QDialogButtonBox   bb = QtGui.QDialogButtonBox(BB.Ok|BB.Cancel) @@ -67,6 +81,7 @@
  bb.button(BB.Ok).setDefault(True)   layout.addWidget(bb)   self.bb = bb + self.branchCombo = branchCombo     def keyPressEvent(self, event):   # todo - is this necessary for a derivation of QDialog? @@ -78,3 +93,17 @@
  self.reject()   return   return super(QtGui.QDialog, self).keyPressEvent(event) + + def accept(self): + '''Branch operation is one of: + None - leave wctx branch name untouched + False - close current branch + str - open new named branch + ''' + if self.branchCombo.isEnabled(): + self.branchop = self.branchCombo.currentText() + elif self.closebranch.isChecked(): + self.branchop = False + else: + self.branchop = None + QtGui.QDialog.accept(self)
 
56
57
58
 
 
59
60
61
62
63
64
 
65
66
67
 
70
71
72
73
74
 
75
76
77
 
81
82
83
84
85
86
87
 
 
 
 
 
 
88
89
90
 
119
120
121
122
123
124
 
 
 
 
 
 
 
 
 
 
 
 
125
126
127
 
56
57
58
59
60
61
62
63
64
65
 
66
67
68
69
 
72
73
74
 
 
75
76
77
78
 
82
83
84
 
 
 
 
85
86
87
88
89
90
91
92
93
 
122
123
124
 
 
 
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
@@ -56,12 +56,14 @@
  self.setLayout(layout)   form = QFormLayout()   form.setContentsMargins(3, 9, 9, 0) + repo = self.stwidget.repo + wctx = repo[None]     usercombo = QComboBox()   try:   if opts.get('user'):   usercombo.addItem(hglib.tounicode(opts['user'])) - usercombo.addItem(hglib.tounicode(self.stwidget.repo[None].user())) + usercombo.addItem(hglib.tounicode(wctx.user()))   except util.Abort:   import socket   user = '%s@%s' % (util.getuser(), socket.getfqdn()) @@ -70,8 +72,7 @@
  usercombo.setEditable(True)   form.addRow(_('Changeset:'), QLabel(_('Working Copy')))   form.addRow(_('User:'), usercombo) - form.addRow(_('Parent:'), QLabel('Description of ' + - str(self.stwidget.repo['.']))) + form.addRow(_('Parent:'), QLabel('Description of ' + str(repo['.'])))   frame = QFrame()   frame.setLayout(form)   frame.setFrameStyle(QFrame.NoFrame) @@ -81,10 +82,12 @@
  vbox.setMargin(0)   hbox = QHBoxLayout()   - branchop = QPushButton('Branch: default') - branchop.pressed.connect(self.branchOp) - self.branchop = branchop - hbox.addWidget(branchop) + branchbutton = QPushButton(_('Branch: ') + + hglib.tounicode(wctx.branch())) + branchbutton.pressed.connect(self.branchOp) + self.branchbutton = branchbutton + self.branchop = None + hbox.addWidget(branchbutton)     msgcombo = MessageHistoryCombo()   self.connect(msgcombo, SIGNAL('activated(int)'), self.msgSelected) @@ -119,9 +122,18 @@
  return self.stwidget.saveState()     def branchOp(self): - d = branchop.BranchOpDialog(self.stwidget.repo) - ret = d.exec_() - # TODO - do something useful here, and in _commit + d = branchop.BranchOpDialog(self.stwidget.repo, self.branchop) + if d.exec_() == QDialog.Accepted: + self.branchop = d.branchop + wctx = self.stwidget.repo[None] + cur = hglib.tounicode(wctx.branch()) + if self.branchop is None: + title = _('Branch: ') + cur + elif self.branchop == False: + title = _('Close Branch: ') + cur + else: + title = _('New Branch: ') + self.branchop + self.branchbutton.setText(title)     def canUndo(self):   'Returns undo description or None if not valid'