[PATCH] applyupdates: audit unlinking of renamed files and directories

Adrian Buehlmann adrian at cadifra.com
Sat May 21 05:45:59 CDT 2011


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1305936300 -7200
# Node ID ddb1ed50c6c5267c67b928c0242de81300af1745
# Parent  bb5cbc16349e47adc8f8300fed3c397e0f54f4ec
applyupdates: audit unlinking of renamed files and directories

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -296,14 +296,15 @@
             if f != fd and move:
                 moves.append(f)
 
+    audit = scmutil.pathauditor(repo.root)
+
     # remove renamed files after safely stored
     for f in moves:
         if os.path.lexists(repo.wjoin(f)):
             repo.ui.debug("removing %s\n" % f)
+            audit(f)
             os.unlink(repo.wjoin(f))
 
-    audit_path = scmutil.pathauditor(repo.root)
-
     numupdates = len(action)
     for i, a in enumerate(action):
         f, m = a[:2]
@@ -313,7 +314,7 @@
             continue
         if m == "r": # remove
             repo.ui.note(_("removing %s\n") % f)
-            audit_path(f)
+            audit(f)
             if f == '.hgsubstate': # subrepo states need updating
                 subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
             try:
@@ -340,6 +341,7 @@
             if (move and repo.dirstate.normalize(fd) != f
                 and os.path.lexists(repo.wjoin(f))):
                 repo.ui.debug("removing %s\n" % f)
+                audit(f)
                 os.unlink(repo.wjoin(f))
         elif m == "g": # get
             flags = a[2]
@@ -354,6 +356,7 @@
             f2, fd, flags = a[2:]
             if f:
                 repo.ui.note(_("moving %s to %s\n") % (f, fd))
+                audit(f)
                 t = wctx.filectx(f).data()
                 repo.wwrite(fd, t, flags)
                 util.unlinkpath(repo.wjoin(f))


More information about the Mercurial-devel mailing list