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

Yuya Nishihara yuya at tcha.org
Fri Apr 22 11:02:40 EDT 2016


On Wed, 20 Apr 2016 09:53:20 +0200, liscju wrote:
> # HG changeset patch
> # User liscju <piotr.listkiewicz at gmail.com>
> # Date 1459834201 -7200
> #      Tue Apr 05 07:30:01 2016 +0200
> # Branch stable
> # Node ID fed812b73ca807061f484aa16eb5ca5383ad9b85
> # Parent  97811ff7964710d32cae951df1da8019b46151a2
> update: fix bare --clean to work on new branch (issue5003) (BC)
> 
> Before this commit bare update --clean on newly created branch
> updates to the parent commit, even if there are later commits
> on the parent commit's branch. Update to the latest head on the
> parent commit's branch instead.
> 
> This seems reasonable as clean should discard uncommited changes,
> branch is one of them.
> 
> diff -r 97811ff79647 -r fed812b73ca8 mercurial/destutil.py
> --- a/mercurial/destutil.py	Sat Mar 26 18:50:56 2016 +0900
> +++ b/mercurial/destutil.py	Tue Apr 05 07:30:01 2016 +0200
> @@ -95,7 +95,16 @@ def _destupdatebranch(repo, clean, check
>      wc = repo[None]
>      movemark = node = None
>      currentbranch = wc.branch()
> -    if currentbranch in repo.branchmap():
> +
> +    if clean:
> +        parentbranch = repo['.'].branch()
> +        heads = repo.branchheads(parentbranch)
> +        if heads:
> +            node = repo.revs('max(.::(%ln))', heads).first()

It would have the missing "default" branch issue we've hit before.

  $ cd repo-with-no-default-branch
  $ hg update null
  $ hg update -C  # perhaps this should bring us to tipmost unclosed branch head

https://selenic.com/repo/hg/rev/d9539959167d

So basically, we would want the following behavior:

  if clean:
      currentbranch = wc.p1().branch()
  if currentbranch in repo.branchmap():
      heads = repo.branchheads(currentbranch)
      ...

> +            if currentbranch not in repo.branchmap():
> +                repo.ui.warn(_('updating to the head of parent branch %s\n')
> +                             % parentbranch)

Hmm, the warning message seems not match with the condition. Which kind of
problems do you have in mind?

 a) uncommitted branch is discarded
 b) update to head of parent branch, not to head of new branch
 c) ?

Since this patch involves BC and isn't a trivial change, I want to revisit
it after May 1.


More information about the Mercurial-devel mailing list