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

stable commit: select QNew for the working dir and QRefresh for the topmost applied patch

This patch tries to fix some recent comments by Phil Currier regarding the
automatic switch to the commit widget when the topmost applied patch is selected.

The patch changes the behaviour of the commit widget to reduce the chances of
a user getting confused in the following two scenarios:

1.- When the user selects the working dir and the selected mode is "QRefresh":
This could lead to a user to refresh a patch by accident when in fact it wanted
to create a new patch.

2.- When the user selects the topmost patch while the "commit" button on the
commit widget is set to "QNew":
This could lead the user to believe that the selected patch has different
contents than expected.

Changeset 373e8e264aa2

Parent 321088de6c36

by Angel Ezquerra

Changes to 2 files · Browse files at 373e8e264aa2 Showing diff from parent 321088de6c36 Diff from another changeset...

 
166
167
168
169
 
170
171
172
173
174
175
 
176
177
178
 
308
309
310
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
312
313
 
364
365
366
367
368
369
370
371
372
373
 
374
375
376
 
378
379
380
381
 
 
 
 
 
 
382
383
384
 
425
426
427
428
 
429
430
431
 
465
466
467
468
 
469
470
471
 
475
476
477
478
 
479
480
481
 
166
167
168
 
169
170
171
172
173
174
175
176
177
178
179
 
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
 
405
406
407
 
 
408
409
410
411
 
412
413
414
415
 
417
418
419
 
420
421
422
423
424
425
426
427
428
 
469
470
471
 
472
473
474
475
 
509
510
511
 
512
513
514
515
 
519
520
521
 
522
523
524
525
@@ -166,13 +166,14 @@
  output = pyqtSignal(QString, QString)   makeLogVisible = pyqtSignal(bool)   - def __init__(self, repo, pats, opts, embedded=False, parent=None): + def __init__(self, repo, pats, opts, embedded=False, parent=None, rev=None):   QWidget.__init__(self, parent=parent)     repo.configChanged.connect(self.configChanged)   repo.repositoryChanged.connect(self.repositoryChanged)   repo.workingBranchChanged.connect(self.workingBranchChanged)   self.repo = repo + self._rev = rev   self.lastAction = None   self.lastCommitMsg = ''   self.currentAction = None @@ -308,6 +309,46 @@
  QShortcut(QKeySequence('Ctrl+Enter'), self,   self.commit).setContext(Qt.WidgetWithChildrenShortcut)   + @property + def rev(self): + """Return current revision""" + return self._rev + + def selectRev(self, rev): + """ + Select the revision that must be set when the dialog is shown again + """ + self._rev = rev + + @pyqtSlot(int) + @pyqtSlot(object) + def setRev(self, rev): + """Change revision to show""" + self.selectRev(rev) + if self.hasmqbutton: + preferredActionName = self._getPreferredActionName() + curractionName = self.mqgroup.checkedAction()._name + if curractionName != preferredActionName: + self.mqSetAction(refresh=True, + actionName=preferredActionName) + + def _getPreferredActionName(self): + """Select the preferred action, depending on the selected revision""" + if not self.hasmqbutton: + return 'commit' + else: + pctx = self.repo.changectx('.') + ispatch = 'qtip' in pctx.tags() + if not ispatch: + # Set the button to Commit + return 'commit' + elif self.rev is None: + # Set the button to QNew + return 'qnew' + else: + # Set the button to QRefresh + return 'qref' +   def mqSetupButton(self):   ispatch = lambda r: 'qtip' in r.changectx('.').tags()   notpatch = lambda r: 'qtip' not in r.changectx('.').tags() @@ -364,13 +405,11 @@
  action._enablefunc = a[3]   action.triggered.connect(menurefresh)   action.setCheckable(True) - if a[3] and a[3](self.repo): - action.setChecked(True)   mqmenu.addAction(action)   mqtb.setMenu(mqmenu)   mqtb.clicked.connect(self.mqPerformAction)   self.mqButtonEnable.connect(mqtb.setEnabled) - self.mqSetAction() + self.mqSetAction(actionName=self._getPreferredActionName())   sc = QShortcut(QKeySequence('Ctrl+Return'), self, self.mqPerformAction)   sc.setContext(Qt.WidgetWithChildrenShortcut)   sc = QShortcut(QKeySequence('Ctrl+Enter'), self, self.mqPerformAction) @@ -378,7 +417,12 @@
  return mqtb     @pyqtSlot(bool) - def mqSetAction(self, refresh=False): + def mqSetAction(self, refresh=False, actionName=None): + if actionName: + selectedAction = \ + [act for act in self.mqgroup.actions() \ + if act._name == actionName][0] + selectedAction.setChecked(True)   curraction = self.mqgroup.checkedAction()   oldpctx = self.stwidget.pctx   pctx = self.repo.changectx('.') @@ -425,7 +469,7 @@
  '''   Create the command line to change or create the selected branch unless   it is the selected branch - +   Verify whether a branch exists on a repo. If it doesn't ask the user   to confirm that it wants to create the branch. If it does and it is not   the current branch as the user whether it wants to change to that branch. @@ -465,7 +509,7 @@
  elif resp == 2:   return None, False   return commandlines, newbranch - +   @pyqtSlot()   def mqPerformAction(self):   curraction = self.mqgroup.checkedAction() @@ -475,7 +519,7 @@
  # Check if we need to change branch first   commandlines = []   if self.branchop: - commandlines, newbranch = self.getBranchCommandLine(self.branchop, + commandlines, newbranch = self.getBranchCommandLine(self.branchop,   self.repo)   if commandlines is None:   return
 
271
272
273
274
 
275
276
277
 
710
711
712
713
 
 
714
715
716
717
718
719
 
720
 
721
722
723
 
271
272
273
 
274
275
276
277
 
710
711
712
 
713
714
715
716
717
718
719
720
721
722
723
724
725
726
@@ -271,7 +271,7 @@
    def createCommitWidget(self):   pats, opts = {}, {} - cw = CommitWidget(self.repo, pats, opts, True, self) + cw = CommitWidget(self.repo, pats, opts, True, self, rev=self.rev)     if cw.hasmqbutton:   cw.buttonHBox.addWidget(cw.mqSetupButton()) @@ -710,14 +710,17 @@
  try:   self.revDetailsWidget.onRevisionSelected(rev)   self.revisionSelected.emit(rev) - if type(rev) != str: # unapplied patch + if type(rev) != str: + # Regular patch or working directory   if self.manifestDemand.isHidden():   self.manifestDemand.forward('selectRev', rev)   else:   self.manifestDemand.forward('setRev', rev)   self.grepDemand.forward('setRevision', rev)   self.syncDemand.forward('refreshTargets', rev) + self.commitDemand.forward('setRev', rev)   else: + # unapplied patch   if self.manifestDemand.isHidden():   self.manifestDemand.forward('selectRev', None)   else: