hgext/evolve.py
changeset 1331 5e82d78f5872
parent 1327 7821a00fb6de
parent 1330 efb75f4d55aa
child 1336 10d2ef1f7ed4
--- a/hgext/evolve.py	Tue May 05 14:09:09 2015 -0700
+++ b/hgext/evolve.py	Mon May 11 14:31:17 2015 -0700
@@ -856,10 +856,9 @@
         try:
             if repo['.'].rev() != dest.rev():
                 merge.update(repo, dest, False, True, False)
-            if repo._bookmarkcurrent:
-                repo.ui.status(_("(leaving bookmark %s)\n") %
-                               repo._bookmarkcurrent)
-            bookmarks.unsetcurrent(repo)
+            if bmactive(repo):
+                repo.ui.status(_("(leaving bookmark %s)\n") % bmactive(repo))
+            bmdeactivate(repo)
             if keepbranch:
                 repo.dirstate.setbranch(orig.branch())
             r = merge.graft(repo, orig, orig.p1(), ['local', 'graft'])
@@ -914,7 +913,7 @@
     """Return a callable update(newid) updating the current bookmark
     and bookmarks bound to oldid to newid.
     """
-    bm = bookmarks.readcurrent(repo)
+    bm = bmactive(repo)
     def updatebookmarks(newid):
         dirty = False
         if bm:
@@ -929,6 +928,19 @@
             repo._bookmarks.write()
     return updatebookmarks
 
+### bookmarks api compatibility layer ###
+def bmdeactivate(repo):
+    try:
+        return bookmarks.deactivate(repo)
+    except AttributeError:
+        return bookmarks.unsetcurrent(repo)
+
+def bmactive(repo):
+    try:
+        return repo._activebookmark
+    except AttributeError:
+        return repo._bookmarkcurrent
+
 ### new command
 #############################
 metadataopts = [
@@ -1666,7 +1678,7 @@
 
 @command('^previous',
          [('B', 'move-bookmark', False,
-             _('Move current active bookmark after update'))],
+             _('Move active bookmark after update'))],
          '[-B]')
 def cmdprevious(ui, repo, **opts):
     """update to parent and display summary lines"""
@@ -1679,7 +1691,7 @@
     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
     if len(parents) == 1:
         p = parents[0]
-        bm = bookmarks.readcurrent(repo)
+        bm = bmactive(repo)
         shouldmove = opts.get('move_bookmark') and bm is not None
         ret = hg.update(repo, p.rev())
         if not ret:
@@ -1687,7 +1699,7 @@
                 repo._bookmarks[bm] = p.node()
                 repo._bookmarks.write()
             else:
-                bookmarks.unsetcurrent(repo)
+                bmdeactivate(repo)
         displayer.show(p)
         return 0
     else:
@@ -1698,7 +1710,7 @@
 
 @command('^next',
          [('B', 'move-bookmark', False,
-             _('Move current active bookmark after update'))],
+             _('Move active bookmark after update'))],
          '[-B]')
 def cmdnext(ui, repo, **opts):
     """update to child and display summary lines"""
@@ -1714,7 +1726,7 @@
         return 1
     if len(children) == 1:
         c = children[0]
-        bm = bookmarks.readcurrent(repo)
+        bm = bmactive(repo)
         shouldmove = opts.get('move_bookmark') and bm is not None
         ret = hg.update(repo, c.rev())
         if not ret:
@@ -1722,7 +1734,7 @@
                 repo._bookmarks[bm] = c.node()
                 repo._bookmarks.write()
             else:
-                bookmarks.unsetcurrent(repo)
+                bmdeactivate(repo)
         displayer.show(c)
         return 0
     else: