Show More
@@ -2109,23 +2109,7 b' class revlog(object):' | |||||
2109 | if not self._censorable: |
|
2109 | if not self._censorable: | |
2110 | return False |
|
2110 | return False | |
2111 |
|
2111 | |||
2112 | # Fragile heuristic: unless new file meta keys are added alphabetically |
|
2112 | return storageutil.deltaiscensored(delta, baserev, self.rawsize) | |
2113 | # preceding "censored", all censored revisions are prefixed by |
|
|||
2114 | # "\1\ncensored:". A delta producing such a censored revision must be a |
|
|||
2115 | # full-replacement delta, so we inspect the first and only patch in the |
|
|||
2116 | # delta for this prefix. |
|
|||
2117 | hlen = struct.calcsize(">lll") |
|
|||
2118 | if len(delta) <= hlen: |
|
|||
2119 | return False |
|
|||
2120 |
|
||||
2121 | oldlen = self.rawsize(baserev) |
|
|||
2122 | newlen = len(delta) - hlen |
|
|||
2123 | if delta[:hlen] != mdiff.replacediffheader(oldlen, newlen): |
|
|||
2124 | return False |
|
|||
2125 |
|
||||
2126 | add = "\1\ncensored:" |
|
|||
2127 | addlen = len(add) |
|
|||
2128 | return newlen >= addlen and delta[hlen:hlen + addlen] == add |
|
|||
2129 |
|
2113 | |||
2130 | def getstrippoint(self, minlink): |
|
2114 | def getstrippoint(self, minlink): | |
2131 | """find the minimum rev that must be stripped to strip the linkrev |
|
2115 | """find the minimum rev that must be stripped to strip the linkrev |
@@ -9,6 +9,7 b' from __future__ import absolute_import' | |||||
9 |
|
9 | |||
10 | import hashlib |
|
10 | import hashlib | |
11 | import re |
|
11 | import re | |
|
12 | import struct | |||
12 |
|
13 | |||
13 | from ..i18n import _ |
|
14 | from ..i18n import _ | |
14 | from ..node import ( |
|
15 | from ..node import ( | |
@@ -449,3 +450,31 b' def emitrevisions(store, nodes, nodesord' | |||||
449 | delta=delta) |
|
450 | delta=delta) | |
450 |
|
451 | |||
451 | prevrev = rev |
|
452 | prevrev = rev | |
|
453 | ||||
|
454 | def deltaiscensored(delta, baserev, baselenfn): | |||
|
455 | """Determine if a delta represents censored revision data. | |||
|
456 | ||||
|
457 | ``baserev`` is the base revision this delta is encoded against. | |||
|
458 | ``baselenfn`` is a callable receiving a revision number that resolves the | |||
|
459 | length of the revision fulltext. | |||
|
460 | ||||
|
461 | Returns a bool indicating if the result of the delta represents a censored | |||
|
462 | revision. | |||
|
463 | """ | |||
|
464 | # Fragile heuristic: unless new file meta keys are added alphabetically | |||
|
465 | # preceding "censored", all censored revisions are prefixed by | |||
|
466 | # "\1\ncensored:". A delta producing such a censored revision must be a | |||
|
467 | # full-replacement delta, so we inspect the first and only patch in the | |||
|
468 | # delta for this prefix. | |||
|
469 | hlen = struct.calcsize(">lll") | |||
|
470 | if len(delta) <= hlen: | |||
|
471 | return False | |||
|
472 | ||||
|
473 | oldlen = baselenfn(baserev) | |||
|
474 | newlen = len(delta) - hlen | |||
|
475 | if delta[:hlen] != mdiff.replacediffheader(oldlen, newlen): | |||
|
476 | return False | |||
|
477 | ||||
|
478 | add = "\1\ncensored:" | |||
|
479 | addlen = len(add) | |||
|
480 | return newlen >= addlen and delta[hlen:hlen + addlen] == add |
General Comments 0
You need to be logged in to leave comments.
Login now