comparison mercurial/revset.py @ 23062:ba89f7b542c9 stable

revset: have rev() drop out-of-range or filtered rev explicitly (issue4396) The recent optimization of "and" operation relies on the assumption that the rhs set does not contain invalid revisions. So rev() has to remove invalid revisions. This is still faster than using `.filter(lambda r: r == l)`. revset #0: rev(25) 0) wall 0.026341 comb 0.020000 user 0.020000 sys 0.000000 (best of 113) 1) wall 0.000038 comb 0.000000 user 0.000000 sys 0.000000 (best of 66567) 2) wall 0.000062 comb 0.000000 user 0.000000 sys 0.000000 (best of 43699) (0: bbf4f3dfd700^, 1: 3.2-rc, 2: this patch)
author Yuya Nishihara <yuya@tcha.org>
date Sun, 19 Oct 2014 16:48:33 +0900
parents f2aeff8a87b6
children eb763217152a
comparison
equal deleted inserted replaced
23061:f2aeff8a87b6 23062:ba89f7b542c9
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:
1355 return baseset()
1354 return subset & baseset([l]) 1356 return subset & baseset([l])
1355 1357
1356 def matching(repo, subset, x): 1358 def matching(repo, subset, x):
1357 """``matching(revision [, field])`` 1359 """``matching(revision [, field])``
1358 Changesets in which a given set of fields match the set of fields in the 1360 Changesets in which a given set of fields match the set of fields in the