From 27b07327bc9f4bcda2c29422e064bced092759e3 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 10 Apr 2009 16:02:48 -0700 Subject: 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 --- project.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'project.py') diff --git a/project.py b/project.py index 24254676..4f560bd6 100644 --- a/project.py +++ b/project.py @@ -306,6 +306,32 @@ class Project(object): """ 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 ## -- cgit v1.2.3-54-g00ecf