[PATCH 03 of 14] obsstore: keep self._data updated with _addmarkers

Boris Feld boris.feld at octobus.net
Sun Jul 9 13:55:15 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1496552183 25200
#      Sat Jun 03 21:56:23 2017 -0700
# Node ID ff2ebc11f12a26a4e0bda3ccf5fde63f5f690813
# Parent  8b71290526ddb77f157e075191dd748793d85601
# EXP-Topic obs-cache
obsstore: keep self._data updated with _addmarkers

This makes sure obsstore._data is still correct with added markers.

The '_data' propertycache was added in 17ce57b7873f.

diff -r 8b71290526dd -r ff2ebc11f12a mercurial/obsolete.py
--- a/mercurial/obsolete.py	Fri Jul 07 22:15:52 2017 +0200
+++ b/mercurial/obsolete.py	Sat Jun 03 21:56:23 2017 -0700
@@ -607,8 +607,8 @@
                 offset = f.tell()
                 transaction.add('obsstore', offset)
                 # offset == 0: new file - add the version header
-                for bytes in encodemarkers(new, offset == 0, self._version):
-                    f.write(bytes)
+                data = b''.join(encodemarkers(new, offset == 0, self._version))
+                f.write(data)
             finally:
                 # XXX: f.close() == filecache invalidation == obsstore rebuilt.
                 # call 'filecacheentry.refresh()'  here
@@ -616,7 +616,7 @@
             addedmarkers = transaction.changes.get('obsmarkers')
             if addedmarkers is not None:
                 addedmarkers.update(new)
-            self._addmarkers(new)
+            self._addmarkers(new, data)
             # new marker *may* have changed several set. invalidate the cache.
             self.caches.clear()
         # records the number of new markers for the transaction hooks
@@ -673,8 +673,9 @@
     def _cached(self, attr):
         return attr in self.__dict__
 
-    def _addmarkers(self, markers):
+    def _addmarkers(self, markers, rawdata):
         markers = list(markers) # to allow repeated iteration
+        self._data = self._data + rawdata
         self._all.extend(markers)
         if self._cached('successors'):
             _addsuccessors(self.successors, markers)


More information about the Mercurial-devel mailing list