[PATCH 4 of 5] workingctx: unlink files while wlock held

Adrian Buehlmann adrian at cadifra.com
Mon May 23 09:56:12 CDT 2011


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1306157454 -7200
# Node ID d9fb24393d26600a9146192fdd231160997fbc4a
# Parent  ff576ed31f699e1db227c7cd23f0f32659da9bae
workingctx: unlink files while wlock held

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -841,17 +841,17 @@
             yield changectx(self._repo, a)
 
     def remove(self, list, unlink=False, unlinkadded=True):
-        if unlink:
-            for f in list:
-                if not unlinkadded and self._repo.dirstate[f] == 'a':
-                    continue
-                try:
-                    util.unlinkpath(self._repo.wjoin(f))
-                except OSError, inst:
-                    if inst.errno != errno.ENOENT:
-                        raise
         wlock = self._repo.wlock()
         try:
+            if unlink:
+                for f in list:
+                    if not unlinkadded and self._repo.dirstate[f] == 'a':
+                        continue
+                    try:
+                        util.unlinkpath(self._repo.wjoin(f))
+                    except OSError, inst:
+                        if inst.errno != errno.ENOENT:
+                            raise
             for f in list:
                 if self._repo.dirstate[f] == 'a':
                     self._repo.dirstate.forget(f)


More information about the Mercurial-devel mailing list