equal
deleted
inserted
replaced
32 REVLOG_DEFAULT_FORMAT = REVLOGNG |
32 REVLOG_DEFAULT_FORMAT = REVLOGNG |
33 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS |
33 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS |
34 REVLOGNG_FLAGS = REVLOGNGINLINEDATA | REVLOGSHALLOW |
34 REVLOGNG_FLAGS = REVLOGNGINLINEDATA | REVLOGSHALLOW |
35 |
35 |
36 # revlog index flags |
36 # revlog index flags |
37 REVIDX_PARENTDELTA = 1 |
|
38 REVIDX_PUNCHED_FLAG = 2 |
37 REVIDX_PUNCHED_FLAG = 2 |
39 REVIDX_KNOWN_FLAGS = REVIDX_PUNCHED_FLAG | REVIDX_PARENTDELTA |
38 REVIDX_KNOWN_FLAGS = REVIDX_PUNCHED_FLAG |
40 |
39 |
41 # max size of revlog with inline data |
40 # max size of revlog with inline data |
42 _maxinline = 131072 |
41 _maxinline = 131072 |
43 _chunksize = 1048576 |
42 _chunksize = 1048576 |
44 |
43 |
221 self.opener = opener |
220 self.opener = opener |
222 self._cache = None |
221 self._cache = None |
223 self._chunkcache = (0, '') |
222 self._chunkcache = (0, '') |
224 self.index = [] |
223 self.index = [] |
225 self._shallowroot = shallowroot |
224 self._shallowroot = shallowroot |
226 self._parentdelta = 0 |
|
227 self._pcache = {} |
225 self._pcache = {} |
228 self._nodecache = {nullid: nullrev} |
226 self._nodecache = {nullid: nullrev} |
229 self._nodepos = None |
227 self._nodepos = None |
230 |
228 |
231 v = REVLOG_DEFAULT_VERSION |
229 v = REVLOG_DEFAULT_VERSION |
232 if hasattr(opener, 'options') and 'defversion' in opener.options: |
230 if hasattr(opener, 'options') and 'defversion' in opener.options: |
233 v = opener.options['defversion'] |
231 v = opener.options['defversion'] |
234 if v & REVLOGNG: |
232 if v & REVLOGNG: |
235 v |= REVLOGNGINLINEDATA |
233 v |= REVLOGNGINLINEDATA |
236 if v & REVLOGNG and 'parentdelta' in opener.options: |
|
237 self._parentdelta = 1 |
|
238 |
234 |
239 if shallowroot: |
235 if shallowroot: |
240 v |= REVLOGSHALLOW |
236 v |= REVLOGSHALLOW |
241 |
237 |
242 i = '' |
238 i = '' |
832 |
828 |
833 def _chunkclear(self): |
829 def _chunkclear(self): |
834 self._chunkcache = (0, '') |
830 self._chunkcache = (0, '') |
835 |
831 |
836 def deltaparent(self, rev): |
832 def deltaparent(self, rev): |
837 """return previous revision or parentrev according to flags""" |
833 """return deltaparent of the given revision""" |
838 if self.flags(rev) & REVIDX_PARENTDELTA: |
834 return rev - 1 |
839 return self.parentrevs(rev)[0] |
|
840 else: |
|
841 return rev - 1 |
|
842 |
835 |
843 def revdiff(self, rev1, rev2): |
836 def revdiff(self, rev1, rev2): |
844 """return or calculate a delta between two revisions""" |
837 """return or calculate a delta between two revisions""" |
845 if self.base(rev2) != rev2 and self.deltaparent(rev2) == rev1: |
838 if self.base(rev2) != rev2 and self.deltaparent(rev2) == rev1: |
846 return self._chunk(rev2) |
839 return self._chunk(rev2) |
868 raise RevlogError(_('incompatible revision flag %x') % |
861 raise RevlogError(_('incompatible revision flag %x') % |
869 (self.flags(rev) & ~REVIDX_KNOWN_FLAGS)) |
862 (self.flags(rev) & ~REVIDX_KNOWN_FLAGS)) |
870 |
863 |
871 # build delta chain |
864 # build delta chain |
872 chain = [] |
865 chain = [] |
873 index = self.index # for performance |
|
874 iterrev = rev |
866 iterrev = rev |
875 e = index[iterrev] |
|
876 while iterrev != base and iterrev != cachedrev: |
867 while iterrev != base and iterrev != cachedrev: |
877 chain.append(iterrev) |
868 chain.append(iterrev) |
878 if e[0] & REVIDX_PARENTDELTA: |
869 iterrev -= 1 |
879 iterrev = e[5] |
|
880 else: |
|
881 iterrev -= 1 |
|
882 e = index[iterrev] |
|
883 chain.reverse() |
870 chain.reverse() |
884 base = iterrev |
871 base = iterrev |
885 |
872 |
886 if iterrev == cachedrev: |
873 if iterrev == cachedrev: |
887 # cache hit |
874 # cache hit |
1016 p1r, p2r = self.rev(p1), self.rev(p2) |
1003 p1r, p2r = self.rev(p1), self.rev(p2) |
1017 |
1004 |
1018 # should we try to build a delta? |
1005 # should we try to build a delta? |
1019 if prev != nullrev: |
1006 if prev != nullrev: |
1020 d = builddelta(prev) |
1007 d = builddelta(prev) |
1021 if self._parentdelta and prev != p1r: |
|
1022 d2 = builddelta(p1r) |
|
1023 if d2 < d: |
|
1024 d = d2 |
|
1025 flags = REVIDX_PARENTDELTA |
|
1026 dist, l, data, base = d |
1008 dist, l, data, base = d |
1027 |
1009 |
1028 # full versions are inserted when the needed deltas |
1010 # full versions are inserted when the needed deltas |
1029 # become comparable to the uncompressed text |
1011 # become comparable to the uncompressed text |
1030 # or the base revision is punched |
1012 # or the base revision is punched |