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

commit/mq: Let the user change the branch of a patch upon qrefresh or qnew

Now that there is a multi-function button to call commit/qrefresh/qnew on the
status widget, it makes sense to honor the selected branch when running qrefresh
or qnew.

Changeset 49a0cab91515

Parent afe08b4e6fd6

by Angel Ezquerra

Changes to one file · Browse files at 49a0cab91515 Showing diff from parent afe08b4e6fd6 Diff from another changeset...

 
415
416
417
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
418
419
420
421
422
 
 
 
 
 
 
 
 
423
424
 
 
425
426
427
 
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
 
 
 
733
734
735
 
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
 
477
478
479
480
481
 
756
757
758
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
759
760
761
762
763
764
@@ -415,13 +415,67 @@
  self.mqtb.setText(curraction._text)   self.lastAction = curraction._name   + def getBranchCommandLine(self, branchName, repo): + ''' + 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. + Depending on the user input, create the command line which will perform + the selected action + ''' + # This function is used both by commit() and mqPerformAction() + commandlines = [] + newbranch = False + branch = hglib.fromunicode(self.branchop) + if branch in repo.branchtags(): + # response: 0=Yes, 1=No, 2=Cancel + if branch in [p.branch() for p in repo.parents()]: + resp = 0 + else: + rev = repo[branch].rev() + resp = qtlib.CustomPrompt(_('Confirm Branch Change'), + _('Named branch "%s" already exists, ' + 'last used in revision %d\n' + ) % (self.branchop, rev), + self, + (_('Restart &Branch'), + _('&Commit to current branch'), + _('Cancel')), 2, 2).run() + else: + resp = qtlib.CustomPrompt(_('Confirm New Branch'), + _('Create new named branch "%s" with this commit?\n' + ) % self.branchop, + self, + (_('Create &Branch'), + _('&Commit to current branch'), + _('Cancel')), 2, 2).run() + if resp == 0: + newbranch = True + commandlines.append(['branch', '--repository', repo.root, + '--force', branch]) + elif resp == 2: + return None, False + return commandlines, newbranch +   @pyqtSlot()   def mqPerformAction(self):   curraction = self.mqgroup.checkedAction()   if curraction._name == 'commit':   return self.commit() + + # Check if we need to change branch first + commandlines = [] + if self.branchop: + commandlines, newbranch = self.getBranchCommandLine(self.branchop, + self.repo) + if commandlines is None: + return   olist = ('user', 'date') - cmdlines = mq.mqNewRefreshCommand(self.repo, curraction._name == 'qnew', + cmdlines = commandlines + mq.mqNewRefreshCommand(self.repo, + curraction._name == 'qnew',   self.stwidget, self.pnedit,   self.msgte.text(), self.opts, olist)   self.repo.incrementBusyCount() @@ -702,34 +756,9 @@
  elif self.branchop == False:   brcmd = ['--close-branch']   else: - branch = hglib.fromunicode(self.branchop) - if branch in repo.branchtags(): - # response: 0=Yes, 1=No, 2=Cancel - if branch in [p.branch() for p in repo.parents()]: - resp = 0 - else: - rev = repo[branch].rev() - resp = qtlib.CustomPrompt(_('Confirm Branch Change'), - _('Named branch "%s" already exists, ' - 'last used in revision %d\n' - ) % (self.branchop, rev), - self, - (_('Restart &Branch'), - _('&Commit to current branch'), - _('Cancel')), 2, 2).run() - else: - resp = qtlib.CustomPrompt(_('Confirm New Branch'), - _('Create new named branch "%s" with this commit?\n' - ) % self.branchop, - self, - (_('Create &Branch'), - _('&Commit to current branch'), - _('Cancel')), 2, 2).run() - if resp == 0: - newbranch = True - commandlines.append(['branch', '--repository', repo.root, - '--force', branch]) - elif resp == 2: + commandlines, newbranch = self.getBranchCommandLine(self.branchop, + self.repo) + if commandlines is None:   return   files = self.stwidget.getChecked('MAR?!S')   if not (files or brcmd or newbranch):