Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revset.py @ 26094:df41c7be16d6
reachableroots: construct and sort baseset in revset module
This can remove the dependency from changelog to revset, which seems a bit awkward
for me.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 28 Aug 2015 11:14:24 +0900 |
parents | 204131131766 |
children | 6eed95ca4c03 |
comparison
equal
deleted
inserted
replaced
26093:204131131766 | 26094:df41c7be16d6 |
---|---|
90 def reachablerootspure(repo, minroot, roots, heads, includepath): | 90 def reachablerootspure(repo, minroot, roots, heads, includepath): |
91 """return (heads(::<roots> and ::<heads>)) | 91 """return (heads(::<roots> and ::<heads>)) |
92 | 92 |
93 If includepath is True, return (<roots>::<heads>).""" | 93 If includepath is True, return (<roots>::<heads>).""" |
94 if not roots: | 94 if not roots: |
95 return baseset() | 95 return [] |
96 parentrevs = repo.changelog.parentrevs | 96 parentrevs = repo.changelog.parentrevs |
97 roots = set(roots) | 97 roots = set(roots) |
98 visit = list(heads) | 98 visit = list(heads) |
99 reachable = set() | 99 reachable = set() |
100 seen = {} | 100 seen = {} |
121 return reachable | 121 return reachable |
122 for rev in sorted(seen): | 122 for rev in sorted(seen): |
123 for parent in seen[rev]: | 123 for parent in seen[rev]: |
124 if parent in reachable: | 124 if parent in reachable: |
125 reached(rev) | 125 reached(rev) |
126 reachable = baseset(reachable) | |
127 reachable.sort() | |
128 return reachable | 126 return reachable |
129 | 127 |
130 def reachableroots(repo, roots, heads, includepath=False): | 128 def reachableroots(repo, roots, heads, includepath=False): |
131 """return (heads(::<roots> and ::<heads>)) | 129 """return (heads(::<roots> and ::<heads>)) |
132 | 130 |
135 return baseset() | 133 return baseset() |
136 minroot = roots.min() | 134 minroot = roots.min() |
137 roots = list(roots) | 135 roots = list(roots) |
138 heads = list(heads) | 136 heads = list(heads) |
139 try: | 137 try: |
140 return repo.changelog.reachableroots(minroot, heads, roots, includepath) | 138 revs = repo.changelog.reachableroots(minroot, heads, roots, includepath) |
141 except AttributeError: | 139 except AttributeError: |
142 return reachablerootspure(repo, minroot, roots, heads, includepath) | 140 revs = reachablerootspure(repo, minroot, roots, heads, includepath) |
141 revs = baseset(revs) | |
142 revs.sort() | |
143 return revs | |
143 | 144 |
144 elements = { | 145 elements = { |
145 # token-type: binding-strength, primary, prefix, infix, suffix | 146 # token-type: binding-strength, primary, prefix, infix, suffix |
146 "(": (21, None, ("group", 1, ")"), ("func", 1, ")"), None), | 147 "(": (21, None, ("group", 1, ")"), ("func", 1, ")"), None), |
147 "##": (20, None, None, ("_concat", 20), None), | 148 "##": (20, None, None, ("_concat", 20), None), |