[PATCH 2 of 2 V6] update: fix bare --clean to work on new branch (issue5003) (BC)

Yuya Nishihara yuya at tcha.org
Sat Apr 9 06:34:27 EDT 2016


On Tue, 05 Apr 2016 07:53:18 +0200, liscju wrote:
> # HG changeset patch
> # User liscju <piotr.listkiewicz at gmail.com>
> # Date 1459834201 -7200
> #      Tue Apr 05 07:30:01 2016 +0200
> # Node ID 8c71316ce8bed9394941bf8ccf3597d7ea7b8b1f
> # Parent  7c72d229ded37ba1df4f737d738d1e6f0603e069
> update: fix bare --clean to work on new branch (issue5003) (BC)
> 
> So far 'hg update --clean' on newly created branch results in abort
> with branch not found error. After applying this commit bare
> update --clean results in updating to the max head of the parents
> branch.
> 
> This seems reasonable as clean should discard uncommited changes,
> branch is one of them.
> 
> diff -r 7c72d229ded3 -r 8c71316ce8be mercurial/destutil.py
> --- a/mercurial/destutil.py	Tue Apr 05 06:53:33 2016 +0200
> +++ b/mercurial/destutil.py	Tue Apr 05 07:30:01 2016 +0200
> @@ -102,8 +102,16 @@ def _destupdatebranch(repo, clean, check
>          if bookmarks.isactivewdirparent(repo):
>              movemark = repo['.'].node()
>      else:
> -        if repo['.']:
> -            node = repo['.'].node()
> +        if clean:
> +            heads = repo.branchheads(repo['.'].branch())
> +            if heads:
> +                node = repo.revs('max(.::(%ln))', heads).first()
> +                repo.ui.warn(_('uncommited branch %s does not exist, '
> +                               'updating to the head of parent branch\n')
> +                             % currentbranch)

I think "if clean" should be moved before "currentbranch in repo.branchmap()".
Otherwise, the behavior would be different whether or not new branch exists
somewhere else in the history, which seems confusing. As --clean is documented
to "discard uncommitted changes", it would make sense to discard uncommitted
branch at all.


More information about the Mercurial-devel mailing list