comparison mercurial/revset.py @ 17952:54cedee86e51 stable

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.
author Durham Goode <durham@fb.com>
date Fri, 16 Nov 2012 15:39:12 -0800
parents d8905e2c1301
children 49c85541617b b0affcb67cba
comparison
equal deleted inserted replaced
17951:6f79c32c0bdf 17952:54cedee86e51
569 def _descendants(repo, subset, x, followfirst=False): 569 def _descendants(repo, subset, x, followfirst=False):
570 args = getset(repo, list(repo), x) 570 args = getset(repo, list(repo), x)
571 if not args: 571 if not args:
572 return [] 572 return []
573 s = set(_revdescendants(repo, args, followfirst)) | set(args) 573 s = set(_revdescendants(repo, args, followfirst)) | set(args)
574
575 if len(subset) == len(repo):
576 # the passed in revisions may not exist, -1 for example
577 for arg in args:
578 if arg not in subset:
579 s.remove(arg)
580 return list(s)
581
574 return [r for r in subset if r in s] 582 return [r for r in subset if r in s]
575 583
576 def descendants(repo, subset, x): 584 def descendants(repo, subset, x):
577 """``descendants(set)`` 585 """``descendants(set)``
578 Changesets which are descendants of changesets in set. 586 Changesets which are descendants of changesets in set.
1326 def roots(repo, subset, x): 1334 def roots(repo, subset, x):
1327 """``roots(set)`` 1335 """``roots(set)``
1328 Changesets in set with no parent changeset in set. 1336 Changesets in set with no parent changeset in set.
1329 """ 1337 """
1330 s = set(getset(repo, repo.changelog, x)) 1338 s = set(getset(repo, repo.changelog, x))
1331 subset = [r for r in subset if r in s] 1339 if len(subset) == len(repo):
1340 subset = s
1341 else:
1342 subset = [r for r in subset if r in s]
1332 cs = _children(repo, subset, s) 1343 cs = _children(repo, subset, s)
1333 return [r for r in subset if r not in cs] 1344 return [r for r in subset if r not in cs]
1334 1345
1335 def secret(repo, subset, x): 1346 def secret(repo, subset, x):
1336 """``secret()`` 1347 """``secret()``