diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2606,7 +2606,7 @@ def revert(ui, repo, *pats, **opts): if not opts.get('dry_run'): repo.dirstate.forget(forget[0]) - r = hg.revert(repo, node, update.has_key) + r = hg.revert(repo, node, update.has_key, wlock) repo.dirstate.update(add[0], 'a') repo.dirstate.update(undelete[0], 'n') repo.dirstate.update(remove[0], 'r') diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -220,10 +220,10 @@ def merge(repo, node, force=None, remind return _merge.update(repo, node, branchmerge=True, forcemerge=force, remind=remind, wlock=wlock) -def revert(repo, node, choose): +def revert(repo, node, choose, wlock): """revert changes to revision in node without updating dirstate""" return _merge.update(repo, node, force=True, partial=choose, - show_stats=False) + show_stats=False, wlock=wlock) def verify(repo): """verify the consistency of a repository""" diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -49,6 +49,10 @@ def merge3(repo, fn, my, other, p1, p2): def update(repo, node, branchmerge=False, force=False, partial=None, forcemerge=False, wlock=None, show_stats=True, remind=True): + + if not wlock: + wlock = repo.wlock() + pl = repo.dirstate.parents() if not force and pl[1] != nullid: raise util.Abort(_("outstanding uncommitted merges")) @@ -110,8 +114,6 @@ def update(repo, node, branchmerge=False mw[f] = "" mfw[f] = util.is_exec(repo.wjoin(f), mfw.get(f, False)) - if not partial and not wlock: wlock = repo.wlock() - for f in deleted + removed: if f in mw: del mw[f]