Commits

Angel Ezquerra  committed d82b54c

outgoing: fix push all command and improve outgoing infobar

The "Push All" command was broken. Calling it from the repowidget context menu
or from the "Push" outgoing infobar button would not always push all. Instead,
it would use the tortoisehg.defaultpush setting.

This patch fixes that, and in doing so it improves the outgoing infobar button
to explicitly specify the revision or branch that will be pushed. It also fixes
a possible issue when trying to push revision 0.

  • Participants
  • Parent commits 2279af1
  • Branches stable

Comments (0)

Files changed (2)

File tortoisehg/hgqt/repowidget.py

         assert w
 
         # Read the tortoisehg.defaultpush setting to determine what to push
-        # by default
+        # by default, and set the button label and action accordingly
         acceptbuttontext = _('Push')
         defaultpush = self.repo.ui.config('tortoisehg', 'defaultpush', 'all')
+        rev = None
+        branch = None
+        pushall = False
         if defaultpush == 'branch':
-            acceptbuttontext = _('Push current branch')
+            branch = self.repo['.'].branch()
+            acceptbuttontext = _('Push current branch (%s)') \
+                % hglib.tounicode(branch)
         elif defaultpush == 'revision':
-            acceptbuttontext = _('Push current revision')
+            rev = self.repo['.'].rev()
+            acceptbuttontext = _('Push current revision (%d)') % rev
+        else:
+            pushall = True
 
         w.acceptButton.setText(acceptbuttontext)
-        w.accepted.connect(lambda: self.push(False))  # TODO: to the same URL
+        w.accepted.connect(lambda: self.push(False,
+            rev=rev, branch=branch, pushall=pushall))  # TODO: to the same URL
         w.rejected.connect(self.clearRevisionSet)
 
     def createGrepWidget(self):
     def outgoing(self):
         self.syncDemand.get().outgoing()
         self.outgoingMode = True
-    def push(self, confirm=True):
+    def push(self, confirm=True, **kwargs):
         """Call sync push.
 
         If confirm is False, the user will not be prompted for
         confirmation. If confirm is True, the prompt might be used.
         """
-        self.syncDemand.get().push(confirm)
+        self.syncDemand.get().push(confirm, **kwargs)
         self.outgoingMode = False
 
     @pyqtSlot()
                 'functionality, you must use a mercurial version above 2.1.'))
 
     def pushAll(self):
-        self.syncDemand.forward('push', True)
+        self.syncDemand.forward('push', False, pushall=True)
 
     def pushToRevision(self):
         # Do not ask for confirmation

File tortoisehg/hgqt/sync.py

         else:
             self.outclicked()
 
-    def push(self, confirm, rev=None, branch=None):
+    def push(self, confirm, **kwargs):
         if self.cmd.core.running():
             self.showMessage.emit(_('sync command already running'))
         else:
-            self.pushclicked(confirm, rev, branch)
+            self.pushclicked(confirm, **kwargs)
 
     def pullBundle(self, bundle, rev, bsource=None):
         'accept bundle changesets'
         self.showMessage.emit(_('Perforce pending...'))
         self.run(['--repository', self.repo.root, 'p4pending', '--verbose'], ())
 
-    def pushclicked(self, confirm, rev=None, branch=None):
+    def pushclicked(self, confirm, rev=None, branch=None, pushall=False):
+        if rev == '':
+            rev = None
+        if branch == '':
+            branch = None
+        if pushall and (rev is not None or branch is not None):
+            # This should never happen
+            qtlib.ErrorMsg(_('Internal TortoiseHg Error'),
+                _('Inconsistent call to SyncWidget.pushclicked()'),
+                _('Cannot call SyncWidget.pushclicked() with pushall=True, '
+                'rev!=None and branch!=None'))
+            return
         validopts = ('force', 'new-branch', 'branch', 'rev', 'bookmark', 'mq')
         self.syncStarted.emit()
         url = self.currentPushUrl()
             self.pushCompleted.emit()
         self.finishfunc = finished
 
-        if not rev and not branch:
+        if not pushall and rev is not None and branch is not None:
             # Read the tortoisehg.defaultpush setting to determine what to push by default
             defaultpush = self.repo.ui.config('tortoisehg', 'defaultpush', 'all')
             if defaultpush == 'all':