When push would create a new remote branch, include the branch name(s) in the warning message
Created originally on Bitbucket by wjb (Bill Binder)
When you push without --force and a new branch would be created, it would be convenient if the error message listed the branch name(s). The mercurial error message contains the names already so its mostly formatting the result.
#!patch
diff -r bdce1014ff10 tortoisehg/hgqt/sync.py
--- a/tortoisehg/hgqt/sync.py Sat Sep 10 19:59:48 2016 +0900
+++ b/tortoisehg/hgqt/sync.py Tue Aug 08 20:11:34 2017 +0100
@@ -36,6 +36,8 @@
# writes extra " "s to the output channel. (hg 3.1)
_extractnodeids = re.compile(r'^\s*([0-9a-f]{40})$', re.MULTILINE).findall
+_newbranchnames = re.compile(r'new remote branches: ([^!]+)!', re.MULTILINE).search
+
class SyncWidget(QWidget, qtlib.TaskWidget):
newCommand = pyqtSignal(cmdcore.CmdSession)
outgoingNodes = pyqtSignal(object)
@@ -916,12 +918,14 @@
self.showMessage.emit(_('Push to %s aborted, ret %d') % (link, ret))
if ("'hg push --new-branch'" in self._cmdsession.errorString()
and '--new-branch' not in self.lastcmdline):
+ brlist = _newbranchnames(self._cmdsession.errorString())
+ brnames = brlist.group(1) if brlist else '?'
r = qtlib.QuestionMsgBox(_('Confirm New Branch'),
_('One or more of the changesets that '
'you are attempting to push involve '
- 'the creation of a new branch. '
+ 'the creation of a new branch (%s). '
'Do you want to create a new branch '
- 'in the remote repository?'),
+ 'in the remote repository?') % brnames,
parent=self)
if r:
cmdline = self.lastcmdline