comparison mercurial/revset.py @ 41276:5affe1583e1d

revset: use changelog's `headrevs` method to compute heads Instead of implementing our own algorithm, we reuse a more generic one. This previous algorithm did not leave much room for laziness so we do not really regress in that regards. A small impact is visible for first/last value in some of the simpler cases. The time needed to compute all values improves overall. Small optimization in the dagop.headrevs function will help to buy this back in the next changesets. There is room to introduce actual laziness in this algorithm, but this is out of scope for this series. This has no visible effect on expensive cases: revset: heads(matching(tip, "author")) plain min max first last reverse rev..rst rev..ast sort sor..rst sor..ast 0) 7.574666 7.545950 7.570743 7.578697 7.525725 7.509929 7.443854 7.488442 7.452880 7.445411 7.689107 1) 7.549390 7.389162 7.529790 7.536297 7.450467 7.555347 7.404586 7.514948 7.542794 7.524787 7.536918 revset: heads(matching(tip, "author")) and -10000:-1 plain min max first last reverse rev..rst rev..ast sort sor..rst sor..ast 0) 7.512533 7.605877 7.382894 7.462109 7.420086 7.575034 7.448452 7.549374 7.457880 7.450308 7.515019 1) 7.548677 7.551832 7.629598 7.494857 7.550554 7.521838 7.451794 error 7.321781 7.546885 7.557523 revset: (-10000:-1) and heads(matching(tip, "author")) plain min max first last reverse rev..rst rev..ast sort sor..rst sor..ast 0) 7.465419 7.570089 7.439594 7.521221 7.498716 7.492922 7.479108 7.552397 7.407888 error 7.468264 1) 7.539866 7.548045 7.491761 7.517170 7.469824 7.501990 7.579102 7.502568 7.578102 7.555754 7.567622 In simpler cases, we see a 10-15% impact when retrieving a single value, the full computation time is equivalent or improved: revset: (-5000:-1000) and heads(-10000:-1) plain min max first last reverse rev..rst rev..ast sort sor..rst sor..ast 0) 0.004244 0.003368 0.003313 0.003367 0.003327 0.004325 0.003401 0.003379 0.004310 0.003359 0.003396 1) 0.003969 93% 0.003862 114% 0.003834 115% 0.003810 113% 0.003822 114% 0.003940 91% 0.003908 114% 0.003814 112% 0.003986 92% 0.003954 117% 0.003816 112% revset: heads(all()) plain min max first last reverse rev..rst rev..ast sort sor..rst sor..ast 0) 0.036503 0.032564 0.030024 0.032378 0.030887 0.036367 0.031713 0.032205 0.036467 0.032286 0.030300 1) 0.036668 0.035347 108% 0.035611 118% 0.035358 109% 0.035726 115% 0.036411 0.035261 111% 0.036096 112% 0.036052 0.035095 108% 0.035792 118% revset: heads(-10000:-1) plain min max first last reverse rev..rst rev..ast sort sor..rst sor..ast 0) 0.003936 0.003218 0.003227 0.003302 0.003328 0.003848 0.003305 0.003252 0.003839 0.003306 0.003279 1) 0.003870 0.003785 117% 0.003821 118% 0.003780 114% 0.003769 113% 0.003776 0.003792 114% 0.003805 117% 0.003810 0.003798 114% 0.003840 117%
author Boris Feld <boris.feld@octobus.net>
date Mon, 14 Jan 2019 17:10:51 +0100
parents 4c6fdc7e2e7d
children b1ea90613af3
comparison
equal deleted inserted replaced
41275:1421d0487a61 41276:5affe1583e1d
1167 """ 1167 """
1168 # argument set should never define order 1168 # argument set should never define order
1169 if order == defineorder: 1169 if order == defineorder:
1170 order = followorder 1170 order = followorder
1171 inputset = getset(repo, fullreposet(repo), x, order=order) 1171 inputset = getset(repo, fullreposet(repo), x, order=order)
1172 ps = set() 1172 wdirparents = None
1173 cl = repo.changelog 1173 if node.wdirrev in inputset:
1174 up = ps.update 1174 # a bit slower, but not common so good enough for now
1175 parentrevs = cl.parentrevs 1175 wdirparents = [p.rev() for p in repo[None].parents()]
1176 for r in inputset: 1176 inputset = set(inputset)
1177 try: 1177 inputset.discard(node.wdirrev)
1178 up(parentrevs(r)) 1178 heads = repo.changelog.headrevs(inputset)
1179 except error.WdirUnsupported: 1179 if wdirparents is not None:
1180 up(p.rev() for p in repo[r].parents()) 1180 heads.difference_update(wdirparents)
1181 ps.discard(node.nullrev) 1181 heads.add(node.wdirrev)
1182 return subset & (inputset - ps) 1182 heads = baseset(heads)
1183 return subset & heads
1183 1184
1184 @predicate('hidden()', safe=True) 1185 @predicate('hidden()', safe=True)
1185 def hidden(repo, subset, x): 1186 def hidden(repo, subset, x):
1186 """Hidden changesets. 1187 """Hidden changesets.
1187 """ 1188 """