[PATCH 2 of 2] rebase: add flag to require destination

Augie Fackler raf at durin42.com
Sun Mar 12 15:06:11 EDT 2017


On Sat, Mar 11, 2017 at 06:03:13PM -0800, Ryan McElroy wrote:
> # HG changeset patch
> # User Ryan McElroy <rmcelroy at fb.com>
> # Date 1489283611 28800
> #      Sat Mar 11 17:53:31 2017 -0800
> # Node ID 7c7f442027b6a0cd51b1f06b01913f53f4f9e9cd
> # Parent  a788a4660443dfc33c5c1c58eec78e20150404d9
> rebase: add flag to require destination

These both look mechanically fine to me, but I'm a little skeptical
about the configuration sections in play (update and rebase
respectively), so I'll leave them for other parties to examine and bikeshed.

>
> diff --git a/hgext/rebase.py b/hgext/rebase.py
> --- a/hgext/rebase.py
> +++ b/hgext/rebase.py
> @@ -650,6 +650,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:
> +
> +      [rebase]
> +      requiredest = False
> +
> +    Return Values:
> +
>      Returns 0 on success, 1 if nothing to rebase or there are
>      unresolved conflicts.
>
> @@ -663,6 +673,12 @@ def rebase(ui, repo, **opts):
>
>          # Validate input and define rebasing points
>          destf = opts.get('dest', None)
> +
> +        if ui.config('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 <<EOF
> +  > [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)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list