Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 20393:b0638b5b004d
revset: fixed bug where revset returning order was being changed
Some revsets were innecesarily turning the subset into a set before iterating
over it. This led to returning order changing in some cases.
author | Lucas Moscovicz <lmoscovicz@fb.com> |
---|---|
date | Fri, 07 Feb 2014 15:01:33 -0800 |
parents | 2ac278aab2b4 |
children | e72bcc245ecb |
comparison
equal
deleted
inserted
replaced
20392:d4f804caa0ed | 20393:b0638b5b004d |
---|---|
308 def _ancestors(repo, subset, x, followfirst=False): | 308 def _ancestors(repo, subset, x, followfirst=False): |
309 args = getset(repo, baseset(repo), x) | 309 args = getset(repo, baseset(repo), x) |
310 if not args: | 310 if not args: |
311 return baseset([]) | 311 return baseset([]) |
312 s = set(_revancestors(repo, args, followfirst)) | set(args) | 312 s = set(_revancestors(repo, args, followfirst)) | set(args) |
313 ss = subset.set() | 313 return baseset([r for r in subset if r in s]) |
314 return baseset([r for r in ss if r in s]) | |
315 | 314 |
316 def ancestors(repo, subset, x): | 315 def ancestors(repo, subset, x): |
317 """``ancestors(set)`` | 316 """``ancestors(set)`` |
318 Changesets that are ancestors of a changeset in set. | 317 Changesets that are ancestors of a changeset in set. |
319 """ | 318 """ |
337 cl = repo.changelog | 336 cl = repo.changelog |
338 for r in getset(repo, cl, x): | 337 for r in getset(repo, cl, x): |
339 for i in range(n): | 338 for i in range(n): |
340 r = cl.parentrevs(r)[0] | 339 r = cl.parentrevs(r)[0] |
341 ps.add(r) | 340 ps.add(r) |
342 s = subset.set() | 341 return baseset([r for r in subset if r in ps]) |
343 return baseset([r for r in s if r in ps]) | |
344 | 342 |
345 def author(repo, subset, x): | 343 def author(repo, subset, x): |
346 """``author(string)`` | 344 """``author(string)`` |
347 Alias for ``user(string)``. | 345 Alias for ``user(string)``. |
348 """ | 346 """ |
365 - ``current`` : the cset currently being bisected | 363 - ``current`` : the cset currently being bisected |
366 """ | 364 """ |
367 # i18n: "bisect" is a keyword | 365 # i18n: "bisect" is a keyword |
368 status = getstring(x, _("bisect requires a string")).lower() | 366 status = getstring(x, _("bisect requires a string")).lower() |
369 state = set(hbisect.get(repo, status)) | 367 state = set(hbisect.get(repo, status)) |
370 s = subset.set() | 368 return baseset([r for r in subset if r in state]) |
371 return baseset([r for r in s if r in state]) | |
372 | 369 |
373 # Backward-compatibility | 370 # Backward-compatibility |
374 # - no help entry so that we do not advertise it any more | 371 # - no help entry so that we do not advertise it any more |
375 def bisected(repo, subset, x): | 372 def bisected(repo, subset, x): |
376 return bisect(repo, subset, x) | 373 return bisect(repo, subset, x) |
409 bmrevs.add(repo[bmrev].rev()) | 406 bmrevs.add(repo[bmrev].rev()) |
410 return subset & bmrevs | 407 return subset & bmrevs |
411 | 408 |
412 bms = set([repo[r].rev() | 409 bms = set([repo[r].rev() |
413 for r in repo._bookmarks.values()]) | 410 for r in repo._bookmarks.values()]) |
414 s = subset.set() | 411 return baseset([r for r in subset if r in bms]) |
415 return baseset([r for r in s if r in bms]) | |
416 | 412 |
417 def branch(repo, subset, x): | 413 def branch(repo, subset, x): |
418 """``branch(string or set)`` | 414 """``branch(string or set)`` |
419 All changesets belonging to the given branch or the branches of the given | 415 All changesets belonging to the given branch or the branches of the given |
420 changesets. | 416 changesets. |
605 def _descendants(repo, subset, x, followfirst=False): | 601 def _descendants(repo, subset, x, followfirst=False): |
606 args = getset(repo, baseset(repo), x) | 602 args = getset(repo, baseset(repo), x) |
607 if not args: | 603 if not args: |
608 return baseset([]) | 604 return baseset([]) |
609 s = set(_revdescendants(repo, args, followfirst)) | set(args) | 605 s = set(_revdescendants(repo, args, followfirst)) | set(args) |
610 ss = subset.set() | 606 return baseset([r for r in subset if r in s]) |
611 return baseset([r for r in ss if r in s]) | |
612 | 607 |
613 def descendants(repo, subset, x): | 608 def descendants(repo, subset, x): |
614 """``descendants(set)`` | 609 """``descendants(set)`` |
615 Changesets which are descendants of changesets in set. | 610 Changesets which are descendants of changesets in set. |
616 """ | 611 """ |
746 if m(f): | 741 if m(f): |
747 fl = repo.file(f) | 742 fl = repo.file(f) |
748 for fr in fl: | 743 for fr in fl: |
749 s.add(fl.linkrev(fr)) | 744 s.add(fl.linkrev(fr)) |
750 | 745 |
751 ss = subset.set() | 746 return baseset([r for r in subset if r in s]) |
752 return baseset([r for r in ss if r in s]) | |
753 | 747 |
754 def first(repo, subset, x): | 748 def first(repo, subset, x): |
755 """``first(set, [n])`` | 749 """``first(set, [n])`` |
756 An alias for limit(). | 750 An alias for limit(). |
757 """ | 751 """ |
770 else: | 764 else: |
771 return baseset([]) | 765 return baseset([]) |
772 else: | 766 else: |
773 s = set(_revancestors(repo, [c.rev()], followfirst)) | set([c.rev()]) | 767 s = set(_revancestors(repo, [c.rev()], followfirst)) | set([c.rev()]) |
774 | 768 |
775 ss = subset.set() | 769 return baseset([r for r in subset if r in s]) |
776 return baseset([r for r in ss if r in s]) | |
777 | 770 |
778 def follow(repo, subset, x): | 771 def follow(repo, subset, x): |
779 """``follow([file])`` | 772 """``follow([file])`` |
780 An alias for ``::.`` (ancestors of the working copy's first parent). | 773 An alias for ``::.`` (ancestors of the working copy's first parent). |
781 If a filename is specified, the history of the given file is followed, | 774 If a filename is specified, the history of the given file is followed, |
900 # i18n: "head" is a keyword | 893 # i18n: "head" is a keyword |
901 getargs(x, 0, 0, _("head takes no arguments")) | 894 getargs(x, 0, 0, _("head takes no arguments")) |
902 hs = set() | 895 hs = set() |
903 for b, ls in repo.branchmap().iteritems(): | 896 for b, ls in repo.branchmap().iteritems(): |
904 hs.update(repo[h].rev() for h in ls) | 897 hs.update(repo[h].rev() for h in ls) |
905 s = subset.set() | 898 return baseset([r for r in subset if r in hs]) |
906 return baseset([r for r in s if r in hs]) | |
907 | 899 |
908 def heads(repo, subset, x): | 900 def heads(repo, subset, x): |
909 """``heads(set)`` | 901 """``heads(set)`` |
910 Members of set with no children in set. | 902 Members of set with no children in set. |
911 """ | 903 """ |
1083 if prev is None: | 1075 if prev is None: |
1084 return src | 1076 return src |
1085 src = prev | 1077 src = prev |
1086 | 1078 |
1087 o = set([_firstsrc(r) for r in args]) | 1079 o = set([_firstsrc(r) for r in args]) |
1088 s = subset.set() | 1080 return baseset([r for r in subset if r in o]) |
1089 return baseset([r for r in s if r in o]) | |
1090 | 1081 |
1091 def outgoing(repo, subset, x): | 1082 def outgoing(repo, subset, x): |
1092 """``outgoing([path])`` | 1083 """``outgoing([path])`` |
1093 Changesets not found in the specified destination repository, or the | 1084 Changesets not found in the specified destination repository, or the |
1094 default push location. | 1085 default push location. |
1107 repo.ui.pushbuffer() | 1098 repo.ui.pushbuffer() |
1108 outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs) | 1099 outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs) |
1109 repo.ui.popbuffer() | 1100 repo.ui.popbuffer() |
1110 cl = repo.changelog | 1101 cl = repo.changelog |
1111 o = set([cl.rev(r) for r in outgoing.missing]) | 1102 o = set([cl.rev(r) for r in outgoing.missing]) |
1112 s = subset.set() | 1103 return baseset([r for r in subset if r in o]) |
1113 return baseset([r for r in s if r in o]) | |
1114 | 1104 |
1115 def p1(repo, subset, x): | 1105 def p1(repo, subset, x): |
1116 """``p1([set])`` | 1106 """``p1([set])`` |
1117 First parent of changesets in set, or the working directory. | 1107 First parent of changesets in set, or the working directory. |
1118 """ | 1108 """ |
2068 else: | 2058 else: |
2069 s = set(x) | 2059 s = set(x) |
2070 return baseset(self.set() - s) | 2060 return baseset(self.set() - s) |
2071 | 2061 |
2072 def __and__(self, x): | 2062 def __and__(self, x): |
2073 s = self.set() | |
2074 if isinstance(x, baseset): | 2063 if isinstance(x, baseset): |
2075 x = x.set() | 2064 x = x.set() |
2076 return baseset([y for y in s if y in x]) | 2065 return baseset([y for y in self if y in x]) |
2077 | 2066 |
2078 # tell hggettext to extract docstrings from these functions: | 2067 # tell hggettext to extract docstrings from these functions: |
2079 i18nfunctions = symbols.values() | 2068 i18nfunctions = symbols.values() |