# HG changeset patch # User Ryan McElroy # Date 2017-03-15 00:43:44 # Node ID 13dc00c233b7e374a6fa0b9846510a94c2615671 # Parent 79d98e1b21a7afc1045a03a1aaf27ee598b8bbb8 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. diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -662,6 +662,16 @@ def rebase(ui, repo, **opts): 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 @@ def rebase(ui, repo, **opts): # 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', []) diff --git a/tests/test-rebase-base.t b/tests/test-rebase-base.t --- a/tests/test-rebase-base.t +++ b/tests/test-rebase-base.t @@ -391,3 +391,25 @@ Multiple roots. Two children share two p / o 0: A +Require a destination + $ cat >> $HGRCPATH < [commands] + > rebase.requiredest = True + > EOF + $ hg init repo + $ cd repo + $ echo a >> a + $ hg commit -qAm aa + $ echo b >> b + $ hg commit -qAm bb + $ hg up ".^" + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ echo c >> c + $ hg commit -qAm cc + $ hg rebase + abort: you must specify a destination + (use: hg rebase -d REV) + [255] + $ hg rebase -d 1 + rebasing 2:5db65b93a12b "cc" (tip) + saved backup bundle to $TESTTMP/repo/.hg/strip-backup/5db65b93a12b-4fb789ec-backup.hg (glob)