Patchwork [1,of,4] addremove: only query dirstate once per path

login
register
mail settings
Submitter Durham Goode
Date Feb. 5, 2013, 3:20 a.m.
Message ID <3457575aad13d6e7b8cc.1360034446@dev350.prn1.facebook.com>
Download mbox | patch
Permalink /patch/803/
State Accepted
Commit eb95cf4e219d02ec9e80f979b8c58989bf4080af
Headers show

Comments

Durham Goode - Feb. 5, 2013, 3:20 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1360015300 28800
# Node ID 3457575aad13d6e7b8ccb9a45f9e49cf1f2b27fe
# Parent  fe2651b3ac978d86b06a1e7c5f614c761f024e93
addremove: only query dirstate once per path

Previously the addremove code queried the dirstate 4 times per path. Now it
only does so once.  On a large repo this brings addremove from 9.5 seconds
to 8.35 seconds (12%).

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -742,20 +742,22 @@ 
             good = False
         rel = m.rel(abs)
         exact = m.exact(abs)
-        if good and abs not in repo.dirstate:
+
+        dstate = repo.dirstate[abs]
+        if good and dstate == '?':
             unknown.append(abs)
             if repo.ui.verbose or not exact:
                 repo.ui.status(_('adding %s\n') % ((pats and rel) or abs))
-        elif (repo.dirstate[abs] != 'r' and
+        elif (dstate != 'r' and
               (not good or not os.path.lexists(target) or
                (os.path.isdir(target) and not os.path.islink(target)))):
             deleted.append(abs)
             if repo.ui.verbose or not exact:
                 repo.ui.status(_('removing %s\n') % ((pats and rel) or abs))
         # for finding renames
-        elif repo.dirstate[abs] == 'r':
+        elif dstate == 'r':
             removed.append(abs)
-        elif repo.dirstate[abs] == 'a':
+        elif dstate == 'a':
             added.append(abs)
     copies = {}
     if similarity > 0: