1157 # sort the output in rev descending order |
1157 # sort the output in rev descending order |
1158 heads = [(-self.changelog.rev(h), h) for h in heads] |
1158 heads = [(-self.changelog.rev(h), h) for h in heads] |
1159 return [n for (r, n) in sorted(heads)] |
1159 return [n for (r, n) in sorted(heads)] |
1160 |
1160 |
1161 def branchheads(self, branch=None, start=None, closed=False): |
1161 def branchheads(self, branch=None, start=None, closed=False): |
|
1162 '''return a (possibly filtered) list of heads for the given branch |
|
1163 |
|
1164 Heads are returned in topological order, from newest to oldest. |
|
1165 If branch is None, use the dirstate branch. |
|
1166 If start is not None, return only heads reachable from start. |
|
1167 If closed is True, return heads that are marked as closed as well. |
|
1168 ''' |
1162 if branch is None: |
1169 if branch is None: |
1163 branch = self[None].branch() |
1170 branch = self[None].branch() |
1164 branches = self.branchmap() |
1171 branches = self.branchmap() |
1165 if branch not in branches: |
1172 if branch not in branches: |
1166 return [] |
1173 return [] |
1167 bheads = branches[branch] |
|
1168 # the cache returns heads ordered lowest to highest |
1174 # the cache returns heads ordered lowest to highest |
1169 bheads.reverse() |
1175 bheads = list(reversed(branches[branch])) |
1170 if start is not None: |
1176 if start is not None: |
1171 # filter out the heads that cannot be reached from startrev |
1177 # filter out the heads that cannot be reached from startrev |
1172 bheads = self.changelog.nodesbetween([start], bheads)[2] |
1178 fbheads = set(self.changelog.nodesbetween([start], bheads)[2]) |
|
1179 bheads = [h for h in bheads if h in fbheads] |
1173 if not closed: |
1180 if not closed: |
1174 bheads = [h for h in bheads if |
1181 bheads = [h for h in bheads if |
1175 ('close' not in self.changelog.read(h)[5])] |
1182 ('close' not in self.changelog.read(h)[5])] |
1176 return bheads |
1183 return bheads |
1177 |
1184 |