[PATCH 04 of 13 V2] branchmap: introduce branchtip() method

Brodie Rao brodie at sf.io
Fri Nov 15 22:18:48 CST 2013


# HG changeset patch
# User Brodie Rao <brodie at sf.io>
# Date 1379318909 25200
#      Mon Sep 16 01:08:29 2013 -0700
# Node ID 0ed65d30c55d995856a92667c3eddaede742c47c
# Parent  6ba0dbca4fb4ffc0598b7e44df540903d9d914f3
branchmap: introduce branchtip() method

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -155,6 +155,19 @@ class branchcache(dict):
         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,


More information about the Mercurial-devel mailing list