changeset 2812:3aeab7bb5adc

Refactor update locking slightly
author Matt Mackall <mpm@selenic.com>
date Tue, 08 Aug 2006 09:19:20 -0500
parents 1ea086bc2086
children 56f99f5aab34
files mercurial/commands.py mercurial/hg.py mercurial/merge.py
diffstat 3 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Aug 08 09:11:16 2006 -0500
+++ b/mercurial/commands.py	Tue Aug 08 09:19:20 2006 -0500
@@ -2606,7 +2606,7 @@
 
     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')
--- a/mercurial/hg.py	Tue Aug 08 09:11:16 2006 -0500
+++ b/mercurial/hg.py	Tue Aug 08 09:19:20 2006 -0500
@@ -220,10 +220,10 @@
     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"""
--- a/mercurial/merge.py	Tue Aug 08 09:11:16 2006 -0500
+++ b/mercurial/merge.py	Tue Aug 08 09:19:20 2006 -0500
@@ -49,6 +49,10 @@
 
 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 @@
         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]