##// END OF EJS Templates
revlog: add 'raw' argument to revision and _addrevision...
Remi Chaintron -
r30743:2df98312 default
parent child Browse files
Show More
@@ -117,7 +117,7 b' class bundlerevlog(revlog.revlog):'
117 117 return mdiff.textdiff(self.revision(self.node(rev1)),
118 118 self.revision(self.node(rev2)))
119 119
120 def revision(self, nodeorrev):
120 def revision(self, nodeorrev, raw=False):
121 121 """return an uncompressed revision of a given node or revision
122 122 number.
123 123 """
@@ -783,7 +783,7 b' class cg1packer(object):'
783 783 prefix = ''
784 784 if revlog.iscensored(base) or revlog.iscensored(rev):
785 785 try:
786 delta = revlog.revision(node)
786 delta = revlog.revision(node, raw=True)
787 787 except error.CensoredNodeError as e:
788 788 delta = e.tombstone
789 789 if base == nullrev:
@@ -792,7 +792,7 b' class cg1packer(object):'
792 792 baselen = revlog.rawsize(base)
793 793 prefix = mdiff.replacediffheader(baselen, len(delta))
794 794 elif base == nullrev:
795 delta = revlog.revision(node)
795 delta = revlog.revision(node, raw=True)
796 796 prefix = mdiff.trivialdiffheader(len(delta))
797 797 else:
798 798 delta = revlog.revdiff(base, rev)
@@ -1110,6 +1110,9 b' class filectx(basefilectx):'
1110 1110 return filectx(self._repo, self._path, fileid=fileid,
1111 1111 filelog=self._filelog, changeid=changeid)
1112 1112
1113 def rawdata(self):
1114 return self._filelog.revision(self._filenode, raw=True)
1115
1113 1116 def data(self):
1114 1117 try:
1115 1118 return self._filelog.read(self._filenode)
@@ -445,7 +445,7 b' def debugdata(ui, repo, file_, rev=None,'
445 445 raise error.CommandError('debugdata', _('invalid arguments'))
446 446 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
447 447 try:
448 ui.write(r.revision(r.lookup(rev)))
448 ui.write(r.revision(r.lookup(rev), raw=True))
449 449 except KeyError:
450 450 raise error.Abort(_('invalid revision identifier %s') % rev)
451 451
@@ -1202,12 +1202,14 b' class revlog(object):'
1202 1202 return mdiff.textdiff(self.revision(rev1),
1203 1203 self.revision(rev2))
1204 1204
1205 def revision(self, nodeorrev, _df=None):
1205 def revision(self, nodeorrev, _df=None, raw=False):
1206 1206 """return an uncompressed revision of a given node or revision
1207 1207 number.
1208 1208
1209 _df is an existing file handle to read from. It is meant to only be
1210 used internally.
1209 _df - an existing file handle to read from. (internal-only)
1210 raw - an optional argument specifying if the revision data is to be
1211 treated as raw data when applying flag transforms. 'raw' should be set
1212 to True when generating changegroups or in debug commands.
1211 1213 """
1212 1214 if isinstance(nodeorrev, int):
1213 1215 rev = nodeorrev
@@ -1412,13 +1414,16 b' class revlog(object):'
1412 1414 return True
1413 1415
1414 1416 def _addrevision(self, node, text, transaction, link, p1, p2, flags,
1415 cachedelta, ifh, dfh, alwayscache=False):
1417 cachedelta, ifh, dfh, alwayscache=False, raw=False):
1416 1418 """internal function to add revisions to the log
1417 1419
1418 1420 see addrevision for argument descriptions.
1419 1421 invariants:
1420 1422 - text is optional (can be None); if not set, cachedelta must be set.
1421 1423 if both are set, they must correspond to each other.
1424 - raw is optional; if set to True, it indicates the revision data is to
1425 be treated by _processflags() as raw. It is usually set by changegroup
1426 generation and debug commands.
1422 1427 """
1423 1428 btext = [text]
1424 1429 def buildtext():
@@ -1438,8 +1443,9 b' class revlog(object):'
1438 1443 fh = ifh
1439 1444 else:
1440 1445 fh = dfh
1441 basetext = self.revision(self.node(baserev), _df=fh)
1446 basetext = self.revision(self.node(baserev), _df=fh, raw=raw)
1442 1447 btext[0] = mdiff.patch(basetext, delta)
1448
1443 1449 try:
1444 1450 self.checkhash(btext[0], node, p1=p1, p2=p2)
1445 1451 if flags & REVIDX_ISCENSORED:
@@ -1668,10 +1674,14 b' class revlog(object):'
1668 1674 # the added revision, which will require a call to
1669 1675 # revision(). revision() will fast path if there is a cache
1670 1676 # hit. So, we tell _addrevision() to always cache in this case.
1677 # We're only using addgroup() in the context of changegroup
1678 # generation so the revision data can always be handled as raw
1679 # by the flagprocessor.
1671 1680 chain = self._addrevision(node, None, transaction, link,
1672 1681 p1, p2, flags, (baserev, delta),
1673 1682 ifh, dfh,
1674 alwayscache=bool(addrevisioncb))
1683 alwayscache=bool(addrevisioncb),
1684 raw=True)
1675 1685
1676 1686 if addrevisioncb:
1677 1687 addrevisioncb(self, chain)
@@ -93,7 +93,7 b' class unionrevlog(revlog.revlog):'
93 93 return mdiff.textdiff(self.revision(self.node(rev1)),
94 94 self.revision(self.node(rev2)))
95 95
96 def revision(self, nodeorrev):
96 def revision(self, nodeorrev, raw=False):
97 97 """return an uncompressed revision of a given node or revision
98 98 number.
99 99 """
General Comments 0
You need to be logged in to leave comments. Login now