comparison mercurial/revset.py @ 23078:eb763217152a stable

revset: avoid O(n) lookup of invalid revision in rev() ba89f7b542c9 was not the final version of that patch. It was really slow because `l not in repo.changelog` iterates revisions up to `l`. Instead, rev() should utilize spanset.__contains__(). revset #0: rev(210000) 0) wall 0.000039 comb 0.000000 user 0.000000 sys 0.000000 (best of 67978) 1) wall 0.002721 comb 0.000000 user 0.000000 sys 0.000000 (best of 1055) 2) wall 0.000059 comb 0.000000 user 0.000000 sys 0.000000 (best of 45599) (0: 3.2-rc, 1: ba89f7b542c9, 2: this patch) Note that the benchmark result described in ba89f7b542c9 is wrong because it is the one of the initial version.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 23 Oct 2014 21:53:37 +0900
parents ba89f7b542c9
children ac494b087feb
comparison
equal deleted inserted replaced
23077:605a8cb61a0c 23078:eb763217152a
1349 # i18n: "rev" is a keyword 1349 # i18n: "rev" is a keyword
1350 l = int(getstring(l[0], _("rev requires a number"))) 1350 l = int(getstring(l[0], _("rev requires a number")))
1351 except (TypeError, ValueError): 1351 except (TypeError, ValueError):
1352 # i18n: "rev" is a keyword 1352 # i18n: "rev" is a keyword
1353 raise error.ParseError(_("rev expects a number")) 1353 raise error.ParseError(_("rev expects a number"))
1354 if l not in repo.changelog: 1354 if l not in fullreposet(repo):
1355 return baseset() 1355 return baseset()
1356 return subset & baseset([l]) 1356 return subset & baseset([l])
1357 1357
1358 def matching(repo, subset, x): 1358 def matching(repo, subset, x):
1359 """``matching(revision [, field])`` 1359 """``matching(revision [, field])``