[PATCH] workingctx: unlink paths while holding the wlock

Adrian Buehlmann adrian at cadifra.com
Tue May 24 07:46:39 CDT 2011


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1306238900 -7200
# Node ID 17e7ee042dc451fae1363803ce10af8543bffd05
# Parent  25137d99a5ed215f302ffc1793590bdbdb437b55
workingctx: unlink paths while holding the wlock

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -852,15 +852,15 @@
             yield changectx(self._repo, a)
 
     def remove(self, list, unlink=False):
-        if unlink:
-            for f in list:
-                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:
+                    try:
+                        util.unlinkpath(self._repo.wjoin(f))
+                    except OSError, inst:
+                        if inst.errno != errno.ENOENT:
+                            raise
             for f in list:
                 if unlink and os.path.lexists(self._repo.wjoin(f)):
                     self._repo.ui.warn(_("%s still exists!\n") % f)


More information about the Mercurial-devel mailing list