Patchwork [16,of,22] obsstore: use new _readmarkers when building index

login
register
mail settings
Submitter Jun Wu
Date June 4, 2017, 11:59 p.m.
Message ID <646ef5fdcf3750f40cb3.1496620768@x1c>
Download mbox | patch
Permalink /patch/21199/
State Accepted
Headers show

Comments

Jun Wu - June 4, 2017, 11:59 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1496603749 25200
#      Sun Jun 04 12:15:49 2017 -0700
# Node ID 646ef5fdcf3750f40cb3cf1c710c0222aef24beb
# Parent  0843176578415e36470485ac48056952e460efc1
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 646ef5fdcf37
obsstore: use new _readmarkers when building index

Instead of reading obssotre._all (parsed markers), read obssotre._data (raw
data) instead. This will allow us to eventually skip parsing markers.

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -540,12 +540,14 @@  class markerindex(dict):
     def update(self):
         """read latest obsstore and build index for its markers"""
-        allmarkers = self._obsstore._all
+        data = self._obsstore._data
+        if len(data) == self.sourceoftruthsize:
+            return
         keyfunc = self._keyfunc
         setdefault = self.setdefault
-        for i in xrange(self.sourceoftruthsize, len(allmarkers)):
-            marker = allmarkers[i]
+        markers, offsets = self._obsstore._readmarkers(self.sourceoftruthsize)
+        for marker in markers:
             for k in keyfunc(marker):
                 setdefault(k, set()).add(marker)
-        self.sourceoftruthsize = len(allmarkers)
+        self.sourceoftruthsize = len(data)
 
 class markerreader(object):