bundlerepo: simplify code to take advantage of `_rawtext`
In the revlog code, the code getting the raw text is now isolated. We take
advantage of this to simplify the bundlerepo code.
--- a/mercurial/bundlerepo.py Sat Aug 31 11:10:12 2019 +0900
+++ b/mercurial/bundlerepo.py Fri Aug 30 15:04:54 2019 +0200
@@ -17,7 +17,10 @@
import shutil
from .i18n import _
-from .node import nullid
+from .node import (
+ nullid,
+ nullrev
+)
from . import (
bundle2,
@@ -108,20 +111,10 @@
return mdiff.textdiff(self.rawdata(rev1),
self.rawdata(rev2))
- def revision(self, nodeorrev, _df=None, raw=False):
- """return an uncompressed revision of a given node or revision
- number.
- """
- if isinstance(nodeorrev, int):
- rev = nodeorrev
- node = self.node(rev)
- else:
- node = nodeorrev
+ def _rawtext(self, node, rev, _df=None):
+ if rev is None:
rev = self.rev(node)
-
- if node == nullid:
- return ""
-
+ validated = False
rawtext = None
chain = []
iterrev = rev
@@ -132,19 +125,19 @@
break
chain.append(iterrev)
iterrev = self.index[iterrev][3]
- if rawtext is None:
- rawtext = self.baserevision(iterrev)
-
+ if iterrev == nullrev:
+ rawtext = ''
+ elif rawtext is None:
+ r = super(bundlerevlog, self)._rawtext(self.node(iterrev),
+ iterrev,
+ _df=_df)
+ __, rawtext, validated = r
+ if chain:
+ validated = False
while chain:
delta = self._chunk(chain.pop())
rawtext = mdiff.patches(rawtext, [delta])
-
- text, validatehash = self._processflags(rawtext, self.flags(rev),
- 'read', raw=raw)
- if validatehash:
- self.checkhash(text, node, rev=rev)
- self._revisioncache = (node, rev, rawtext)
- return text
+ return rev, rawtext, validated
def rawdata(self, nodeorrev, _df=None):
return self.revision(nodeorrev, _df=_df, raw=True)