changeset 33480:ef54789a947d

bookmark: introduce a 'applychanges' function to gather bookmark movement We want to track bookmark movement within a transaction. For this we need a more centralized way to update bookmarks. For this purpose we introduce a new 'applychanges' method that apply a list of changes encoded as '(name, node)'. We'll cover all bookmark updating code to this new method in later changesets and add bookmark move in the transaction when all will be migrated.
author Boris Feld <boris.feld@octobus.net>
date Mon, 10 Jul 2017 17:01:34 +0200
parents 8b48dad66be4
children 67b5f81f17cf
files mercurial/bookmarks.py
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Sat Jun 03 21:56:23 2017 -0700
+++ b/mercurial/bookmarks.py	Mon Jul 10 17:01:34 2017 +0200
@@ -109,6 +109,16 @@
         self._clean = False
         return dict.__delitem__(self, key)
 
+    def applychanges(self, repo, tr, changes):
+        """Apply a list of changes to bookmarks
+        """
+        for name, node in changes:
+            if node is None:
+                del self[name]
+            else:
+                self[name] = node
+        self.recordchange(tr)
+
     def recordchange(self, tr):
         """record that bookmarks have been changed in a transaction