comparison mercurial/commands.py @ 6631:a2b13cac0922

Active branches fix (issue1104)
author Stefano Tortarolo <stefano.tortarolo@gmail.com>
date Thu, 29 May 2008 22:21:29 +0200
parents 4d3a60d5c490
children 1603bba96411 4fa7701918ed
comparison
equal deleted inserted replaced
6630:8542fac26f63 6631:a2b13cac0922
369 """list repository named branches 369 """list repository named branches
370 370
371 List the repository's named branches, indicating which ones are 371 List the repository's named branches, indicating which ones are
372 inactive. If active is specified, only show active branches. 372 inactive. If active is specified, only show active branches.
373 373
374 A branch is considered active if it contains unmerged heads. 374 A branch is considered active if it contains repository heads.
375 375
376 Use the command 'hg update' to switch to an existing branch. 376 Use the command 'hg update' to switch to an existing branch.
377 """ 377 """
378 b = repo.branchtags() 378 hexfunc = ui.debugflag and hex or short
379 heads = dict.fromkeys(repo.heads(), 1) 379 activebranches = [util.tolocal(repo.changectx(n).branch())
380 l = [((n in heads), repo.changelog.rev(n), n, t) for t, n in b.items()] 380 for n in repo.heads()]
381 l.sort() 381 branches = [(tag in activebranches, repo.changelog.rev(node), tag)
382 l.reverse() 382 for tag, node in repo.branchtags().items()]
383 for ishead, r, n, t in l: 383 branches.sort(reverse=True)
384 if active and not ishead: 384
385 # If we're only displaying active branches, abort the loop on 385 for isactive, node, tag in branches:
386 # encountering the first inactive head 386 if (not active) or isactive:
387 break
388 else:
389 hexfunc = ui.debugflag and hex or short
390 if ui.quiet: 387 if ui.quiet:
391 ui.write("%s\n" % t) 388 ui.write("%s\n" % tag)
392 else: 389 else:
393 spaces = " " * (30 - util.locallen(t)) 390 rev = str(node).rjust(32 - util.locallen(tag))
394 # The code only gets here if inactive branches are being 391 isinactive = ((not isactive) and " (inactive)") or ''
395 # displayed or the branch is active. 392 data = tag, rev, hexfunc(repo.lookup(node)), isinactive
396 isinactive = ((not ishead) and " (inactive)") or '' 393 ui.write("%s%s:%s%s\n" % data)
397 ui.write("%s%s %s:%s%s\n" % (t, spaces, r, hexfunc(n), isinactive))
398 394
399 def bundle(ui, repo, fname, dest=None, **opts): 395 def bundle(ui, repo, fname, dest=None, **opts):
400 """create a changegroup file 396 """create a changegroup file
401 397
402 Generate a compressed changegroup file collecting changesets not 398 Generate a compressed changegroup file collecting changesets not