##// END OF EJS Templates
revlogdeltas: extra fulltext building in its own function...
Boris Feld -
r39367:fd0150a3 default
parent child Browse files
Show More
@@ -438,6 +438,34 b' def segmentspan(revlog, revs, deltainfo='
438 end = revlog.end(revs[-1])
438 end = revlog.end(revs[-1])
439 return end - revlog.start(revs[0])
439 return end - revlog.start(revs[0])
440
440
441 def _textfromdelta(fh, revlog, baserev, delta, p1, p2, flags, expectednode):
442 """build full text from a (base, delta) pair and other metadata"""
443 # special case deltas which replace entire base; no need to decode
444 # base revision. this neatly avoids censored bases, which throw when
445 # they're decoded.
446 hlen = struct.calcsize(">lll")
447 if delta[:hlen] == mdiff.replacediffheader(revlog.rawsize(baserev),
448 len(delta) - hlen):
449 fulltext = delta[hlen:]
450 else:
451 # deltabase is rawtext before changed by flag processors, which is
452 # equivalent to non-raw text
453 basetext = revlog.revision(baserev, _df=fh, raw=False)
454 fulltext = mdiff.patch(basetext, delta)
455
456 try:
457 res = revlog._processflags(fulltext, flags, 'read', raw=True)
458 fulltext, validatehash = res
459 if validatehash:
460 revlog.checkhash(fulltext, expectednode, p1=p1, p2=p2)
461 if flags & REVIDX_ISCENSORED:
462 raise RevlogError(_('node %s is not censored') % expectednode)
463 except CensoredNodeError:
464 # must pass the censored index flag to add censored revisions
465 if not flags & REVIDX_ISCENSORED:
466 raise
467 return fulltext
468
441 @attr.s(slots=True, frozen=True)
469 @attr.s(slots=True, frozen=True)
442 class _deltainfo(object):
470 class _deltainfo(object):
443 distance = attr.ib()
471 distance = attr.ib()
@@ -605,36 +633,13 b' class deltacomputer(object):'
605
633
606 revlog = self.revlog
634 revlog = self.revlog
607 cachedelta = revinfo.cachedelta
635 cachedelta = revinfo.cachedelta
608 flags = revinfo.flags
609 node = revinfo.node
610
611 baserev = cachedelta[0]
636 baserev = cachedelta[0]
612 delta = cachedelta[1]
637 delta = cachedelta[1]
613 # special case deltas which replace entire base; no need to decode
614 # base revision. this neatly avoids censored bases, which throw when
615 # they're decoded.
616 hlen = struct.calcsize(">lll")
617 if delta[:hlen] == mdiff.replacediffheader(revlog.rawsize(baserev),
618 len(delta) - hlen):
619 btext[0] = delta[hlen:]
620 else:
621 # deltabase is rawtext before changed by flag processors, which is
622 # equivalent to non-raw text
623 basetext = revlog.revision(baserev, _df=fh, raw=False)
624 btext[0] = mdiff.patch(basetext, delta)
625
638
626 try:
639 fulltext = btext[0] = _textfromdelta(fh, revlog, baserev, delta,
627 res = revlog._processflags(btext[0], flags, 'read', raw=True)
640 revinfo.p1, revinfo.p2,
628 btext[0], validatehash = res
641 revinfo.flags, revinfo.node)
629 if validatehash:
642 return fulltext
630 revlog.checkhash(btext[0], node, p1=revinfo.p1, p2=revinfo.p2)
631 if flags & REVIDX_ISCENSORED:
632 raise RevlogError(_('node %s is not censored') % node)
633 except CensoredNodeError:
634 # must pass the censored index flag to add censored revisions
635 if not flags & REVIDX_ISCENSORED:
636 raise
637 return btext[0]
638
643
639 def _builddeltadiff(self, base, revinfo, fh):
644 def _builddeltadiff(self, base, revinfo, fh):
640 revlog = self.revlog
645 revlog = self.revlog
General Comments 0
You need to be logged in to leave comments. Login now