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

Yuya Nishihara yuya at tcha.org
Thu Apr 14 11:12:35 EDT 2016


On Wed, 13 Apr 2016 13:29:57 +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 a8cc72ea2f5d5d73bf51447eb18d1ccba48afdee
> # Parent  f5f2ade3ad9fa5ce6f4c908273c74d1228b03e0c
> update: fix bare --clean to work on new branch (issue5003) (BC)

Looks mostly good to me. One nit.

> --- a/mercurial/destutil.py	Tue Apr 05 06:53:33 2016 +0200
> +++ b/mercurial/destutil.py	Tue Apr 05 07:30:01 2016 +0200
> @@ -95,14 +95,24 @@ def _destupdatebranch(repo, clean, check
>      wc = repo[None]
>      movemark = node = None
>      currentbranch = wc.branch()
> -    if currentbranch in repo.branchmap():
> -        heads = repo.branchheads(currentbranch)
> +
> +    if clean:
> +        heads = repo.branchheads(repo['.'].branch())
>          if heads:
>              node = repo.revs('max(.::(%ln))', heads).first()
> -        if bookmarks.isactivewdirparent(repo):
> -            movemark = repo['.'].node()
> +            if currentbranch not in repo.branchmap():
> +                repo.ui.warn(_('uncommitted branch %s does not exist, '
> +                               'updating to the head of parent branch\n')
> +                             % currentbranch)

This warning seems a bit unclear because "update --clean" will update to the
head of p1() no matter if new branch exists or not. Can you rephrase it?

>      else:
> -        node = repo['.'].node()
> +        if currentbranch in repo.branchmap():

"elif currentbranch in repo.branchmap()" would make this patch easy to read,
but it is just a matter of taste.


More information about the Mercurial-devel mailing list