changeset 18558:eb95cf4e219d

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%).
author Durham Goode <durham@fb.com>
date Mon, 04 Feb 2013 14:01:40 -0800
parents 945ba91c5e16
children d1582dd6288e
files mercurial/scmutil.py
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/scmutil.py	Mon Feb 04 23:48:34 2013 +0100
+++ b/mercurial/scmutil.py	Mon Feb 04 14:01:40 2013 -0800
@@ -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: