branchmap: introduce branchtip() method
authorBrodie Rao <brodie@sf.io>
Mon, 16 Sep 2013 01:08:29 -0700
changeset 20186 f5b461a4bc55
parent 20185 7d4219512823
child 20187 4d6d5ef88538
branchmap: introduce branchtip() method
mercurial/branchmap.py
--- 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,