comparison mercurial/revlog.py @ 49077:5b65721a75eb

revlog: recommit 49fd21f32695 with a fix for issue6528 `filelog.size` currently special cases two forms of metadata encoding: - copy data via the parent order as flag bit - censor data by peaking into the raw delta All other forms of metadata encoding including the empty metadata block are mishandled. In `basefilectx.cmp` the empty metadata block is explicitly checked to compensate for this. Restore 49fd21f32695, but disable it for filelog, so that the original flag bit use contines to work. Document all this mess for now in preparation of a proper rework. Differential Revision: https://phab.mercurial-scm.org/D11203
author Joerg Sonnenberger <joerg@bec.de>
date Tue, 20 Jul 2021 15:07:10 +0200
parents 642e31cb55f0
children 2bcf5e14bb7e
comparison
equal deleted inserted replaced
49076:b999edb15f8c 49077:5b65721a75eb
296 censorable=False, 296 censorable=False,
297 upperboundcomp=None, 297 upperboundcomp=None,
298 persistentnodemap=False, 298 persistentnodemap=False,
299 concurrencychecker=None, 299 concurrencychecker=None,
300 trypending=False, 300 trypending=False,
301 canonical_parent_order=True,
301 ): 302 ):
302 """ 303 """
303 create a revlog object 304 create a revlog object
304 305
305 opener is a function that abstracts the file opening operation 306 opener is a function that abstracts the file opening operation
370 self._adding_group = None 371 self._adding_group = None
371 372
372 self._loadindex() 373 self._loadindex()
373 374
374 self._concurrencychecker = concurrencychecker 375 self._concurrencychecker = concurrencychecker
376
377 # parent order is supposed to be semantically irrelevant, so we
378 # normally resort parents to ensure that the first parent is non-null,
379 # if there is a non-null parent at all.
380 # filelog abuses the parent order as flag to mark some instances of
381 # meta-encoded files, so allow it to disable this behavior.
382 self.canonical_parent_order = canonical_parent_order
375 383
376 def _init_opts(self): 384 def _init_opts(self):
377 """process options (from above/config) to setup associated default revlog mode 385 """process options (from above/config) to setup associated default revlog mode
378 386
379 These values might be affected when actually reading on disk information. 387 These values might be affected when actually reading on disk information.
896 except IndexError: 904 except IndexError:
897 if rev == wdirrev: 905 if rev == wdirrev:
898 raise error.WdirUnsupported 906 raise error.WdirUnsupported
899 raise 907 raise
900 908
901 return entry[5], entry[6] 909 if self.canonical_parent_order and entry[5] == nullrev:
910 return entry[6], entry[5]
911 else:
912 return entry[5], entry[6]
902 913
903 # fast parentrevs(rev) where rev isn't filtered 914 # fast parentrevs(rev) where rev isn't filtered
904 _uncheckedparentrevs = parentrevs 915 _uncheckedparentrevs = parentrevs
905 916
906 def node(self, rev): 917 def node(self, rev):
917 return self.start(rev) + self.length(rev) 928 return self.start(rev) + self.length(rev)
918 929
919 def parents(self, node): 930 def parents(self, node):
920 i = self.index 931 i = self.index
921 d = i[self.rev(node)] 932 d = i[self.rev(node)]
922 return i[d[5]][7], i[d[6]][7] # map revisions to nodes inline 933 # inline node() to avoid function call overhead
934 if self.canonical_parent_order and d[5] == self.nullid:
935 return i[d[6]][7], i[d[5]][7]
936 else:
937 return i[d[5]][7], i[d[6]][7]
923 938
924 def chainlen(self, rev): 939 def chainlen(self, rev):
925 return self._chaininfo(rev)[0] 940 return self._chaininfo(rev)[0]
926 941
927 def _chaininfo(self, rev): 942 def _chaininfo(self, rev):