Mercurial > hg-stable
changeset 42831:c070ca6ed86d
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.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 30 Aug 2019 15:04:54 +0200 |
parents | 10841b9a80c3 |
children | 0f5652f17325 |
files | mercurial/bundlerepo.py |
diffstat | 1 files changed, 17 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- 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)