comparison mercurial/revlog.py @ 22934:8a096d4d0862

revlog: support importing censored file revision tombstones This change allows a revision log to not fail integrity checks when applying a changegroup delta (eg from a bundle) results in a censored file tombstone. The tombstone is inserted as-is, so future integrity verification will observe the tombstone. Deltas based on the tombstone will also remain correct. The new code path is encountered for *exactly* the cases where _addrevision is importing a tombstone from a changegroup. When committing a file containing the "magic" tombstone text, the "text" parameter will be non-empty and the checkhash call is not executed (and when committing, the node will be computed to match the "magic" tombstone text).
author Mike Edgar <adgar@google.com>
date Wed, 03 Sep 2014 16:34:29 -0400
parents abc44fcc9c57
children d23834b871ac
comparison
equal deleted inserted replaced
22933:3a60cd44e619 22934:8a096d4d0862
40 _maxinline = 131072 40 _maxinline = 131072
41 _chunksize = 1048576 41 _chunksize = 1048576
42 42
43 RevlogError = error.RevlogError 43 RevlogError = error.RevlogError
44 LookupError = error.LookupError 44 LookupError = error.LookupError
45 CensoredNodeError = error.CensoredNodeError
45 46
46 def getoffset(q): 47 def getoffset(q):
47 return int(q >> 16) 48 return int(q >> 16)
48 49
49 def gettype(q): 50 def gettype(q):
1174 if dfh: 1175 if dfh:
1175 dfh.flush() 1176 dfh.flush()
1176 ifh.flush() 1177 ifh.flush()
1177 basetext = self.revision(self.node(cachedelta[0])) 1178 basetext = self.revision(self.node(cachedelta[0]))
1178 btext[0] = mdiff.patch(basetext, cachedelta[1]) 1179 btext[0] = mdiff.patch(basetext, cachedelta[1])
1179 self.checkhash(btext[0], p1, p2, node) 1180 try:
1181 self.checkhash(btext[0], p1, p2, node)
1182 except CensoredNodeError:
1183 pass # always import a censor tombstone.
1180 return btext[0] 1184 return btext[0]
1181 1185
1182 def builddelta(rev): 1186 def builddelta(rev):
1183 # can we use the cached delta? 1187 # can we use the cached delta?
1184 if cachedelta and cachedelta[0] == rev: 1188 if cachedelta and cachedelta[0] == rev: