[PATCH 1 of 2 V4] shelve: make non bare shelve not preserving newly created branch (BC)

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Mar 11 09:56:50 EST 2016



On 03/11/2016 09:10 AM, liscju wrote:
> # HG changeset patch
> # User liscju <piotr.listkiewicz at gmail.com>
> # Date 1457387891 -3600
> #      Mon Mar 07 22:58:11 2016 +0100
> # Node ID c0f1872014a6ce46dbcbb5627a9bb7ff5a206aaf
> # Parent  a036e1ae1fbe88ab99cb861ebfc2e4da7a3912ca
> shelve: make non bare shelve not preserving newly created branch (BC)

If this change user observable behavior, this should have a test. If it 
does not is can't be BC. What is happening here?

We don't want to preserve it in the shelve, but we don't want to loose 
it either. the uncommited branch should remain active in the working 
directory after the non-bare shelve.

> This patch makes non bare shelve setting branch of working directory
> to the first parent branch before commiting, making it not
> remember newly created branch.
>
> This patch prepares for restoring branch name on newly created
> branch on bare shelve, because newly created branch name will be
> saved only on bare shelve.
>
> diff -r a036e1ae1fbe -r c0f1872014a6 hgext/shelve.py
> --- a/hgext/shelve.py	Sun Feb 07 00:49:31 2016 -0600
> +++ b/hgext/shelve.py	Mon Mar 07 22:58:11 2016 +0100
> @@ -312,6 +312,12 @@ def _docreatecmd(ui, repo, pats, opts):
>                   extra['shelve_unknown'] = '\0'.join(s.unknown)
>                   repo[None].add(s.unknown)
>
> +        if _iswctxonnewbranch(repo) and not _isbareshelve(pats, opts):
> +            # In non-bare shelve we don't store newly created branch
> +            repo.dirstate.setbranch(repo['.'].branch())
> +            ui.status(_('marked working directory as branch %s\n')
> +                      % repo['.'].branch())
> +
>           def commitfunc(ui, repo, message, match, opts):
>               hasmq = util.safehasattr(repo, 'mq')
>               if hasmq:
> @@ -362,6 +368,15 @@ def _docreatecmd(ui, repo, pats, opts):
>       finally:
>           lockmod.release(tr, lock)
>
> +def _isbareshelve(pats, opts):
> +    return (not pats
> +            and not opts.get('interactive', False)
> +            and not opts.get('include', False)
> +            and not opts.get('exclude', False))
> +
> +def _iswctxonnewbranch(repo):
> +    return repo[None].branch() != repo['.'].branch()
> +
>   def cleanupcmd(ui, repo):
>       """subcommand that deletes all shelves"""
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list