comparison mercurial/revlog.py @ 24123:eb2d41c6ec37

revlog: _addrevision creates full-replace deltas based on censored revisions A delta against a censored revision is either received through exchange and written blindly to a revlog, or it is created by the revlog itself. This change ensures the latter process creates deltas which fully replace all data in a censored base using a single patch operation. Recipients of a delta against a censored base will verify that the delta is in this full-replace format. Other recipients will use the delta as normal. For background and broader design of the censorship feature, see: http://mercurial.selenic.com/wiki/CensorPlan
author Mike Edgar <adgar@google.com>
date Wed, 21 Jan 2015 17:11:37 -0500
parents da14b8eba806
children 4bfe9f2d9761
comparison
equal deleted inserted replaced
24122:da14b8eba806 24123:eb2d41c6ec37
1259 # can we use the cached delta? 1259 # can we use the cached delta?
1260 if cachedelta and cachedelta[0] == rev: 1260 if cachedelta and cachedelta[0] == rev:
1261 delta = cachedelta[1] 1261 delta = cachedelta[1]
1262 else: 1262 else:
1263 t = buildtext() 1263 t = buildtext()
1264 ptext = self.revision(self.node(rev)) 1264 if self.iscensored(rev):
1265 delta = mdiff.textdiff(ptext, t) 1265 # deltas based on a censored revision must replace the
1266 # full content in one patch, so delta works everywhere
1267 header = mdiff.replacediffheader(self.rawsize(rev), len(t))
1268 delta = header + t
1269 else:
1270 ptext = self.revision(self.node(rev))
1271 delta = mdiff.textdiff(ptext, t)
1266 data = self.compress(delta) 1272 data = self.compress(delta)
1267 l = len(data[1]) + len(data[0]) 1273 l = len(data[1]) + len(data[0])
1268 if basecache[0] == rev: 1274 if basecache[0] == rev:
1269 chainbase = basecache[1] 1275 chainbase = basecache[1]
1270 else: 1276 else: