Commits

Anonymous committed ebfb6b4

settings: add defaultpush configuration setting

This new setting lets the user select what should be pushed when he clicks the
push buttons. The default behavior is to push "all", which is equivalent to
calling "hg push". However it is also possible to push the "current branch"
(equivalent to "hg push --branch .") or to push up to the current revision
(equivalent to "hg push --rev .").

The current behavior of tortoisehg is to call "hg push" when the user clicks
the the push button. This makes is quite easy to push unfinished work when you
are working on several named branches in parallel.

The problem is that the TortoiseHg interface does not make it easy for the user
to easily call "hg push --branch ." to only push the current branch or "hg push
--rev ." to only push up to the current revision. In order to do so the user
must use the outgoing button, right click the proper revision and then find the
push submenu on the context menu, where he must select the proper command.

This new setting makes it easy to select the desired default behavior, while
retaining the ability to select a different behavior if needed.

Note that in order to let the user easily override this setting when using the
"branch" or the "revision" settings, the outgoing command will show the
outgoing revisions from _all_ branches, even though the "push" button will only
push the selected revisions. In order to push all the user can right click on
any revision and select "Push all" on the context menu.

  • Participants
  • Parent commits 992f6ea
  • Branches stable

Comments (0)

Files changed (2)

File tortoisehg/hgqt/settings.py

         _('Operation which is performed directly after a successful pull. '
           'update equates to pull --update, fetch equates to the fetch '
           'extension, rebase equates to pull --rebase.  Default: none')),
+    _fi(_('Default Push'), 'tortoisehg.defaultpush', (genDefaultCombo,
+        ['all', 'branch', 'revision']),
+        _('Select the revisions that will be pushed by default, '
+        'whenever you click the Push button.'
+        '<ul><li><b>all</b>: The default. Push all changes in <i>all branches</i>.'
+        '<li><b>branch</b>: Push all changes in the <i>current branch</i>.'
+        '<li><b>revision</b>: Push the changes in the current branch '
+        '<i><u>up to</u> the current revision</i>.</ul><p>'
+        'Default: all')),
     )),
-
 ({'name': 'commit', 'label': _('Commit', 'config item'), 'icon': 'menucommit'}, (
     _fi(_('Username'), 'ui.username', genEditCombo,
         _('Name associated with commits.  The common format is:<br>'

File tortoisehg/hgqt/sync.py

                         return
             self.pushCompleted.emit()
         self.finishfunc = finished
+
+        if not rev and not branch:
+            # Read the tortoisehg.defaultpush setting to determine what to push by default
+            defaultpush = self.repo.ui.config('tortoisehg', 'defaultpush', 'all')
+            if defaultpush == 'all':
+                # This is the default
+                pass
+            elif defaultpush == 'branch':
+                branch = '.'
+            elif defaultpush == 'revision':
+                rev = '.'
+            else:
+                self.showMessage.emit(_('Invalid default push revision: %s.'
+                                        'Please check your mercurial configuration '
+                                        '(tortoisehg.defaultpush)') % defaultpush)
+                self.pushCompleted.emit()
+                return
+
         cmdline = ['--repository', self.repo.root, 'push']
         if rev:
             cmdline.extend(['--rev', str(rev)])