changeset 20186:f5b461a4bc55

branchmap: introduce branchtip() method
author Brodie Rao <brodie@sf.io>
date Mon, 16 Sep 2013 01:08:29 -0700
parents 7d4219512823
children 4d6d5ef88538
files mercurial/branchmap.py
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/branchmap.py	Mon Sep 16 01:08:29 2013 -0700
+++ b/mercurial/branchmap.py	Mon Sep 16 01:08:29 2013 -0700
@@ -166,6 +166,19 @@
         except IndexError:
             return False
 
+    def _branchtip(self, heads):
+        tip = heads[-1]
+        closed = True
+        for h in reversed(heads):
+            if h not in self._closednodes:
+                tip = h
+                closed = False
+                break
+        return tip, closed
+
+    def branchtip(self, branch):
+        return self._branchtip(self[branch])[0]
+
     def copy(self):
         """return an deep copy of the branchcache object"""
         return branchcache(self, self.tipnode, self.tiprev, self.filteredhash,