mercurial/revlogutils/deltas.py
changeset 43077 687b865b95ad
parent 43076 2372284d9457
child 43089 c59eb1560c44
equal deleted inserted replaced
43076:2372284d9457 43077:687b865b95ad
   512 def _textfromdelta(fh, revlog, baserev, delta, p1, p2, flags, expectednode):
   512 def _textfromdelta(fh, revlog, baserev, delta, p1, p2, flags, expectednode):
   513     """build full text from a (base, delta) pair and other metadata"""
   513     """build full text from a (base, delta) pair and other metadata"""
   514     # special case deltas which replace entire base; no need to decode
   514     # special case deltas which replace entire base; no need to decode
   515     # base revision. this neatly avoids censored bases, which throw when
   515     # base revision. this neatly avoids censored bases, which throw when
   516     # they're decoded.
   516     # they're decoded.
   517     hlen = struct.calcsize(">lll")
   517     hlen = struct.calcsize(b">lll")
   518     if delta[:hlen] == mdiff.replacediffheader(
   518     if delta[:hlen] == mdiff.replacediffheader(
   519         revlog.rawsize(baserev), len(delta) - hlen
   519         revlog.rawsize(baserev), len(delta) - hlen
   520     ):
   520     ):
   521         fulltext = delta[hlen:]
   521         fulltext = delta[hlen:]
   522     else:
   522     else:
   529         validatehash = flagutil.processflagsraw(revlog, fulltext, flags)
   529         validatehash = flagutil.processflagsraw(revlog, fulltext, flags)
   530         if validatehash:
   530         if validatehash:
   531             revlog.checkhash(fulltext, expectednode, p1=p1, p2=p2)
   531             revlog.checkhash(fulltext, expectednode, p1=p1, p2=p2)
   532         if flags & REVIDX_ISCENSORED:
   532         if flags & REVIDX_ISCENSORED:
   533             raise error.StorageError(
   533             raise error.StorageError(
   534                 _('node %s is not censored') % expectednode
   534                 _(b'node %s is not censored') % expectednode
   535             )
   535             )
   536     except error.CensoredNodeError:
   536     except error.CensoredNodeError:
   537         # must pass the censored index flag to add censored revisions
   537         # must pass the censored index flag to add censored revisions
   538         if not flags & REVIDX_ISCENSORED:
   538         if not flags & REVIDX_ISCENSORED:
   539             raise
   539             raise
   724     yield None
   724     yield None
   725 
   725 
   726 
   726 
   727 def _findsnapshots(revlog, cache, start_rev):
   727 def _findsnapshots(revlog, cache, start_rev):
   728     """find snapshot from start_rev to tip"""
   728     """find snapshot from start_rev to tip"""
   729     if util.safehasattr(revlog.index, 'findsnapshots'):
   729     if util.safehasattr(revlog.index, b'findsnapshots'):
   730         revlog.index.findsnapshots(cache, start_rev)
   730         revlog.index.findsnapshots(cache, start_rev)
   731     else:
   731     else:
   732         deltaparent = revlog.deltaparent
   732         deltaparent = revlog.deltaparent
   733         issnapshot = revlog.issnapshot
   733         issnapshot = revlog.issnapshot
   734         for rev in revlog.revs(start_rev):
   734         for rev in revlog.revs(start_rev):