[PATCH 2 of 2] shelve: add dirstateguard to unshelve

Augie Fackler raf at durin42.com
Tue Sep 29 08:38:47 CDT 2015


On Mon, Sep 28, 2015 at 07:07:03PM -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham at fb.com>
> # Date 1443492037 25200
> #      Mon Sep 28 19:00:37 2015 -0700
> # Node ID 50ce9941d7c0ce0abf4b3c9e616057a82e6c9021
> # Parent  ff1ab706e6d662d1971c1a6127e60b7063abfe74
> shelve: add dirstateguard to unshelve

very nice, queued these

>
> If unshelve threw an exception at an inopportune moment, it would cause an
> unknown working copy parent. Adding the dirstateguard prevents this.
>
> I tested it by manually introducing exceptions in various locations within
> unshelve.
>
> diff --git a/hgext/shelve.py b/hgext/shelve.py
> --- a/hgext/shelve.py
> +++ b/hgext/shelve.py
> @@ -619,6 +619,8 @@ def unshelve(ui, repo, *shelved, **opts)
>          wlock = repo.wlock()
>          lock = repo.lock()
>
> +        dsguard = cmdutil.dirstateguard(repo, 'unshelve')
> +
>          tr = repo.transaction('unshelve', report=lambda x: None)
>          oldtiprev = len(repo)
>
> @@ -676,6 +678,7 @@ def unshelve(ui, repo, *shelved, **opts)
>                  })
>              except error.InterventionRequired:
>                  tr.close()
> +                dsguard.close()
>
>                  stripnodes = [repo.changelog.node(rev)
>                                for rev in xrange(oldtiprev, len(repo))]
> @@ -695,6 +698,7 @@ def unshelve(ui, repo, *shelved, **opts)
>                  shelvectx = tmpwctx
>
>          mergefiles(ui, repo, pctx, shelvectx)
> +        dsguard.close()
>          shelvedstate.clear(repo)
>
>          # The transaction aborting will strip all the commits for us,
> @@ -708,6 +712,8 @@ def unshelve(ui, repo, *shelved, **opts)
>          ui.quiet = oldquiet
>          if tr:
>              tr.release()
> +        if dsguard:
> +            dsguard.release()
>          lockmod.release(lock, wlock)
>
>  @command('shelve',
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list