changeset 13384:caa561759538

context: add method to return all bookmarks pointing to a node
author David Soria Parra <dsp@php.net>
date Fri, 11 Feb 2011 19:36:15 +0100
parents 70ef5b610222
children d012d95499f7
files mercurial/context.py mercurial/localrepo.py
diffstat 2 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Sun Feb 13 11:14:46 2011 +0100
+++ b/mercurial/context.py	Fri Feb 11 19:36:15 2011 +0100
@@ -114,6 +114,8 @@
         return self._changeset[5]
     def tags(self):
         return self._repo.nodetags(self._node)
+    def bookmarks(self):
+        return self._repo.nodebookmarks(self._node)
 
     def parents(self):
         """return contexts for each parent changeset"""
--- a/mercurial/localrepo.py	Sun Feb 13 11:14:46 2011 +0100
+++ b/mercurial/localrepo.py	Fri Feb 11 19:36:15 2011 +0100
@@ -399,6 +399,13 @@
                 tags.sort()
         return self.nodetagscache.get(node, [])
 
+    def nodebookmarks(self, node):
+        marks = []
+        for bookmark, n in self._bookmarks.iteritems():
+            if n == node:
+                marks.append(bookmark)
+        return sorted(marks)
+
     def _branchtags(self, partial, lrev):
         # TODO: rename this function?
         tiprev = len(self) - 1