Changeset b3160d14d0dd…
Parent e8f197f5769a…
by
Changes to 2 files · Browse files at b3160d14d0dd Showing diff from parent e8f197f5769a Diff from another changeset...
@@ -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,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'
|
Loading...