Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revset.py @ 29408:785cadec2091
revset: make head() honor order of subset
The ordering of 'x & head()' was broken in 6a1a4c212d50 (revset:
improve head revset performance, 2014-03-13). Presumably due to other
optimizations since then, undoing that change to fix the order does
not slow down the simple case of "hg log -r 'head()'" mentioned in
that commit. I see a small slowdown from ~0.16s to about ~0.19s with
'not 0 & head()', but I'd say it's worth it for the correct output.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 23 Jun 2016 12:37:09 -0700 |
parents | 20fabe814f89 |
children | bcefb25acf52 |
comparison
equal
deleted
inserted
replaced
29407:20fabe814f89 | 29408:785cadec2091 |
---|---|
1145 getargs(x, 0, 0, _("head takes no arguments")) | 1145 getargs(x, 0, 0, _("head takes no arguments")) |
1146 hs = set() | 1146 hs = set() |
1147 cl = repo.changelog | 1147 cl = repo.changelog |
1148 for ls in repo.branchmap().itervalues(): | 1148 for ls in repo.branchmap().itervalues(): |
1149 hs.update(cl.rev(h) for h in ls) | 1149 hs.update(cl.rev(h) for h in ls) |
1150 # XXX We should combine with subset first: 'subset & baseset(...)'. This is | 1150 return subset & baseset(hs) |
1151 # necessary to ensure we preserve the order in subset. | |
1152 return baseset(hs) & subset | |
1153 | 1151 |
1154 @predicate('heads(set)', safe=True) | 1152 @predicate('heads(set)', safe=True) |
1155 def heads(repo, subset, x): | 1153 def heads(repo, subset, x): |
1156 """Members of set with no children in set. | 1154 """Members of set with no children in set. |
1157 """ | 1155 """ |