Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 11745:138c055ec57d
revlog: add punched revision flag
index flag to identify a revision as punched, i.e. it contains no data.
REVIDX_PUNCHED_FLAG = 2, is used to mark a revision as punched.
REVIDX_KNOWN_FLAGS is the accumulation of all index flags.
author | Vishakh H <vsh426@gmail.com> |
---|---|
date | Tue, 03 Aug 2010 19:38:19 +0530 |
parents | ff33f937a7da |
children | 46ac30b17978 |
comparison
equal
deleted
inserted
replaced
11744:5b53aa2d4b99 | 11745:138c055ec57d |
---|---|
28 REVLOGNG = 1 | 28 REVLOGNG = 1 |
29 REVLOGNGINLINEDATA = (1 << 16) | 29 REVLOGNGINLINEDATA = (1 << 16) |
30 REVLOG_DEFAULT_FLAGS = REVLOGNGINLINEDATA | 30 REVLOG_DEFAULT_FLAGS = REVLOGNGINLINEDATA |
31 REVLOG_DEFAULT_FORMAT = REVLOGNG | 31 REVLOG_DEFAULT_FORMAT = REVLOGNG |
32 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS | 32 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS |
33 REVIDX_PUNCHED_FLAG = 2 | |
34 REVIDX_KNOWN_FLAGS = REVIDX_PUNCHED_FLAG | |
33 | 35 |
34 # amount of data read unconditionally, should be >= 4 | 36 # amount of data read unconditionally, should be >= 4 |
35 # when not inline: threshold for using lazy index | 37 # when not inline: threshold for using lazy index |
36 _prereadsize = 1048576 | 38 _prereadsize = 1048576 |
37 # max size of revlog with inline data | 39 # max size of revlog with inline data |
1020 text = None | 1022 text = None |
1021 rev = self.rev(node) | 1023 rev = self.rev(node) |
1022 base = self.base(rev) | 1024 base = self.base(rev) |
1023 | 1025 |
1024 # check rev flags | 1026 # check rev flags |
1025 if self.flags(rev): | 1027 if self.flags(rev) & ~REVIDX_KNOWN_FLAGS: |
1026 raise RevlogError(_('incompatible revision flag %x') % | 1028 raise RevlogError(_('incompatible revision flag %x') % |
1027 (self.flags(rev))) | 1029 (self.flags(rev) & ~REVIDX_KNOWN_FLAGS)) |
1028 | 1030 |
1029 # do we have useful data cached? | 1031 # do we have useful data cached? |
1030 if self._cache and self._cache[1] >= base and self._cache[1] < rev: | 1032 if self._cache and self._cache[1] >= base and self._cache[1] < rev: |
1031 base = self._cache[1] | 1033 base = self._cache[1] |
1032 text = self._cache[2] | 1034 text = self._cache[2] |
1037 text = self._chunk(base) | 1039 text = self._chunk(base) |
1038 | 1040 |
1039 bins = [self._chunk(r) for r in xrange(base + 1, rev + 1)] | 1041 bins = [self._chunk(r) for r in xrange(base + 1, rev + 1)] |
1040 text = mdiff.patches(text, bins) | 1042 text = mdiff.patches(text, bins) |
1041 p1, p2 = self.parents(node) | 1043 p1, p2 = self.parents(node) |
1042 if node != hash(text, p1, p2): | 1044 if (node != hash(text, p1, p2) and |
1045 not (self.flags(rev) & REVIDX_PUNCHED_FLAG)): | |
1043 raise RevlogError(_("integrity check failed on %s:%d") | 1046 raise RevlogError(_("integrity check failed on %s:%d") |
1044 % (self.indexfile, rev)) | 1047 % (self.indexfile, rev)) |
1045 | 1048 |
1046 self._cache = (node, rev, text) | 1049 self._cache = (node, rev, text) |
1047 return text | 1050 return text |
1123 l = len(data[1]) + len(data[0]) | 1126 l = len(data[1]) + len(data[0]) |
1124 dist = l + offset - self.start(base) | 1127 dist = l + offset - self.start(base) |
1125 | 1128 |
1126 # full versions are inserted when the needed deltas | 1129 # full versions are inserted when the needed deltas |
1127 # become comparable to the uncompressed text | 1130 # become comparable to the uncompressed text |
1128 if not curr or dist > len(text) * 2: | 1131 # or the base revision is punched |
1132 if (not curr or dist > len(text) * 2 or | |
1133 (self.flags(base) & REVIDX_PUNCHED_FLAG)): | |
1129 data = compress(text) | 1134 data = compress(text) |
1130 l = len(data[1]) + len(data[0]) | 1135 l = len(data[1]) + len(data[0]) |
1131 base = curr | 1136 base = curr |
1132 | 1137 |
1133 e = (offset_type(offset, 0), l, len(text), | 1138 e = (offset_type(offset, 0), l, len(text), |