context: add method to return all bookmarks pointing to a node
authorDavid Soria Parra <dsp@php.net>
Fri, 11 Feb 2011 19:36:15 +0100
changeset 13384 caa561759538
parent 13383 70ef5b610222
child 13385 d012d95499f7
context: add method to return all bookmarks pointing to a node
mercurial/context.py
mercurial/localrepo.py
--- 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