localrepo: use lock.release for single lock
authorSimon Heimberg <simohe@besonet.ch>
Wed, 27 May 2009 14:16:13 +0200
changeset 8646 60f9e574b6eb
parent 8645 27638a233577
child 8647 cb74433f9b41
localrepo: use lock.release for single lock
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Wed May 27 23:39:41 2009 +0200
+++ b/mercurial/localrepo.py	Wed May 27 14:16:13 2009 +0200
@@ -971,18 +971,17 @@
 
                 # update dirstate for files that are actually clean
                 if fixup:
-                    wlock = None
                     try:
+                        wlock = self.wlock(False)
                         try:
                             # updating the dirstate is optional
                             # so we don't wait on the lock
-                            wlock = self.wlock(False)
                             for f in fixup:
                                 self.dirstate.normal(f)
-                        except error.LockError:
-                            pass
-                    finally:
-                        release(wlock)
+                        finally:
+                            wlock.release()
+                    except error.LockError:
+                        pass
 
         if not parentworking:
             mf1 = mfmatches(ctx1)
@@ -1062,16 +1061,15 @@
             wlock.release()
 
     def remove(self, list, unlink=False):
-        wlock = None
+        if unlink:
+            for f in list:
+                try:
+                    util.unlink(self.wjoin(f))
+                except OSError, inst:
+                    if inst.errno != errno.ENOENT:
+                        raise
+        wlock = self.wlock()
         try:
-            if unlink:
-                for f in list:
-                    try:
-                        util.unlink(self.wjoin(f))
-                    except OSError, inst:
-                        if inst.errno != errno.ENOENT:
-                            raise
-            wlock = self.wlock()
             for f in list:
                 if unlink and os.path.exists(self.wjoin(f)):
                     self.ui.warn(_("%s still exists!\n") % f)
@@ -1082,7 +1080,7 @@
                 else:
                     self.dirstate.remove(f)
         finally:
-            release(wlock)
+            wlock.release()
 
     def undelete(self, list):
         manifests = [self.manifest.read(self.changelog.read(p)[0])