[PATCH 1 of 4] addremove: only query dirstate once per path
Durham Goode
durham at fb.com
Mon Feb 4 21:20:46 CST 2013
# HG changeset patch
# User Durham Goode <durham at 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%).
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:
More information about the Mercurial-devel
mailing list