diff mercurial/revlog.py @ 40325:b0fbd1792e2d

storageutil: extract most of peek_censored from revlog This function is super hacky and isn't correct 100% of the time. I'm going to need this functionality on a future non-revlog store. Let's copy things to storageutil so this code only exists once. Differential Revision: https://phab.mercurial-scm.org/D5118
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 16 Oct 2018 15:36:19 +0200
parents 9cadb0f5f227
children 59a870a4ad6e 256b1f0c24e8
line wrap: on
line diff
--- a/mercurial/revlog.py	Thu Sep 20 17:27:01 2018 -0700
+++ b/mercurial/revlog.py	Tue Oct 16 15:36:19 2018 +0200
@@ -2109,23 +2109,7 @@
         if not self._censorable:
             return False
 
-        # Fragile heuristic: unless new file meta keys are added alphabetically
-        # preceding "censored", all censored revisions are prefixed by
-        # "\1\ncensored:". A delta producing such a censored revision must be a
-        # full-replacement delta, so we inspect the first and only patch in the
-        # delta for this prefix.
-        hlen = struct.calcsize(">lll")
-        if len(delta) <= hlen:
-            return False
-
-        oldlen = self.rawsize(baserev)
-        newlen = len(delta) - hlen
-        if delta[:hlen] != mdiff.replacediffheader(oldlen, newlen):
-            return False
-
-        add = "\1\ncensored:"
-        addlen = len(add)
-        return newlen >= addlen and delta[hlen:hlen + addlen] == add
+        return storageutil.deltaiscensored(delta, baserev, self.rawsize)
 
     def getstrippoint(self, minlink):
         """find the minimum rev that must be stripped to strip the linkrev