changeset 8405:7cbf8fcd2453

commit: push repo lock down into _commitctx
author Matt Mackall <mpm@selenic.com>
date Thu, 14 May 2009 13:20:40 -0500
parents a2bc39ade36b
children 6ad1f72bdf34
files mercurial/localrepo.py
diffstat 1 files changed, 7 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Thu May 14 13:20:40 2009 -0500
+++ b/mercurial/localrepo.py	Thu May 14 13:20:40 2009 -0500
@@ -774,10 +774,9 @@
             force = True
         if files:
             files = list(set(files))
+
+        wlock = self.wlock()
         try:
-            wlock = self.wlock()
-            lock = self.lock()
-
             p1, p2 = self.dirstate.parents()
 
             if (not force and p2 != nullid and
@@ -817,7 +816,7 @@
             return r
 
         finally:
-            release(lock, wlock)
+            wlock.release()
 
     def commitctx(self, ctx):
         """Add a new revision to current repository.
@@ -825,15 +824,12 @@
         Revision information is passed in the context.memctx argument.
         commitctx() does not touch the working directory.
         """
-        lock = self.lock()
-        try:
-            return self._commitctx(ctx, force=True, force_editor=False,
-                                   empty_ok=True, working=False)
-        finally:
-            lock.release()
+        return self._commitctx(ctx, force=True, force_editor=False,
+                               empty_ok=True, working=False)
 
     def _commitctx(self, ctx, force=False, force_editor=False, empty_ok=False,
                    working=True):
+        lock = self.lock()
         tr = None
         valid = 0 # don't save the dirstate if this isn't set
         try:
@@ -958,6 +954,7 @@
             if not valid: # don't save our updated dirstate
                 self.dirstate.invalidate()
             del tr
+            lock.release()
 
     def walk(self, match, node=None):
         '''