diff hggit/git_handler.py @ 1024:078c3912afce

bookmarks: compatibility with new applychanges api Recent versions of mercuiral issue a devel-warn if the old recordchange api is used, but we want to remain backwards-compatible, so this patch refactors things to be forward-compatible and backwards-compatible.
author Ryan McElroy <rmcelroy@fb.com>
date Wed, 19 Jul 2017 05:51:44 -0700
parents 78959c8e5e60
children e7a8a5710257
line wrap: on
line diff
--- a/hggit/git_handler.py	Mon Jul 17 05:49:23 2017 -0700
+++ b/hggit/git_handler.py	Wed Jul 19 05:51:44 2017 -0700
@@ -300,8 +300,8 @@
                     # make sure the bookmark exists; at the point the remote
                     # branches has already been set up
                     suffix = self.branch_bookmark_suffix or ''
-                    self.repo._bookmarks[rhead + suffix] = rnode
-                    util.recordbookmarks(self.repo, self.repo._bookmarks)
+                    changes = [(rhead + suffix, rnode)]
+                    util.updatebookmarks(self.repo, changes)
                     bms = [rhead + suffix]
 
                 if bms:
@@ -1372,6 +1372,7 @@
                           if ref.startswith('refs/heads/')])
 
             suffix = self.branch_bookmark_suffix or ''
+            changes = []
             for head, sha in heads.iteritems():
                 # refs contains all the refs in the server, not just
                 # the ones we are pulling
@@ -1381,15 +1382,15 @@
                 hgsha = bin(hgsha)
                 if head not in bms:
                     # new branch
-                    bms[head + suffix] = hgsha
+                    changes.append((head + suffix, hgsha))
                 else:
                     bm = self.repo[bms[head]]
                     if bm.ancestor(self.repo[hgsha]) == bm:
                         # fast forward
-                        bms[head + suffix] = hgsha
+                        changes.append((head + suffix, hgsha))
 
             if heads:
-                util.recordbookmarks(self.repo, bms)
+                util.updatebookmarks(self.repo, changes)
 
         except AttributeError:
             self.ui.warn(_('creating bookmarks failed, do you have'