371 """list repository named branches |
371 """list repository named branches |
372 |
372 |
373 List the repository's named branches, indicating which ones are |
373 List the repository's named branches, indicating which ones are |
374 inactive. If active is specified, only show active branches. |
374 inactive. If active is specified, only show active branches. |
375 |
375 |
376 A branch is considered active if it contains unmerged heads. |
376 A branch is considered active if it contains repository heads. |
377 |
377 |
378 Use the command 'hg update' to switch to an existing branch. |
378 Use the command 'hg update' to switch to an existing branch. |
379 """ |
379 """ |
380 b = repo.branchtags() |
380 hexfunc = ui.debugflag and hex or short |
381 heads = dict.fromkeys(repo.heads(), 1) |
381 activebranches = [util.tolocal(repo.changectx(n).branch()) |
382 l = [((n in heads), repo.changelog.rev(n), n, t) for t, n in b.items()] |
382 for n in repo.heads()] |
383 l.sort() |
383 branches = [(tag in activebranches, repo.changelog.rev(node), tag) |
384 l.reverse() |
384 for tag, node in repo.branchtags().items()] |
385 for ishead, r, n, t in l: |
385 branches.sort(reverse=True) |
386 if active and not ishead: |
386 |
387 # If we're only displaying active branches, abort the loop on |
387 for isactive, node, tag in branches: |
388 # encountering the first inactive head |
388 if (not active) or isactive: |
389 break |
|
390 else: |
|
391 hexfunc = ui.debugflag and hex or short |
|
392 if ui.quiet: |
389 if ui.quiet: |
393 ui.write("%s\n" % t) |
390 ui.write("%s\n" % tag) |
394 else: |
391 else: |
395 spaces = " " * (30 - util.locallen(t)) |
392 rev = str(node).rjust(32 - util.locallen(tag)) |
396 # The code only gets here if inactive branches are being |
393 isinactive = ((not isactive) and " (inactive)") or '' |
397 # displayed or the branch is active. |
394 data = tag, rev, hexfunc(repo.lookup(node)), isinactive |
398 isinactive = ((not ishead) and " (inactive)") or '' |
395 ui.write("%s%s:%s%s\n" % data) |
399 ui.write("%s%s %s:%s%s\n" % (t, spaces, r, hexfunc(n), isinactive)) |
|
400 |
396 |
401 def bundle(ui, repo, fname, dest=None, **opts): |
397 def bundle(ui, repo, fname, dest=None, **opts): |
402 """create a changegroup file |
398 """create a changegroup file |
403 |
399 |
404 Generate a compressed changegroup file collecting changesets not |
400 Generate a compressed changegroup file collecting changesets not |