bookmarks: update to use new bookmarks api via compatibility layer
Tested against 3.4 and latest hg + upcoming bookmarks patches
--- a/README Thu May 07 10:54:37 2015 -0700
+++ b/README Thu May 07 13:20:11 2015 -0700
@@ -58,6 +58,7 @@
- fix the `debugrecordpruneparents` utility
- fix some possible crash during command abort (release non-existant transaction)
- fix simple4server bug tracker URL
+- compatibility with bookmark API change in future Mercurial 3.5
5.1.4 -- 2015-04-23
--- a/hgext/evolve.py Thu May 07 10:54:37 2015 -0700
+++ b/hgext/evolve.py Thu May 07 13:20:11 2015 -0700
@@ -806,10 +806,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'])
@@ -864,7 +863,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:
@@ -879,6 +878,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 = [
@@ -1593,7 +1605,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"""
@@ -1606,7 +1618,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:
@@ -1614,7 +1626,7 @@
repo._bookmarks[bm] = p.node()
repo._bookmarks.write()
else:
- bookmarks.unsetcurrent(repo)
+ bmdeactivate(repo)
displayer.show(p)
return 0
else:
@@ -1625,7 +1637,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"""
@@ -1641,7 +1653,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:
@@ -1649,7 +1661,7 @@
repo._bookmarks[bm] = c.node()
repo._bookmarks.write()
else:
- bookmarks.unsetcurrent(repo)
+ bmdeactivate(repo)
displayer.show(c)
return 0
else:
--- a/tests/test-evolve.t Thu May 07 10:54:37 2015 -0700
+++ b/tests/test-evolve.t Thu May 07 13:20:11 2015 -0700
@@ -879,7 +879,7 @@
$ hg bookmark testbookmark
$ ls .hg/bookmarks*
.hg/bookmarks
- .hg/bookmarks.current
+ .hg/bookmarks.* (glob)
$ hg evolve
move:[8] a2
atop:[10] a1__