Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.1, 2.1.1, and 2.1.2

Merge with stable

Changeset aff0628998c0

Parents a9a715092aff

Parents e724702efd06

by Steve Borho

Changes to 3 files · Browse files at aff0628998c0 Showing diff from parent a9a715092aff e724702efd06 Diff from another changeset...

 
445
446
447
 
 
 
 
 
 
 
 
 
 
448
449
450
451
 
452
453
454
 
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
 
461
462
463
464
@@ -445,10 +445,20 @@
  'Patch has been renamed, issue qrename'   if self.cmd.running():   return + from tortoisehg.hgqt import qrename + newpatchname = hglib.fromunicode(item.text()) + if newpatchname == item._thgpatch: + return + else: + res = qrename.checkPatchname(self.repo.root, + self.repo.thgactivemqname, newpatchname, self) + if not res: + item.setText(item._thgpatch) + return   self.repo.incrementBusyCount()   self.qtbar.setEnabled(False)   self.cmd.run(['qrename', '-R', self.repo.root, '--', - item._thgpatch, hglib.fromunicode(item.text())]) + item._thgpatch, newpatchname])     @pyqtSlot(int)   def onPatchSelected(self, row):
 
13
14
15
16
 
17
18
19
 
56
57
58
 
 
 
 
59
60
61
62
63
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
14
15
 
16
17
18
19
 
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
@@ -13,7 +13,7 @@
   from tortoisehg.util import hglib  from tortoisehg.hgqt.i18n import _ -from tortoisehg.hgqt import cmdui +from tortoisehg.hgqt import cmdui, qtlib    class QRenameDialog(QDialog):   @@ -56,9 +56,113 @@
  def accept(self):   self.newpatchname = hglib.fromunicode(self.le.text())   if self.newpatchname != self.oldpatchname: + res = checkPatchname(self.repo.root, self.repo.thgactivemqname, + self.newpatchname, self) + if not res: + return   cmdline = ['qrename', '--repository', self.repo.root, '--',   self.oldpatchname, self.newpatchname]   self.cmd.run(cmdline)   else:   self.close()   +def checkPatchname(reporoot, activequeue, newpatchname, parent): + if activequeue == 'patches': + pn = 'patches' + else: + pn = 'patches-%s' % activequeue + patchfile = os.sep.join([reporoot, ".hg", pn, newpatchname]) + if os.path.exists(patchfile): + dlg = CheckPatchnameDialog(newpatchname, parent) + choice = dlg.exec_() + if choice == 1: + # add .OLD to existing patchfile + try: + os.rename(patchfile, patchfile + '.OLD') + except (OSError, IOError), inst: + qtlib.ErrorMsgBox(self.errTitle, + _('Could not rename existing patchfile'), + hglib.tounicode(str(inst))) + return False + return True + elif choice == 2: + # overwite existing patchfile + try: + os.remove(patchfile) + except (OSError, IOError), inst: + qtlib.ErrorMsgBox(self.errTitle, + _('Could not delete existing patchfile'), + hglib.tounicode(str(inst))) + return False + return True + elif choice == 3: + # go back and change the new name + return False + else: + return False + else: + return True + +class CheckPatchnameDialog(QDialog): + + def __init__(self, patchname, parent): + super(CheckPatchnameDialog, self).__init__(parent) + self.setWindowTitle(_('QRename - Check patchname')) + + f = self.windowFlags() + self.setWindowFlags(f & ~Qt.WindowContextHelpButtonHint) + self.patchname = patchname + + self.vbox = QVBoxLayout() + self.vbox.setSpacing(4) + + lbl = QLabel(_('Patch name <b>%s</b> already exists:') + % (self.patchname)) + self.vbox.addWidget(lbl) + + self.extensionradio = \ + QRadioButton(_('Add .OLD extension to existing patchfile')) + self.vbox.addWidget(self.extensionradio) + self.overwriteradio = QRadioButton(_('Overwrite existing patchfile')) + self.vbox.addWidget(self.overwriteradio) + self.backradio = QRadioButton(_('Go back and change new patchname')) + self.vbox.addWidget(self.backradio) + + self.extensionradio.toggled.connect(self.onExtensionRadioChecked) + self.overwriteradio.toggled.connect(self.onOverwriteRadioChecked) + self.backradio.toggled.connect(self.onBackRadioChecked) + + self.choice = 0 + self.extensionradio.setChecked(True) + self.extensionradio.setFocus() + + self.setLayout(self.vbox) + + BB = QDialogButtonBox + bbox = QDialogButtonBox(BB.Ok|BB.Cancel) + bbox.accepted.connect(self.accept) + bbox.rejected.connect(self.reject) + self.layout().addWidget(bbox) + self.bbox = bbox + + @pyqtSlot() + def onExtensionRadioChecked(self): + if self.extensionradio.isChecked(): + self.choice = 1 + + @pyqtSlot() + def onOverwriteRadioChecked(self): + if self.overwriteradio.isChecked(): + self.choice = 2 + + @pyqtSlot() + def onBackRadioChecked(self): + if self.backradio.isChecked(): + self.choice = 3 + + def accept(self): + self.done(self.choice) + self.close() + + def reject(self): + self.done(0)
 
56
57
58
59
60
 
 
 
61
62
63
 
124
125
126
127
128
 
 
 
129
130
131
 
56
57
58
 
 
59
60
61
62
63
64
 
125
126
127
 
 
128
129
130
131
132
133
@@ -56,8 +56,9 @@
  QListWidget.__init__(self, parent)   self.setCurrentRow(0)   def contextMenuEvent(self, event): - self.menuRequested.emit(event.globalPos(), - self.item(self.currentRow()).patchname) + i = self.item(self.currentRow()) + if i: + self.menuRequested.emit(event.globalPos(), i.patchname)   def focusInEvent(self, e):   i = self.item(self.currentRow())   if i: @@ -124,8 +125,9 @@
  patchname = self.menuselection   dlg = qrename.QRenameDialog(self.repo, patchname, self)   dlg.finished.connect(dlg.deleteLater) - dlg.output.connect(self.parent().output) - dlg.makeLogVisible.connect(self.parent().makeLogVisible) + if self.parent(): + dlg.output.connect(self.parent().output) + dlg.makeLogVisible.connect(self.parent().makeLogVisible)   dlg.exec_()     def refresh(self):