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

branchop: introduce a wctx.branch() manipulation dialog

The commit tool opens the dialog but ignores the results

Changeset 8937ab7d10fa

Parent f8202d82d1f5

by Steve Borho

Changes to 2 files · Browse files at 8937ab7d10fa Showing diff from parent f8202d82d1f5 Diff from another changeset...

Change 1 of 1 Show Entire File tortoisehg/​hgqt/​branchop.py Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
77
78
79
80
@@ -0,0 +1,80 @@
+# branchop.py - branch operations dialog for TortoiseHg commit tool +# +# Copyright 2010 Steve Borho <steve@borho.org> +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2, incorporated herein by reference. + +import os + +from mercurial import util + +from PyQt4 import QtCore, QtGui + +from tortoisehg.hgqt.i18n import _ +from tortoisehg.util import hglib + +from tortoisehg.hgqt import qtlib + +class BranchOpDialog(QtGui.QDialog): + 'Dialog for manipulating wctx.branch()' + def __init__(self, repo, parent=None): + QtGui.QDialog.__init__(self, parent) + layout = QtGui.QVBoxLayout() + self.setLayout(layout) + wctx = repo[None] + + if len(wctx.parents()) == 2: + lbl = QtGui.QLabel('<b>'+_('Select branch of merge commit')+'</b>') + layout.addWidget(lbl) + branchCombo = QtGui.QComboBox() + for p in wctx.parents(): + branchCombo.addItem(hglib.tounicode(p.branch())) + layout.addWidget(branchCombo) + else: + text = '<b>'+_('Changes take effect on next commit')+'</b>' + lbl = QtGui.QLabel(text) + layout.addWidget(lbl) + + grid = QtGui.QGridLayout() + nochange = QtGui.QRadioButton(_('No Branch Changes')) + newbranch = QtGui.QRadioButton(_('Open a new named branch')) + closebranch = QtGui.QRadioButton(_('Close current named branch')) + branchCombo = QtGui.QComboBox() + branchCombo.setEditable(True) + for name in hglib.getlivebranch(repo): + if name == wctx.branch(): + continue + branchCombo.addItem(hglib.tounicode(name)) + 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) + + BB = QtGui.QDialogButtonBox + bb = QtGui.QDialogButtonBox(BB.Ok|BB.Cancel) + self.connect(bb, QtCore.SIGNAL("accepted()"), + self, QtCore.SLOT("accept()")) + self.connect(bb, QtCore.SIGNAL("rejected()"), + self, QtCore.SLOT("reject()")) + bb.button(BB.Ok).setDefault(True) + layout.addWidget(bb) + self.bb = bb + + def keyPressEvent(self, event): + # todo - is this necessary for a derivation of QDialog? + if event.key() in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter): + if event.modifiers() == QtCore.Qt.ControlModifier: + self.accept() # Ctrl+Enter + return + elif event.key() == QtCore.Qt.Key_Escape: + self.reject() + return + return super(QtGui.QDialog, self).keyPressEvent(event)
 
15
16
17
18
 
19
20
21
 
81
82
83
 
84
 
 
85
 
86
87
88
 
115
116
117
 
 
 
 
118
119
120
 
15
16
17
 
18
19
20
21
 
81
82
83
84
85
86
87
88
89
90
91
92
 
119
120
121
122
123
124
125
126
127
128
@@ -15,7 +15,7 @@
 from tortoisehg.hgqt.i18n import _  from tortoisehg.util import hglib, shlib, paths   -from tortoisehg.hgqt import qtlib, status, cmdui +from tortoisehg.hgqt import qtlib, status, cmdui, branchop    # Technical Debt for CommitWidget  # qrefresh support @@ -81,8 +81,12 @@
  vbox.addWidget(frame, 0)   vbox.setMargin(0)   hbox = QHBoxLayout() +   branchop = QPushButton('Branch: default') + branchop.pressed.connect(self.branchOp) + self.branchop = branchop   hbox.addWidget(branchop) +   msgcombo = MessageHistoryCombo()   self.connect(msgcombo, SIGNAL('activated(int)'), self.msgSelected)   hbox.addWidget(msgcombo, 1) @@ -115,6 +119,10 @@
  def saveState(self):   return self.stwidget.saveState()   + def branchOp(self): + d = branchop.BranchOpDialog(self.stwidget.repo) + ret = d.exec_() +   def canUndo(self):   'Returns undo description or None if not valid'   repo = self.stwidget.repo