Add a repo branches subcommand to describe current branches
We now display a summary of the available topic branches in this
client, based upon a sorted union of all existing projects.
Bug: REPO-21
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/project.py b/project.py
index 2425467..4f560bd 100644
--- a/project.py
+++ b/project.py
@@ -306,6 +306,32 @@
"""
return self.config.GetBranch(name)
+ def GetBranches(self):
+ """Get all existing local branches.
+ """
+ current = self.CurrentBranch
+ all = self.bare_git.ListRefs()
+ heads = {}
+ pubd = {}
+
+ for name, id in all.iteritems():
+ if name.startswith(R_HEADS):
+ name = name[len(R_HEADS):]
+ b = self.GetBranch(name)
+ b.current = name == current
+ b.published = None
+ b.revision = id
+ heads[name] = b
+
+ for name, id in all.iteritems():
+ if name.startswith(R_PUB):
+ name = name[len(R_PUB):]
+ b = heads.get(name)
+ if b:
+ b.published = id
+
+ return heads
+
## Status Display ##