mercurial/bookmarks.py
branchstable
changeset 18471 2096e025a728
parent 18363 c6e033a7dd38
child 18496 d1c13a4dc638
--- a/mercurial/bookmarks.py	Mon Jan 21 12:58:59 2013 -0600
+++ b/mercurial/bookmarks.py	Mon Jan 21 13:47:10 2013 -0600
@@ -134,6 +134,19 @@
     finally:
         wlock.release()
 
+def iscurrent(repo, mark=None, parents=None):
+    '''Tell whether the current bookmark is also active
+
+    I.e., the bookmark listed in .hg/bookmarks.current also points to a
+    parent of the working directory.
+    '''
+    if not mark:
+        mark = repo._bookmarkcurrent
+    if not parents:
+        parents = [p.node() for p in repo[None].parents()]
+    marks = repo._bookmarks
+    return (mark in marks and marks[mark] in parents)
+
 def updatecurrentbookmark(repo, oldnode, curbranch):
     try:
         return update(repo, oldnode, repo.branchtip(curbranch))