hgext/sqlitestore.py
changeset 42772 5c2e8a661418
parent 42760 9f2189b6bf2a
child 42813 268662aac075
equal deleted inserted replaced
42771:fdeb4c1d23d5 42772:5c2e8a661418
   655 
   655 
   656             # If base is censored, delta must be full replacement in a single
   656             # If base is censored, delta must be full replacement in a single
   657             # patch operation.
   657             # patch operation.
   658             if baserev != nullrev and self.iscensored(baserev):
   658             if baserev != nullrev and self.iscensored(baserev):
   659                 hlen = struct.calcsize('>lll')
   659                 hlen = struct.calcsize('>lll')
   660                 oldlen = len(self.revision(deltabase, raw=True,
   660                 oldlen = len(self.rawdata(deltabase, _verifyhash=False))
   661                                            _verifyhash=False))
       
   662                 newlen = len(delta) - hlen
   661                 newlen = len(delta) - hlen
   663 
   662 
   664                 if delta[:hlen] != mdiff.replacediffheader(oldlen, newlen):
   663                 if delta[:hlen] != mdiff.replacediffheader(oldlen, newlen):
   665                     raise error.CensoredBaseError(self._path,
   664                     raise error.CensoredBaseError(self._path,
   666                                                   deltabase)
   665                                                   deltabase)
   667 
   666 
   668             if (not (storeflags & FLAG_CENSORED)
   667             if (not (storeflags & FLAG_CENSORED)
   669                 and storageutil.deltaiscensored(
   668                 and storageutil.deltaiscensored(
   670                     delta, baserev, lambda x: len(self.revision(x, raw=True)))):
   669                     delta, baserev, lambda x: len(self.rawdata(x)))):
   671                 storeflags |= FLAG_CENSORED
   670                 storeflags |= FLAG_CENSORED
   672 
   671 
   673             linkrev = linkmapper(linknode)
   672             linkrev = linkmapper(linknode)
   674 
   673 
   675             nodes.append(node)
   674             nodes.append(node)
   718     def censorrevision(self, tr, censornode, tombstone=b''):
   717     def censorrevision(self, tr, censornode, tombstone=b''):
   719         tombstone = storageutil.packmeta({b'censored': tombstone}, b'')
   718         tombstone = storageutil.packmeta({b'censored': tombstone}, b'')
   720 
   719 
   721         # This restriction is cargo culted from revlogs and makes no sense for
   720         # This restriction is cargo culted from revlogs and makes no sense for
   722         # SQLite, since columns can be resized at will.
   721         # SQLite, since columns can be resized at will.
   723         if len(tombstone) > len(self.revision(censornode, raw=True)):
   722         if len(tombstone) > len(self.rawdata(censornode)):
   724             raise error.Abort(_('censor tombstone must be no longer than '
   723             raise error.Abort(_('censor tombstone must be no longer than '
   725                                 'censored data'))
   724                                 'censored data'))
   726 
   725 
   727         # We need to replace the censored revision's data with the tombstone.
   726         # We need to replace the censored revision's data with the tombstone.
   728         # But replacing that data will have implications for delta chains that
   727         # But replacing that data will have implications for delta chains that