compat: drop compatibility layer for bookmark.applychanges
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 19 Apr 2018 16:21:44 +0200
changeset 3699 67d6cc7e0979
parent 3698 4819656d1134
child 3700 2577fdc3a458
compat: drop compatibility layer for bookmark.applychanges We now only support Mercurial version down to 4.3.
hgext3rd/evolve/__init__.py
hgext3rd/evolve/cmdrewrite.py
hgext3rd/evolve/compat.py
hgext3rd/evolve/evolvecmd.py
hgext3rd/evolve/rewriteutil.py
--- a/hgext3rd/evolve/__init__.py	Thu Apr 19 16:15:10 2018 +0200
+++ b/hgext3rd/evolve/__init__.py	Thu Apr 19 16:21:44 2018 +0200
@@ -981,7 +981,7 @@
                 tr = repo.transaction('previous')
                 if bookmark is not None:
                     bmchanges = [(bookmark, target.node())]
-                    compat.bookmarkapplychanges(repo, tr, bmchanges)
+                    repo._bookmarks.applychanges(repo, tr, bmchanges)
                 else:
                     bookmarksmod.deactivate(repo)
                 tr.close()
@@ -1203,7 +1203,7 @@
                 tr = repo.transaction('next')
                 if shouldmove:
                     bmchanges = [(bm, children.node())]
-                    compat.bookmarkapplychanges(repo, tr, bmchanges)
+                    repo._bookmarks.applychanges(repo, tr, bmchanges)
                 else:
                     bookmarksmod.deactivate(repo)
                 tr.close()
@@ -1244,7 +1244,7 @@
                 if not lock:
                     lock = repo.lock()
                 tr = repo.transaction('commit')
-                compat.bookmarkapplychanges(repo, tr, bmchanges)
+                repo._bookmarks.applychanges(repo, tr, bmchanges)
                 tr.close()
         return result
     finally:
--- a/hgext3rd/evolve/cmdrewrite.py	Thu Apr 19 16:15:10 2018 +0200
+++ b/hgext3rd/evolve/cmdrewrite.py	Thu Apr 19 16:21:44 2018 +0200
@@ -1079,7 +1079,7 @@
                 if movebookmark:
                     bookmarksmod.deactivate(repo)
                     bmchanges = [(bookactive, newnode.node())]
-                    compat.bookmarkapplychanges(repo, tr, bmchanges)
+                    repo._bookmarks.applychanges(repo, tr, bmchanges)
                 commands.update(ui, repo, newnode.rev())
                 ui.status(_('working directory now at %s\n')
                           % ui.label(str(newnode), 'evolve.node'))
--- a/hgext3rd/evolve/compat.py	Thu Apr 19 16:15:10 2018 +0200
+++ b/hgext3rd/evolve/compat.py	Thu Apr 19 16:21:44 2018 +0200
@@ -38,20 +38,6 @@
 
 eh = exthelper.exthelper()
 
-# compatibility layer for mercurial < 4.3
-def bookmarkapplychanges(repo, tr, changes):
-    """Apply a list of changes to bookmarks
-    """
-    bookmarks = repo._bookmarks
-    if util.safehasattr(bookmarks, 'applychanges'):
-        return bookmarks.applychanges(repo, tr, changes)
-    for name, node in changes:
-        if node is None:
-            del bookmarks[name]
-        else:
-            bookmarks[name] = node
-    bookmarks.recordchange(tr)
-
 def isobsnotesupported():
     # hack to know obsnote is supported. The patches for obsnote support was
     # pushed before the obsfateprinter patches, so this will serve as a good
--- a/hgext3rd/evolve/evolvecmd.py	Thu Apr 19 16:15:10 2018 +0200
+++ b/hgext3rd/evolve/evolvecmd.py	Thu Apr 19 16:21:44 2018 +0200
@@ -596,7 +596,7 @@
     for book in destbookmarks: # restore bookmark that rebase move
         bmchanges.append((book, dest.node()))
     if bmchanges:
-        compat.bookmarkapplychanges(repo, tr, bmchanges)
+        repo._bookmarks.applychanges(repo, tr, bmchanges)
 
 def _evolvemerge(repo, orig, dest, pctx, keepbranch):
     """Used by the evolve function to merge dest on top of pctx.
@@ -1323,7 +1323,7 @@
                 # restoring bookmarks at there original place
                 bmchanges = evolvestate['bookmarkchanges']
                 if bmchanges:
-                    compat.bookmarkapplychanges(repo, tr, bmchanges)
+                    repo._bookmarks.applychanges(repo, tr, bmchanges)
                 tr.close()
             finally:
                 tr.release()
--- a/hgext3rd/evolve/rewriteutil.py	Thu Apr 19 16:15:10 2018 +0200
+++ b/hgext3rd/evolve/rewriteutil.py	Thu Apr 19 16:21:44 2018 +0200
@@ -86,7 +86,7 @@
         oldbookmarks = repo.nodebookmarks(oldid)
         bmchanges = [(b, newid) for b in oldbookmarks]
         if bmchanges:
-            compat.bookmarkapplychanges(repo, tr, bmchanges)
+            repo._bookmarks.applychanges(repo, tr, bmchanges)
     return updatebookmarks
 
 def disallowednewunstable(repo, revs):
@@ -125,7 +125,7 @@
         bmchanges = []
         for bookmark in bookmarks:
             bmchanges.append((bookmark, None))
-        compat.bookmarkapplychanges(repo, tr, bmchanges)
+        repo._bookmarks.applychanges(repo, tr, bmchanges)
         tr.close()
         for bookmark in sorted(bookmarks):
             repo.ui.write(_("bookmark '%s' deleted\n") % bookmark)