[PATCH 3 of 6] scmutil.addremove: remove redundant directory and symlink checks

Siddharth Agarwal sid0 at fb.com
Tue Apr 2 14:36:34 CDT 2013


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1364931253 25200
#      Tue Apr 02 12:34:13 2013 -0700
# Node ID 808296ac211eca66234a2c7e5c7fcccb3d81d2ab
# Parent  891827de9c10b0bbedd2e74ef48189dfb4af77e1
scmutil.addremove: remove redundant directory and symlink checks

dirstate.walk only does lstats and never returns stat objects for directories.

On a large repository with 170,000 files, this speeds perfaddremove up from
2.29 seconds to 2.23.

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -686,8 +686,7 @@ def addremove(repo, pats=[], opts={}, dr
             if repo.ui.verbose or not m.exact(abs):
                 rel = m.rel(abs)
                 repo.ui.status(_('adding %s\n') % ((pats and rel) or abs))
-        elif (dstate != 'r' and (not st or
-               (stat.S_ISDIR(st.st_mode) and not stat.S_ISLNK(st.st_mode)))):
+        elif dstate != 'r' and not st:
             deleted.append(abs)
             if repo.ui.verbose or not m.exact(abs):
                 rel = m.rel(abs)


More information about the Mercurial-devel mailing list