# HG changeset patch # User Pierre-Yves David # Date 1407370131 25200 # Node ID 155949287628748e1a5bbeb2779c027fc9a7a642 # Parent 0c733dab0036a4cda47836f3a3aab9353eff0bf9 uncommit: saner locking scheme (and do it in the right order in the process) diff -r 0c733dab0036 -r 155949287628 hgext/evolve.py --- a/hgext/evolve.py Wed Aug 06 17:40:55 2014 -0700 +++ b/hgext/evolve.py Wed Aug 06 17:08:51 2014 -0700 @@ -1953,44 +1953,43 @@ Return 0 if changed files are uncommitted. """ - lock = repo.lock() + + wlock = lock = None try: wlock = repo.wlock() - try: - wctx = repo[None] - if len(wctx.parents()) <= 0: - raise util.Abort(_("cannot uncommit null changeset")) - if len(wctx.parents()) > 1: - raise util.Abort(_("cannot uncommit while merging")) - old = repo['.'] - if old.phase() == phases.public: - raise util.Abort(_("cannot rewrite immutable changeset")) - if len(old.parents()) > 1: - raise util.Abort(_("cannot uncommit merge changeset")) - oldphase = old.phase() - updatebookmarks = _bookmarksupdater(repo, old.node()) - # Recommit the filtered changeset - newid = None - if (pats or opts.get('include') or opts.get('exclude') - or opts.get('all')): - match = scmutil.match(old, pats, opts) - newid = _commitfiltered(repo, old, match) - if newid is None: - raise util.Abort(_('nothing to uncommit'), - hint=_("use --all to uncommit all files")) - # Move local changes on filtered changeset - createmarkers(repo, [(old, (repo[newid],))]) - retractboundary(repo, oldphase, [newid]) - repo.dirstate.setparents(newid, node.nullid) - _uncommitdirstate(repo, old, match) - updatebookmarks(newid) - if not repo[newid].files(): - ui.warn(_("new changeset is empty\n")) - ui.status(_('(use "hg prune ." to remove it)\n')) - finally: - wlock.release() + lock = repo.lock() + wctx = repo[None] + if len(wctx.parents()) <= 0: + raise util.Abort(_("cannot uncommit null changeset")) + if len(wctx.parents()) > 1: + raise util.Abort(_("cannot uncommit while merging")) + old = repo['.'] + if old.phase() == phases.public: + raise util.Abort(_("cannot rewrite immutable changeset")) + if len(old.parents()) > 1: + raise util.Abort(_("cannot uncommit merge changeset")) + oldphase = old.phase() + updatebookmarks = _bookmarksupdater(repo, old.node()) + # Recommit the filtered changeset + newid = None + if (pats or opts.get('include') or opts.get('exclude') + or opts.get('all')): + match = scmutil.match(old, pats, opts) + newid = _commitfiltered(repo, old, match) + if newid is None: + raise util.Abort(_('nothing to uncommit'), + hint=_("use --all to uncommit all files")) + # Move local changes on filtered changeset + createmarkers(repo, [(old, (repo[newid],))]) + retractboundary(repo, oldphase, [newid]) + repo.dirstate.setparents(newid, node.nullid) + _uncommitdirstate(repo, old, match) + updatebookmarks(newid) + if not repo[newid].files(): + ui.warn(_("new changeset is empty\n")) + ui.status(_('(use "hg prune ." to remove it)\n')) finally: - lock.release() + lockmod.release(lock, wlock) @eh.wrapcommand('commit') def commitwrapper(orig, ui, repo, *arg, **kwargs):