changeset 6641:1603bba96411

merge from crew-stable
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Thu, 29 May 2008 22:23:33 +0200
parents d6b53b48943f (current diff) a2b13cac0922 (diff)
children c8c7248f6172
files mercurial/commands.py
diffstat 5 files changed, 30 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu May 29 16:29:28 2008 +0200
+++ b/mercurial/commands.py	Thu May 29 22:23:33 2008 +0200
@@ -373,30 +373,26 @@
     List the repository's named branches, indicating which ones are
     inactive. If active is specified, only show active branches.
 
-    A branch is considered active if it contains unmerged heads.
+    A branch is considered active if it contains repository heads.
 
     Use the command 'hg update' to switch to an existing branch.
     """
-    b = repo.branchtags()
-    heads = dict.fromkeys(repo.heads(), 1)
-    l = [((n in heads), repo.changelog.rev(n), n, t) for t, n in b.items()]
-    l.sort()
-    l.reverse()
-    for ishead, r, n, t in l:
-        if active and not ishead:
-            # If we're only displaying active branches, abort the loop on
-            # encountering the first inactive head
-            break
-        else:
-            hexfunc = ui.debugflag and hex or short
+    hexfunc = ui.debugflag and hex or short
+    activebranches = [util.tolocal(repo.changectx(n).branch())
+                            for n in repo.heads()]
+    branches = [(tag in activebranches, repo.changelog.rev(node), tag)
+                            for tag, node in repo.branchtags().items()]
+    branches.sort(reverse=True)
+
+    for isactive, node, tag in branches:
+        if (not active) or isactive:
             if ui.quiet:
-                ui.write("%s\n" % t)
+                ui.write("%s\n" % tag)
             else:
-                spaces = " " * (30 - util.locallen(t))
-                # The code only gets here if inactive branches are being
-                # displayed or the branch is active.
-                isinactive = ((not ishead) and " (inactive)") or ''
-                ui.write("%s%s %s:%s%s\n" % (t, spaces, r, hexfunc(n), isinactive))
+                rev = str(node).rjust(32 - util.locallen(tag))
+                isinactive = ((not isactive) and " (inactive)") or ''
+                data = tag, rev, hexfunc(repo.lookup(node)), isinactive
+                ui.write("%s%s:%s%s\n" % data)
 
 def bundle(ui, repo, fname, dest=None, **opts):
     """create a changegroup file
--- a/mercurial/hgweb/protocol.py	Thu May 29 16:29:28 2008 +0200
+++ b/mercurial/hgweb/protocol.py	Thu May 29 22:23:33 2008 +0200
@@ -224,5 +224,7 @@
         os.unlink(tempname)
 
 def stream_out(web, req):
+    if not web.allowpull:
+        return
     req.respond(HTTP_OK, HGTYPE)
     streamclone.stream_out(web.repo, req, untrusted=True)
--- a/tests/test-branches	Thu May 29 16:29:28 2008 +0200
+++ b/tests/test-branches	Thu May 29 22:23:33 2008 +0200
@@ -31,6 +31,11 @@
 hg branch c
 hg commit -d '5 0' -u test -m "Adding c branch"
 
+echo 'd' >d
+hg add d
+hg branch d
+hg commit -d '6 0' -u test -m "Adding d branch"
+
 hg branches
 echo '-------'
 hg branches -a
--- a/tests/test-branches.out	Thu May 29 16:29:28 2008 +0200
+++ b/tests/test-branches.out	Thu May 29 22:23:33 2008 +0200
@@ -5,12 +5,15 @@
 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
 created new head
 marked working directory as branch c
-c                              5:5ca481e59b8c
+marked working directory as branch d
+d                              6:9c581c5ff105
+b                              4:22df7444f7c1
 a                              1:dd6b440dd85a
-b                              4:22df7444f7c1 (inactive)
+c                              5:5ca481e59b8c (inactive)
 default                        0:19709c5a4e75 (inactive)
 -------
-c                              5:5ca481e59b8c
+d                              6:9c581c5ff105
+b                              4:22df7444f7c1
 a                              1:dd6b440dd85a
 --- Branch a
 changeset:   1:dd6b440dd85a
--- a/tests/test-convert-svn-branches.out	Thu May 29 16:29:28 2008 +0200
+++ b/tests/test-convert-svn-branches.out	Thu May 29 22:23:33 2008 +0200
@@ -123,8 +123,8 @@
 |/
 o  branch= 0 init projA files:
 
-old3                           11:
-default                        10:
+old3                          11:
+default                       10:
 old                            9:
 old2                           8:
 tip