Show More
@@ -431,7 +431,7 def branches(ui, repo, active=False): | |||||
431 | """ |
|
431 | """ | |
432 | hexfunc = ui.debugflag and hex or short |
|
432 | hexfunc = ui.debugflag and hex or short | |
433 | activebranches = [util.tolocal(repo[n].branch()) |
|
433 | activebranches = [util.tolocal(repo[n].branch()) | |
434 | for n in repo.heads()] |
|
434 | for n in repo.heads(closed=False)] | |
435 | branches = util.sort([(tag in activebranches, repo.changelog.rev(node), tag) |
|
435 | branches = util.sort([(tag in activebranches, repo.changelog.rev(node), tag) | |
436 | for tag, node in repo.branchtags().items()]) |
|
436 | for tag, node in repo.branchtags().items()]) | |
437 | branches.reverse() |
|
437 | branches.reverse() | |
@@ -441,9 +441,15 def branches(ui, repo, active=False): | |||||
441 | if ui.quiet: |
|
441 | if ui.quiet: | |
442 | ui.write("%s\n" % tag) |
|
442 | ui.write("%s\n" % tag) | |
443 | else: |
|
443 | else: | |
|
444 | hn = repo.lookup(node) | |||
|
445 | if isactive: | |||
|
446 | notice = '' | |||
|
447 | elif hn not in repo.branchheads(tag, closed=False): | |||
|
448 | notice = ' (closed)' | |||
|
449 | else: | |||
|
450 | notice = ' (inactive)' | |||
444 | rev = str(node).rjust(31 - util.locallen(tag)) |
|
451 | rev = str(node).rjust(31 - util.locallen(tag)) | |
445 | isinactive = ((not isactive) and " (inactive)") or '' |
|
452 | data = tag, rev, hexfunc(hn), notice | |
446 | data = tag, rev, hexfunc(repo.lookup(node)), isinactive |
|
|||
447 | ui.write("%s %s:%s%s\n" % data) |
|
453 | ui.write("%s %s:%s%s\n" % data) | |
448 |
|
454 | |||
449 | def bundle(ui, repo, fname, dest=None, **opts): |
|
455 | def bundle(ui, repo, fname, dest=None, **opts): | |
@@ -1266,9 +1272,10 def heads(ui, repo, *branchrevs, **opts) | |||||
1266 | start = repo.lookup(opts['rev']) |
|
1272 | start = repo.lookup(opts['rev']) | |
1267 | else: |
|
1273 | else: | |
1268 | start = None |
|
1274 | start = None | |
|
1275 | closed = not opts.get('active') | |||
1269 | if not branchrevs: |
|
1276 | if not branchrevs: | |
1270 | # Assume we're looking repo-wide heads if no revs were specified. |
|
1277 | # Assume we're looking repo-wide heads if no revs were specified. | |
1271 | heads = repo.heads(start) |
|
1278 | heads = repo.heads(start, closed=closed) | |
1272 | else: |
|
1279 | else: | |
1273 | heads = [] |
|
1280 | heads = [] | |
1274 | visitedset = util.set() |
|
1281 | visitedset = util.set() | |
@@ -1277,7 +1284,7 def heads(ui, repo, *branchrevs, **opts) | |||||
1277 | if branch in visitedset: |
|
1284 | if branch in visitedset: | |
1278 | continue |
|
1285 | continue | |
1279 | visitedset.add(branch) |
|
1286 | visitedset.add(branch) | |
1280 | bheads = repo.branchheads(branch, start) |
|
1287 | bheads = repo.branchheads(branch, start, closed=closed) | |
1281 | if not bheads: |
|
1288 | if not bheads: | |
1282 | if branch != branchrev: |
|
1289 | if branch != branchrev: | |
1283 | ui.warn(_("no changes on branch %s containing %s are " |
|
1290 | ui.warn(_("no changes on branch %s containing %s are " | |
@@ -3215,6 +3222,8 table = { | |||||
3215 | "heads": |
|
3222 | "heads": | |
3216 | (heads, |
|
3223 | (heads, | |
3217 | [('r', 'rev', '', _('show only heads which are descendants of rev')), |
|
3224 | [('r', 'rev', '', _('show only heads which are descendants of rev')), | |
|
3225 | ('a', 'active', False, | |||
|
3226 | _('show only the active heads from open branches')), | |||
3218 | ] + templateopts, |
|
3227 | ] + templateopts, | |
3219 | _('[-r REV] [REV]...')), |
|
3228 | _('[-r REV] [REV]...')), | |
3220 | "help": (help_, [], _('[TOPIC]')), |
|
3229 | "help": (help_, [], _('[TOPIC]')), |
@@ -398,8 +398,21 class localrepository(repo.repository): | |||||
398 |
|
398 | |||
399 | def branchtags(self): |
|
399 | def branchtags(self): | |
400 | '''return a dict where branch names map to the tipmost head of |
|
400 | '''return a dict where branch names map to the tipmost head of | |
401 | the branch''' |
|
401 | the branch, open heads come before closed''' | |
402 | return dict([(k, v[-1]) for (k, v) in self._branchheads().iteritems()]) |
|
402 | bt = {} | |
|
403 | for bn, heads in self._branchheads().iteritems(): | |||
|
404 | head = None | |||
|
405 | for i in range(len(heads)-1, -1, -1): | |||
|
406 | h = heads[i] | |||
|
407 | if 'close' not in self.changelog.read(h)[5]: | |||
|
408 | head = h | |||
|
409 | break | |||
|
410 | # no open heads were found | |||
|
411 | if head is None: | |||
|
412 | head = heads[-1] | |||
|
413 | bt[bn] = head | |||
|
414 | return bt | |||
|
415 | ||||
403 |
|
416 | |||
404 | def _readbranchcache(self): |
|
417 | def _readbranchcache(self): | |
405 | partial = {} |
|
418 | partial = {} | |
@@ -1180,13 +1193,18 class localrepository(repo.repository): | |||||
1180 | finally: |
|
1193 | finally: | |
1181 | del wlock |
|
1194 | del wlock | |
1182 |
|
1195 | |||
1183 | def heads(self, start=None): |
|
1196 | def heads(self, start=None, closed=True): | |
1184 | heads = self.changelog.heads(start) |
|
1197 | heads = self.changelog.heads(start) | |
|
1198 | def display(head): | |||
|
1199 | if closed: | |||
|
1200 | return True | |||
|
1201 | extras = self.changelog.read(head)[5] | |||
|
1202 | return ('close' not in extras) | |||
1185 | # sort the output in rev descending order |
|
1203 | # sort the output in rev descending order | |
1186 | heads = [(-self.changelog.rev(h), h) for h in heads] |
|
1204 | heads = [(-self.changelog.rev(h), h) for h in heads if display(h)] | |
1187 | return [n for (r, n) in util.sort(heads)] |
|
1205 | return [n for (r, n) in util.sort(heads)] | |
1188 |
|
1206 | |||
1189 | def branchheads(self, branch=None, start=None): |
|
1207 | def branchheads(self, branch=None, start=None, closed=True): | |
1190 | if branch is None: |
|
1208 | if branch is None: | |
1191 | branch = self[None].branch() |
|
1209 | branch = self[None].branch() | |
1192 | branches = self._branchheads() |
|
1210 | branches = self._branchheads() | |
@@ -1198,6 +1216,9 class localrepository(repo.repository): | |||||
1198 | if start is not None: |
|
1216 | if start is not None: | |
1199 | # filter out the heads that cannot be reached from startrev |
|
1217 | # filter out the heads that cannot be reached from startrev | |
1200 | bheads = self.changelog.nodesbetween([start], bheads)[2] |
|
1218 | bheads = self.changelog.nodesbetween([start], bheads)[2] | |
|
1219 | if not closed: | |||
|
1220 | bheads = [h for h in bheads if | |||
|
1221 | ('close' not in self.changelog.read(h)[5])] | |||
1201 | return bheads |
|
1222 | return bheads | |
1202 |
|
1223 | |||
1203 | def branches(self, nodes): |
|
1224 | def branches(self, nodes): |
General Comments 0
You need to be logged in to leave comments.
Login now