diff hgext/rebase.py @ 31564:13dc00c233b7

rebase: add flag to require destination In some mercurial workflows, the default destination for rebase does not always work well and can lead to confusing behavior. With this flag enabled, every rebase command will require passing an explicit destination, eliminating this confusion.
author Ryan McElroy <rmcelroy@fb.com>
date Tue, 14 Mar 2017 17:43:44 -0700
parents 2519994d25ca
children 37a0ad669051
line wrap: on
line diff
--- a/hgext/rebase.py	Tue Mar 14 17:43:18 2017 -0700
+++ b/hgext/rebase.py	Tue Mar 14 17:43:44 2017 -0700
@@ -662,6 +662,16 @@
 
           hg rebase -r "branch(featureX)" -d 1.3 --keepbranches
 
+    Configuration Options:
+
+    You can make rebase require a destination if you set the following config
+    option:
+
+      [commands]
+      rebase.requiredest = False
+
+    Return Values:
+
     Returns 0 on success, 1 if nothing to rebase or there are
     unresolved conflicts.
 
@@ -675,6 +685,12 @@
 
         # Validate input and define rebasing points
         destf = opts.get('dest', None)
+
+        if ui.config('commands', 'rebase.requiredest', False):
+            if not destf:
+                raise error.Abort(_('you must specify a destination'),
+                                  hint=_('use: hg rebase -d REV'))
+
         srcf = opts.get('source', None)
         basef = opts.get('base', None)
         revf = opts.get('rev', [])