[PATCH V2] shelve: adds restoring newly created branch (issue5048) (BC)
Yuya Nishihara
yuya at tcha.org
Wed Mar 2 09:43:49 EST 2016
On Tue, 01 Mar 2016 16:34:48 +0100, liscju wrote:
> # HG changeset patch
> # User liscju <piotr.listkiewicz at gmail.com>
> # Date 1455067407 -3600
> # Wed Feb 10 02:23:27 2016 +0100
> # Node ID bb25b522b01de4954502729a22b40075d6a35f6f
> # Parent a036e1ae1fbe88ab99cb861ebfc2e4da7a3912ca
> shelve: adds restoring newly created branch (issue5048) (BC)
> @@ -312,6 +316,10 @@ def _docreatecmd(ui, repo, pats, opts):
> extra['shelve_unknown'] = '\0'.join(s.unknown)
> repo[None].add(s.unknown)
>
> + if pats:
> + # In non-bare shelve we don't store newly created branch
> + repo.dirstate.setbranch(repo['.'].branch())
This is a big change enough for a separate commit.
Also, if "hg shelve FILE" doesn't remember the branch change, the working
branch should stay unchanged. Perhaps we'll need an in-memory commit stuff.
Let's concentrate on fixing the "unshelve" issue first.
> + if shelvectx.branch() != shelvectx.p1().branch():
> + restorebranch = shelvectx.branch()
> + else:
> + restorebranch = ''
Nit: we prefer the following style (but I'm okay with either styles.)
restorebranch = ''
if shelvectx.branch() != shelvectx.p1().branch():
restorebranch = shelvectx.branch()
> mergefiles(ui, repo, pctx, shelvectx)
> + if (restorebranch and
> + restorebranch != repo.dirstate.branch()):
> + repo.dirstate.setbranch(restorebranch)
> + ui.status(_('marked working directory as branch %s\n') %
> + restorebranch)
Can we have a restorebranch() (or setbranch()) helper?
More information about the Mercurial-devel
mailing list