Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGc514936d92b4: revlog: remove deprecated APIs
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
( )
hg-reviewers |
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/filelog.py (4 lines) | |||
M | mercurial/interfaces/repository.py (2 lines) | |||
M | mercurial/manifest.py (4 lines) | |||
M | mercurial/pure/parsers.py (6 lines) | |||
M | mercurial/revlog.py (41 lines) | |||
M | mercurial/revlogutils/deltas.py (2 lines) | |||
M | mercurial/revlogutils/revlogv0.py (6 lines) | |||
M | tests/test-revlog-raw.py (2 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
0b6e5a2dfe55 | 2cb4bb3b368e | Raphaël Gomès | Dec 23 2021, 8:48 AM |
# Used by hgweb, children extension. | # Used by hgweb, children extension. | ||||
def children(self, node): | def children(self, node): | ||||
return self._revlog.children(node) | return self._revlog.children(node) | ||||
def iscensored(self, rev): | def iscensored(self, rev): | ||||
return self._revlog.iscensored(rev) | return self._revlog.iscensored(rev) | ||||
def revision(self, node, _df=None, raw=False): | def revision(self, node, _df=None): | ||||
return self._revlog.revision(node, _df=_df, raw=raw) | return self._revlog.revision(node, _df=_df) | ||||
def rawdata(self, node, _df=None): | def rawdata(self, node, _df=None): | ||||
return self._revlog.rawdata(node, _df=_df) | return self._revlog.rawdata(node, _df=_df) | ||||
def emitrevisions( | def emitrevisions( | ||||
self, | self, | ||||
nodes, | nodes, | ||||
nodesorder=None, | nodesorder=None, |
""" | """ | ||||
def parentrevs(rev): | def parentrevs(rev): | ||||
"""Like parents() but operates on revision numbers.""" | """Like parents() but operates on revision numbers.""" | ||||
def linkrev(rev): | def linkrev(rev): | ||||
"""Obtain the changeset revision number a revision is linked to.""" | """Obtain the changeset revision number a revision is linked to.""" | ||||
def revision(node, _df=None, raw=False): | def revision(node, _df=None): | ||||
"""Obtain fulltext data for a node.""" | """Obtain fulltext data for a node.""" | ||||
def rawdata(node, _df=None): | def rawdata(node, _df=None): | ||||
"""Obtain raw data for a node.""" | """Obtain raw data for a node.""" | ||||
def revdiff(rev1, rev2): | def revdiff(rev1, rev2): | ||||
"""Obtain a delta between two revision numbers. | """Obtain a delta between two revision numbers. | ||||
return self._revlog.parents(node) | return self._revlog.parents(node) | ||||
def linkrev(self, rev): | def linkrev(self, rev): | ||||
return self._revlog.linkrev(rev) | return self._revlog.linkrev(rev) | ||||
def checksize(self): | def checksize(self): | ||||
return self._revlog.checksize() | return self._revlog.checksize() | ||||
def revision(self, node, _df=None, raw=False): | def revision(self, node, _df=None): | ||||
return self._revlog.revision(node, _df=_df, raw=raw) | return self._revlog.revision(node, _df=_df) | ||||
def rawdata(self, node, _df=None): | def rawdata(self, node, _df=None): | ||||
return self._revlog.rawdata(node, _df=_df) | return self._revlog.rawdata(node, _df=_df) | ||||
def revdiff(self, rev1, rev2): | def revdiff(self, rev1, rev2): | ||||
return self._revlog.revdiff(rev1, rev2) | return self._revlog.revdiff(rev1, rev2) | ||||
def cmp(self, node, text): | def cmp(self, node, text): |
revlog_constants.COMP_MODE_INLINE, | revlog_constants.COMP_MODE_INLINE, | ||||
revlog_constants.RANK_UNKNOWN, | revlog_constants.RANK_UNKNOWN, | ||||
) | ) | ||||
@util.propertycache | @util.propertycache | ||||
def entry_size(self): | def entry_size(self): | ||||
return self.index_format.size | return self.index_format.size | ||||
@property | |||||
def nodemap(self): | |||||
msg = b"index.nodemap is deprecated, use index.[has_node|rev|get_rev]" | |||||
util.nouideprecwarn(msg, b'5.3', stacklevel=2) | |||||
return self._nodemap | |||||
@util.propertycache | @util.propertycache | ||||
def _nodemap(self): | def _nodemap(self): | ||||
nodemap = nodemaputil.NodeMap({sha1nodeconstants.nullid: nullrev}) | nodemap = nodemaputil.NodeMap({sha1nodeconstants.nullid: nullrev}) | ||||
for r in range(0, len(self)): | for r in range(0, len(self)): | ||||
n = self[r][7] | n = self[r][7] | ||||
nodemap[n] = r | nodemap[n] = r | ||||
return nodemap | return nodemap | ||||
def __iter__(self): | def __iter__(self): | ||||
return iter(pycompat.xrange(len(self))) | return iter(pycompat.xrange(len(self))) | ||||
def revs(self, start=0, stop=None): | def revs(self, start=0, stop=None): | ||||
"""iterate over all rev in this revlog (from start to stop)""" | """iterate over all rev in this revlog (from start to stop)""" | ||||
return storageutil.iterrevs(len(self), start=start, stop=stop) | return storageutil.iterrevs(len(self), start=start, stop=stop) | ||||
@property | |||||
def nodemap(self): | |||||
msg = ( | |||||
b"revlog.nodemap is deprecated, " | |||||
b"use revlog.index.[has_node|rev|get_rev]" | |||||
) | |||||
util.nouideprecwarn(msg, b'5.3', stacklevel=2) | |||||
return self.index.nodemap | |||||
@property | |||||
def _nodecache(self): | |||||
msg = b"revlog._nodecache is deprecated, use revlog.index.nodemap" | |||||
util.nouideprecwarn(msg, b'5.3', stacklevel=2) | |||||
return self.index.nodemap | |||||
def hasnode(self, node): | def hasnode(self, node): | ||||
try: | try: | ||||
self.rev(node) | self.rev(node) | ||||
return True | return True | ||||
except KeyError: | except KeyError: | ||||
return False | return False | ||||
def candelta(self, baserev, rev): | def candelta(self, baserev, rev): | ||||
def size(self, rev): | def size(self, rev): | ||||
"""length of non-raw text (processed by a "read" flag processor)""" | """length of non-raw text (processed by a "read" flag processor)""" | ||||
# fast path: if no "read" flag processor could change the content, | # fast path: if no "read" flag processor could change the content, | ||||
# size is rawsize. note: ELLIPSIS is known to not change the content. | # size is rawsize. note: ELLIPSIS is known to not change the content. | ||||
flags = self.flags(rev) | flags = self.flags(rev) | ||||
if flags & (flagutil.REVIDX_KNOWN_FLAGS ^ REVIDX_ELLIPSIS) == 0: | if flags & (flagutil.REVIDX_KNOWN_FLAGS ^ REVIDX_ELLIPSIS) == 0: | ||||
return self.rawsize(rev) | return self.rawsize(rev) | ||||
return len(self.revision(rev, raw=False)) | return len(self.revision(rev)) | ||||
def chainbase(self, rev): | def chainbase(self, rev): | ||||
base = self._chainbasecache.get(rev) | base = self._chainbasecache.get(rev) | ||||
if base is not None: | if base is not None: | ||||
return base | return base | ||||
index = self.index | index = self.index | ||||
iterrev = rev | iterrev = rev | ||||
The delta calculated is in binary form and is intended to be written to | The delta calculated is in binary form and is intended to be written to | ||||
revlog data directly. So this function needs raw revision data. | revlog data directly. So this function needs raw revision data. | ||||
""" | """ | ||||
if rev1 != nullrev and self.deltaparent(rev2) == rev1: | if rev1 != nullrev and self.deltaparent(rev2) == rev1: | ||||
return bytes(self._chunk(rev2)) | return bytes(self._chunk(rev2)) | ||||
return mdiff.textdiff(self.rawdata(rev1), self.rawdata(rev2)) | return mdiff.textdiff(self.rawdata(rev1), self.rawdata(rev2)) | ||||
def _processflags(self, text, flags, operation, raw=False): | def revision(self, nodeorrev, _df=None): | ||||
"""deprecated entry point to access flag processors""" | |||||
msg = b'_processflag(...) use the specialized variant' | |||||
util.nouideprecwarn(msg, b'5.2', stacklevel=2) | |||||
if raw: | |||||
return text, flagutil.processflagsraw(self, text, flags) | |||||
elif operation == b'read': | |||||
return flagutil.processflagsread(self, text, flags) | |||||
else: # write operation | |||||
return flagutil.processflagswrite(self, text, flags) | |||||
def revision(self, nodeorrev, _df=None, raw=False): | |||||
"""return an uncompressed revision of a given node or revision | """return an uncompressed revision of a given node or revision | ||||
number. | number. | ||||
_df - an existing file handle to read from. (internal-only) | _df - an existing file handle to read from. (internal-only) | ||||
raw - an optional argument specifying if the revision data is to be | |||||
treated as raw data when applying flag transforms. 'raw' should be set | |||||
to True when generating changegroups or in debug commands. | |||||
""" | """ | ||||
if raw: | return self._revisiondata(nodeorrev, _df) | ||||
msg = ( | |||||
b'revlog.revision(..., raw=True) is deprecated, ' | |||||
b'use revlog.rawdata(...)' | |||||
) | |||||
util.nouideprecwarn(msg, b'5.2', stacklevel=2) | |||||
return self._revisiondata(nodeorrev, _df, raw=raw) | |||||
def sidedata(self, nodeorrev, _df=None): | def sidedata(self, nodeorrev, _df=None): | ||||
"""a map of extra data related to the changeset but not part of the hash | """a map of extra data related to the changeset but not part of the hash | ||||
This function currently return a dictionary. However, more advanced | This function currently return a dictionary. However, more advanced | ||||
mapping object will likely be used in the future for a more | mapping object will likely be used in the future for a more | ||||
efficient/lazy code. | efficient/lazy code. | ||||
""" | """ |
hlen = struct.calcsize(b">lll") | hlen = struct.calcsize(b">lll") | ||||
if delta[:hlen] == mdiff.replacediffheader( | if delta[:hlen] == mdiff.replacediffheader( | ||||
revlog.rawsize(baserev), len(delta) - hlen | revlog.rawsize(baserev), len(delta) - hlen | ||||
): | ): | ||||
fulltext = delta[hlen:] | fulltext = delta[hlen:] | ||||
else: | else: | ||||
# deltabase is rawtext before changed by flag processors, which is | # deltabase is rawtext before changed by flag processors, which is | ||||
# equivalent to non-raw text | # equivalent to non-raw text | ||||
basetext = revlog.revision(baserev, _df=fh, raw=False) | basetext = revlog.revision(baserev, _df=fh) | ||||
fulltext = mdiff.patch(basetext, delta) | fulltext = mdiff.patch(basetext, delta) | ||||
try: | try: | ||||
validatehash = flagutil.processflagsraw(revlog, fulltext, flags) | validatehash = flagutil.processflagsraw(revlog, fulltext, flags) | ||||
if validatehash: | if validatehash: | ||||
revlog.checkhash(fulltext, expectednode, p1=p1, p2=p2) | revlog.checkhash(fulltext, expectednode, p1=p1, p2=p2) | ||||
if flags & REVIDX_ISCENSORED: | if flags & REVIDX_ISCENSORED: | ||||
raise error.StorageError( | raise error.StorageError( |
data_compressed_length=0, | data_compressed_length=0, | ||||
data_delta_base=node.nullrev, | data_delta_base=node.nullrev, | ||||
link_rev=node.nullrev, | link_rev=node.nullrev, | ||||
parent_rev_1=node.nullrev, | parent_rev_1=node.nullrev, | ||||
parent_rev_2=node.nullrev, | parent_rev_2=node.nullrev, | ||||
node_id=sha1nodeconstants.nullid, | node_id=sha1nodeconstants.nullid, | ||||
) | ) | ||||
@property | |||||
def nodemap(self): | |||||
msg = b"index.nodemap is deprecated, use index.[has_node|rev|get_rev]" | |||||
util.nouideprecwarn(msg, b'5.3', stacklevel=2) | |||||
return self._nodemap | |||||
@util.propertycache | @util.propertycache | ||||
def _nodemap(self): | def _nodemap(self): | ||||
nodemap = nodemaputil.NodeMap({sha1nodeconstants.nullid: node.nullrev}) | nodemap = nodemaputil.NodeMap({sha1nodeconstants.nullid: node.nullrev}) | ||||
for r in range(0, len(self)): | for r in range(0, len(self)): | ||||
n = self[r][7] | n = self[r][7] | ||||
nodemap[n] = r | nodemap[n] = r | ||||
return nodemap | return nodemap | ||||
# Verify text, rawtext, and rawsize | # Verify text, rawtext, and rawsize | ||||
if isext: | if isext: | ||||
rawtext = writeprocessor(None, text)[0] | rawtext = writeprocessor(None, text)[0] | ||||
else: | else: | ||||
rawtext = text | rawtext = text | ||||
if rlog.rawsize(rev) != len(rawtext): | if rlog.rawsize(rev) != len(rawtext): | ||||
abort('rev %d: wrong rawsize' % rev) | abort('rev %d: wrong rawsize' % rev) | ||||
if rlog.revision(rev, raw=False) != text: | if rlog.revision(rev) != text: | ||||
abort('rev %d: wrong text' % rev) | abort('rev %d: wrong text' % rev) | ||||
if rlog.rawdata(rev) != rawtext: | if rlog.rawdata(rev) != rawtext: | ||||
abort('rev %d: wrong rawtext' % rev) | abort('rev %d: wrong rawtext' % rev) | ||||
result.append((text, rawtext)) | result.append((text, rawtext)) | ||||
# Verify flags like isdelta, isext work as expected | # Verify flags like isdelta, isext work as expected | ||||
# isdelta can be overridden to False if this or p1 has isext set | # isdelta can be overridden to False if this or p1 has isext set | ||||
if bool(rlog.deltaparent(rev) > -1) and not isdelta: | if bool(rlog.deltaparent(rev) > -1) and not isdelta: |