[PATCH] mercurial: fixes update --clean to work on new branch (issue5003)

Augie Fackler raf at durin42.com
Thu Dec 31 10:52:45 CST 2015


On Wed, Dec 30, 2015 at 08:55:38PM +0100, liscju wrote:
> # HG changeset patch
> # User liscju <piotr.listkiewicz at gmail.com>
> # Date 1451505270 -3600
> #      Wed Dec 30 20:54:30 2015 +0100
> # Node ID a92bf43906f58c665c35bc745e6d83049a2e95c2
> # Parent  23541bdd1610c08af247f9c8719045cf247ce541
> mercurial: fixes update --clean to work on new branch (issue5003)

I'm somewhat unconvinced. What's wrong with 'hg revert --all' in this case?

(Other reviewers, please chime in - I'm not opposed to this, it just
seems a little quirky to me, and has implications for topics and some
other experimental work as well.)

>
> So far 'hg update --clean' on new created branch results in abort with
> branch not found error. This patch fixes this by changing how destination
> update branch revision is resolved when clean option is specified: it tries
> to resolve branch tip, and then if it is not found it returns parent of
> working directory as destination.
>
> diff -r 23541bdd1610 -r a92bf43906f5 mercurial/destutil.py
> --- a/mercurial/destutil.py	Wed Dec 23 16:22:20 2015 -0800
> +++ b/mercurial/destutil.py	Wed Dec 30 20:54:30 2015 +0100
> @@ -92,7 +92,12 @@
>      wc = repo[None]
>      movemark = node = None
>      try:
> -        node = repo.branchtip(wc.branch())
> +        if clean:
> +            node = repo.branchtip(wc.branch(), ignoremissing=True)
> +            if not node:
> +                node = repo['.'].node()
> +        else:
> +            node = repo.branchtip(wc.branch())
>          if bookmarks.isactivewdirparent(repo):
>              movemark = repo['.'].node()
>      except error.RepoLookupError:
> diff -r 23541bdd1610 -r a92bf43906f5 tests/test-newbranch.t
> --- a/tests/test-newbranch.t	Wed Dec 23 16:22:20 2015 -0800
> +++ b/tests/test-newbranch.t	Wed Dec 30 20:54:30 2015 +0100
> @@ -214,6 +214,15 @@
>    abort: branch foobar not found
>    [255]
>
> +  $ hg branch
> +  foobar
> +
> +  $ hg up --clean
> +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +
> +  $ hg branch
> +  foo
> +
>  Fast-forward merge:
>
>    $ hg branch ff
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list