[PATCH] shelve: adds restoring original parents after unshelve (issue5123)

Yuya Nishihara yuya at tcha.org
Sat Mar 26 10:39:43 EDT 2016


On Tue, 22 Mar 2016 13:18:00 +0100, liscju wrote:
> # HG changeset patch
> # User liscju <piotr.listkiewicz at gmail.com>
> # Date 1458639243 -3600
> #      Tue Mar 22 10:34:03 2016 +0100
> # Node ID 30c3e45abd3e5446757653a85f3a22d9e39f5254
> # Parent  78e4e558fa74aa4489609953328cbcecf1a8a428
> shelve: adds restoring original parents after unshelve (issue5123)

>      def save(cls, repo, name, originalwctx, pendingctx, stripnodes,
> -             branchtorestore):
> +             branchtorestore, originalparents):
>          fp = repo.vfs(cls._filename, 'wb')
>          fp.write('%i\n' % cls._version)
>          fp.write('%s\n' % name)
> @@ -194,6 +196,8 @@ class shelvedstate(object):
>          fp.write('%s\n' %
>                   ' '.join([nodemod.hex(n) for n in stripnodes]))
>          fp.write('%s\n' % branchtorestore)
> +        fp.write('%s\n' %
> +                 ' '.join([nodemod.hex(n) for n in originalparents]))

One of originalparents should be saved as originalwctx (= pctx). And I think
originalparents can be obtained from pendingctx (= tmpwctx).

  pctx -> tmpwctx -> shelvectx
       /
  (p2)-

  if pctx != tmpwctx:
      originalparents = tmpwctx.parents()

> +def restoreparents(repo, parents):
> +    if len(parents) > 1:
> +        repo.setparents(parents[0],
> +                        parents[1])

Maybe it would need begin/endparentchange().


More information about the Mercurial-devel mailing list