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

login
register
mail settings
Submitter Brodie Rao
Date Nov. 16, 2013, 4:18 a.m.
Message ID <0ed65d30c55d995856a9.1384575528@hit-nxdomain.opendns.com>
Download mbox | patch
Permalink /patch/2980/
State Accepted
Commit f5b461a4bc55fe88df0a04cc2f58fb336f8d03aa
Headers show

Comments

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

Patch

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,