##// END OF EJS Templates
Active branches fix (issue1104)
Stefano Tortarolo -
r6631:a2b13cac default
parent child Browse files
Show More
@@ -371,30 +371,26 b' def branches(ui, repo, active=False):'
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
@@ -31,6 +31,11 b' hg add c'
31 hg branch c
31 hg branch c
32 hg commit -d '5 0' -u test -m "Adding c branch"
32 hg commit -d '5 0' -u test -m "Adding c branch"
33
33
34 echo 'd' >d
35 hg add d
36 hg branch d
37 hg commit -d '6 0' -u test -m "Adding d branch"
38
34 hg branches
39 hg branches
35 echo '-------'
40 echo '-------'
36 hg branches -a
41 hg branches -a
@@ -5,12 +5,15 b' created new head'
5 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
5 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
6 created new head
6 created new head
7 marked working directory as branch c
7 marked working directory as branch c
8 c 5:5ca481e59b8c
8 marked working directory as branch d
9 d 6:9c581c5ff105
10 b 4:22df7444f7c1
9 a 1:dd6b440dd85a
11 a 1:dd6b440dd85a
10 b 4:22df7444f7c1 (inactive)
12 c 5:5ca481e59b8c (inactive)
11 default 0:19709c5a4e75 (inactive)
13 default 0:19709c5a4e75 (inactive)
12 -------
14 -------
13 c 5:5ca481e59b8c
15 d 6:9c581c5ff105
16 b 4:22df7444f7c1
14 a 1:dd6b440dd85a
17 a 1:dd6b440dd85a
15 --- Branch a
18 --- Branch a
16 changeset: 1:dd6b440dd85a
19 changeset: 1:dd6b440dd85a
@@ -123,8 +123,8 b' o branch=old3 11 branch trunk@1 into ol'
123 |/
123 |/
124 o branch= 0 init projA files:
124 o branch= 0 init projA files:
125
125
126 old3 11:
126 old3 11:
127 default 10:
127 default 10:
128 old 9:
128 old 9:
129 old2 8:
129 old2 8:
130 tip
130 tip
General Comments 0
You need to be logged in to leave comments. Login now