[PATCH 3 of 8 v2] context: return bookmarks for a node

David Soria Parra dsp at php.net
Tue Feb 1 16:21:55 CST 2011


# HG changeset patch
# User David Soria Parra <dsp at php.net>
# Date 1296598850 -3600
# Node ID 4f145cc3cb6efd22933dd5d310836997914305f2
# Parent  f677b63b15c6e5992a1b488db652439ffb26e01c
context: return bookmarks for a node

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -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"""
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -392,6 +392,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


More information about the Mercurial-devel mailing list