Patchwork D10664: revlog: pass around the `rev` we deal with when packing/unpacking entry

login
register
mail settings
Submitter phabricator
Date May 4, 2021, 2:20 p.m.
Message ID <differential-rev-PHID-DREV-lp5cxdygw4l3n2ej7jhj-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48980/
State Superseded
Headers show

Comments

phabricator - May 4, 2021, 2:20 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This will help code to compute some flag on the fly.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10664

AFFECTED FILES
  mercurial/pure/parsers.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -118,10 +118,10 @@ 
     def append(self, tup):
         if '_nodemap' in vars(self):
             self._nodemap[tup[7]] = len(self)
-        data = self._pack_entry(tup)
+        data = self._pack_entry(len(self), tup)
         self._extra.append(data)
 
-    def _pack_entry(self, entry):
+    def _pack_entry(self, rev, entry):
         assert entry[8] == 0
         assert entry[9] == 0
         return self.index_format.pack(*entry[:8])
@@ -141,12 +141,12 @@ 
         else:
             index = self._calculate_index(i)
             data = self._data[index : index + self.entry_size]
-        r = self._unpack_entry(data)
+        r = self._unpack_entry(i, data)
         if self._lgt and i == 0:
             r = (offset_type(0, gettype(r[0])),) + r[1:]
         return r
 
-    def _unpack_entry(self, data):
+    def _unpack_entry(self, rev, data):
         r = self.index_format.unpack(data)
         r = r + (
             0,
@@ -323,17 +323,17 @@ 
             entry[9] = sidedata_length
             entry[11] = compression_mode
             entry = tuple(entry)
-            new = self._pack_entry(entry)
+            new = self._pack_entry(rev, entry)
             self._extra[rev - self._lgt] = new
 
-    def _unpack_entry(self, data):
+    def _unpack_entry(self, rev, data):
         data = self.index_format.unpack(data)
         entry = data[:10]
         data_comp = data[10] & 3
         sidedata_comp = (data[10] & (3 << 2)) >> 2
         return entry + (data_comp, sidedata_comp)
 
-    def _pack_entry(self, entry):
+    def _pack_entry(self, rev, entry):
         data = entry[:10]
         data_comp = entry[10] & 3
         sidedata_comp = (entry[11] & 3) << 2
@@ -344,7 +344,7 @@ 
     def entry_binary(self, rev):
         """return the raw binary string representing a revision"""
         entry = self[rev]
-        return self._pack_entry(entry)
+        return self._pack_entry(rev, entry)
 
     def pack_header(self, header):
         """pack header information as binary"""