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

update: display only useful buttons when uncommitted local changes

The confirm dialog box contains a text explaining what are the
possible options:
- discard
- shelve
- merge
The text for shelve and/or merge options is not always displayed
(depending on the update).

The buttons for shelve and/or merge will also be filtered in the same
way as the corresponding text.

Changeset 9831e13f9a66

Parent 2479f89fa4a2

by André Sintzoff

Changes to one file · Browse files at 9831e13f9a66 Showing diff from parent 2479f89fa4a2 Diff from another changeset...

 
221
222
223
224
 
225
226
227
 
229
230
231
232
 
233
234
 
235
236
 
237
238
239
240
 
241
242
 
243
 
 
244
 
245
246
 
247
248
249
 
252
253
254
255
 
256
257
258
 
259
260
261
262
263
264
 
265
266
267
 
221
222
223
 
224
225
226
227
 
229
230
231
 
232
233
 
234
235
 
236
237
 
238
 
239
240
 
241
242
243
244
245
246
247
 
248
249
250
251
 
254
255
256
 
257
258
259
 
260
261
262
263
264
265
 
266
267
268
269
@@ -221,7 +221,7 @@
  clean = isclean()     msg = _('Detected uncommitted local changes in working tree.\n' - 'Please select to continue:\n\n') + 'Please select to continue:\n')   data = {'discard': (_('&Discard'),   _('Discard - discard local changes, no backup')),   'shelve': (_('&Shelve'), @@ -229,21 +229,23 @@
  'merge': (_('&Merge'),   _('Merge - allow to merge with local changes')),}   - opts = [data['discard']] + opts = ['discard']   if not ismergedchange(): - opts.append(data['shelve']) + opts.append('shelve')   if islocalmerge(cur, node, clean): - opts.append(data['merge']) + opts.append('merge')   - msg += '\n'.join([desc for label, desc in opts if desc])   dlg = QMessageBox(QMessageBox.Question, _('Confirm Update'), - msg, QMessageBox.Cancel, self) + '', QMessageBox.Cancel, self)   buttons = {} - for name in ('discard', 'shelve', 'merge'): + for name in opts:   label, desc = data[name] + msg += '\n' + msg += desc   buttons[name] = dlg.addButton(label, QMessageBox.ActionRole) + dlg.setText(msg)   dlg.exec_() - return buttons, dlg.clickedButton() + return buttons, dlg.clickedButton(), opts     # If merge-by-default, we want to merge whenever possible,   # without prompting user (similar to command-line behavior) @@ -252,16 +254,16 @@
  if clean:   cmdline.append('--check')   elif not (defaultmerge and islocalmerge(cur, node, clean)): - buttons, clicked = confirmupdate(clean) + buttons, clicked, options = confirmupdate(clean)   if buttons['discard'] == clicked:   cmdline.append('--clean') - elif buttons['shelve'] == clicked: + elif 'shelve' in options and buttons['shelve'] == clicked:   from tortoisehg.hgqt import shelve   dlg = shelve.ShelveDialog(self.repo, self)   dlg.finished.connect(dlg.deleteLater)   dlg.exec_()   return - elif buttons['merge'] == clicked: + elif 'merge' in options and buttons['merge'] == clicked:   pass # no args   else:   return