changeset 3413:cc9c31b07c2c

Add branch method to contexts
author Matt Mackall <mpm@selenic.com>
date Tue, 17 Oct 2006 18:30:12 -0500
parents f2de6b6bc57a
children 52617d992eed
files mercurial/context.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Tue Oct 17 18:01:14 2006 -0500
+++ b/mercurial/context.py	Tue Oct 17 18:30:12 2006 -0500
@@ -64,6 +64,7 @@
     def date(self): return self._changeset[2]
     def files(self): return self._changeset[3]
     def description(self): return self._changeset[4]
+    def branch(self): return self._changeset[5].get("branch", "")
 
     def parents(self):
         """return contexts for each parent changeset"""
@@ -192,6 +193,7 @@
     def date(self): return self._changectx.date()
     def files(self): return self._changectx.files()
     def description(self): return self._changectx.description()
+    def branch(self): return self._changectx.branch()
     def manifest(self): return self._changectx.manifest()
     def changectx(self): return self._changectx
 
@@ -388,6 +390,11 @@
     def deleted(self): return self._status[3]
     def unknown(self): return self._status[4]
     def clean(self): return self._status[5]
+    def branch(self):
+        try:
+            return self._repo.opener("branch").read().strip()
+        except IOError:
+            return ""
 
     def parents(self):
         """return contexts for each parent changeset"""