Patchwork [05,of,12] branchmap: introduce branchheads() method

login
register
mail settings
Submitter Brodie Rao
Date Nov. 16, 2013, 2:27 a.m.
Message ID <7b9b47384721d01206f4.1384568857@hit-nxdomain.opendns.com>
Download mbox | patch
Permalink /patch/2963/
State Superseded
Headers show

Comments

Brodie Rao - Nov. 16, 2013, 2:27 a.m.
# HG changeset patch
# User Brodie Rao <brodie@sf.io>
# Date 1379318909 25200
#      Mon Sep 16 01:08:29 2013 -0700
# Node ID 7b9b47384721d01206f4bed187374f48b03e742d
# Parent  219c711dbd1540d7b4e88765f9c032738156386d
branchmap: introduce branchheads() method

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -149,6 +149,12 @@  class branchcache(dict):
     def branchtip(self, branch):
         return self._branchtip(self[branch])[0]
 
+    def branchheads(self, branch, closed=False):
+        heads = self[branch]
+        if not closed:
+            heads = [h for h in heads if h not in self._closednodes]
+        return heads
+
     def copy(self):
         """return an deep copy of the branchcache object"""
         return branchcache(self, self.tipnode, self.tiprev, self.filteredhash,