[PATCH STABLE] commit: increase perf by avoiding checks against entire repo subsets
Durham Goode
durham at fb.com
Fri Nov 16 17:42:58 CST 2012
# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1353109152 28800
# Node ID c35a368bfc3e7562edee21ffc1e3d22e6a461465
# Parent 270338011eff9c88433e9cced0ba4a1c424b3d4a
commit: increase perf by avoiding checks against entire repo subsets
When commiting to a repo with lots of history (>400000 changesets)
checking the results of revset.py:descendants against the subset takes
some time. Since the subset equals the entire changelog, the check
isn't necessary. Avoiding it in that case saves 0.1 seconds off of
a 1.78 second commit. A 6% gain.
We use the length of the subset to determine if it is the entire repo.
There is precedence for this in revset.py:stringset.
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -584,6 +584,14 @@
if not args:
return []
s = set(_revdescendants(repo, args, followfirst)) | set(args)
+
+ if len(subset) == len(repo):
+ # the passed in revisions may not exist, -1 for example
+ for arg in args:
+ if arg not in subset:
+ s.remove(arg)
+ return list(s)
+
return [r for r in subset if r in s]
def descendants(repo, subset, x):
@@ -1341,7 +1349,10 @@
Changesets in set with no parent changeset in set.
"""
s = set(getset(repo, repo.changelog, x))
- subset = [r for r in subset if r in s]
+ if len(subset) == len(repo):
+ subset = s
+ else:
+ subset = [r for r in subset if r in s]
cs = _children(repo, subset, s)
return [r for r in subset if r not in cs]
More information about the Mercurial-devel
mailing list