error.RevlogError was moved from revlog.py in 08cabecfa8a8 in
- revlog.RevlogError has remained as an alias ever since.
Let's drop the alias and use error.RevlogError directly.
hg-reviewers |
error.RevlogError was moved from revlog.py in 08cabecfa8a8 in
Let's drop the alias and use error.RevlogError directly.
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/revlog.py (79 lines) | |||
M | mercurial/revlogutils/deltas.py (3 lines) | |||
M | tests/simplestorerepo.py (2 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Gregory Szorc | Sep 18 2018, 7:18 PM |
# Aliased for performance. | # Aliased for performance. | ||||
_zlibdecompress = zlib.decompress | _zlibdecompress = zlib.decompress | ||||
# max size of revlog with inline data | # max size of revlog with inline data | ||||
_maxinline = 131072 | _maxinline = 131072 | ||||
_chunksize = 1048576 | _chunksize = 1048576 | ||||
RevlogError = error.RevlogError | |||||
LookupError = error.LookupError | LookupError = error.LookupError | ||||
AmbiguousPrefixLookupError = error.AmbiguousPrefixLookupError | AmbiguousPrefixLookupError = error.AmbiguousPrefixLookupError | ||||
CensoredNodeError = error.CensoredNodeError | CensoredNodeError = error.CensoredNodeError | ||||
ProgrammingError = error.ProgrammingError | ProgrammingError = error.ProgrammingError | ||||
# Store flag processors (cf. 'addflagprocessor()' to register) | # Store flag processors (cf. 'addflagprocessor()' to register) | ||||
_flagprocessors = { | _flagprocessors = { | ||||
REVIDX_ISCENSORED: None, | REVIDX_ISCENSORED: None, | ||||
index.append(e2) | index.append(e2) | ||||
nodemap[e[6]] = n | nodemap[e[6]] = n | ||||
n += 1 | n += 1 | ||||
return revlogoldindex(index), nodemap, None | return revlogoldindex(index), nodemap, None | ||||
def packentry(self, entry, node, version, rev): | def packentry(self, entry, node, version, rev): | ||||
if gettype(entry[0]): | if gettype(entry[0]): | ||||
raise RevlogError(_('index entry flags need revlog version 1')) | raise error.RevlogError(_('index entry flags need revlog ' | ||||
'version 1')) | |||||
e2 = (getoffset(entry[0]), entry[1], entry[3], entry[4], | e2 = (getoffset(entry[0]), entry[1], entry[3], entry[4], | ||||
node(entry[5]), node(entry[6]), entry[7]) | node(entry[5]), node(entry[6]), entry[7]) | ||||
return indexformatv0_pack(*e2) | return indexformatv0_pack(*e2) | ||||
# index ng: | # index ng: | ||||
# 6 bytes: offset | # 6 bytes: offset | ||||
# 2 bytes: flags | # 2 bytes: flags | ||||
# 4 bytes: compressed length | # 4 bytes: compressed length | ||||
if 'sparse-read-density-threshold' in opts: | if 'sparse-read-density-threshold' in opts: | ||||
self._srdensitythreshold = opts['sparse-read-density-threshold'] | self._srdensitythreshold = opts['sparse-read-density-threshold'] | ||||
if 'sparse-read-min-gap-size' in opts: | if 'sparse-read-min-gap-size' in opts: | ||||
self._srmingapsize = opts['sparse-read-min-gap-size'] | self._srmingapsize = opts['sparse-read-min-gap-size'] | ||||
if opts.get('enableellipsis'): | if opts.get('enableellipsis'): | ||||
self._flagprocessors[REVIDX_ELLIPSIS] = ellipsisprocessor | self._flagprocessors[REVIDX_ELLIPSIS] = ellipsisprocessor | ||||
if self._chunkcachesize <= 0: | if self._chunkcachesize <= 0: | ||||
raise RevlogError(_('revlog chunk cache size %r is not greater ' | raise error.RevlogError(_('revlog chunk cache size %r is not ' | ||||
'than 0') % self._chunkcachesize) | 'greater than 0') % self._chunkcachesize) | ||||
elif self._chunkcachesize & (self._chunkcachesize - 1): | elif self._chunkcachesize & (self._chunkcachesize - 1): | ||||
raise RevlogError(_('revlog chunk cache size %r is not a power ' | raise error.RevlogError(_('revlog chunk cache size %r is not a ' | ||||
'of 2') % self._chunkcachesize) | 'power of 2') % self._chunkcachesize) | ||||
indexdata = '' | indexdata = '' | ||||
self._initempty = True | self._initempty = True | ||||
try: | try: | ||||
with self._indexfp() as f: | with self._indexfp() as f: | ||||
if (mmapindexthreshold is not None and | if (mmapindexthreshold is not None and | ||||
self.opener.fstat(f).st_size >= mmapindexthreshold): | self.opener.fstat(f).st_size >= mmapindexthreshold): | ||||
indexdata = util.buffer(util.mmapread(f)) | indexdata = util.buffer(util.mmapread(f)) | ||||
else: | else: | ||||
indexdata = f.read() | indexdata = f.read() | ||||
if len(indexdata) > 0: | if len(indexdata) > 0: | ||||
v = versionformat_unpack(indexdata[:4])[0] | v = versionformat_unpack(indexdata[:4])[0] | ||||
self._initempty = False | self._initempty = False | ||||
except IOError as inst: | except IOError as inst: | ||||
if inst.errno != errno.ENOENT: | if inst.errno != errno.ENOENT: | ||||
raise | raise | ||||
self.version = v | self.version = v | ||||
self._inline = v & FLAG_INLINE_DATA | self._inline = v & FLAG_INLINE_DATA | ||||
self._generaldelta = v & FLAG_GENERALDELTA | self._generaldelta = v & FLAG_GENERALDELTA | ||||
flags = v & ~0xFFFF | flags = v & ~0xFFFF | ||||
fmt = v & 0xFFFF | fmt = v & 0xFFFF | ||||
if fmt == REVLOGV0: | if fmt == REVLOGV0: | ||||
if flags: | if flags: | ||||
raise RevlogError(_('unknown flags (%#04x) in version %d ' | raise error.RevlogError(_('unknown flags (%#04x) in version %d ' | ||||
'revlog %s') % | 'revlog %s') % | ||||
(flags >> 16, fmt, self.indexfile)) | (flags >> 16, fmt, self.indexfile)) | ||||
elif fmt == REVLOGV1: | elif fmt == REVLOGV1: | ||||
if flags & ~REVLOGV1_FLAGS: | if flags & ~REVLOGV1_FLAGS: | ||||
raise RevlogError(_('unknown flags (%#04x) in version %d ' | raise error.RevlogError(_('unknown flags (%#04x) in version %d ' | ||||
'revlog %s') % | 'revlog %s') % | ||||
(flags >> 16, fmt, self.indexfile)) | (flags >> 16, fmt, self.indexfile)) | ||||
elif fmt == REVLOGV2: | elif fmt == REVLOGV2: | ||||
if flags & ~REVLOGV2_FLAGS: | if flags & ~REVLOGV2_FLAGS: | ||||
raise RevlogError(_('unknown flags (%#04x) in version %d ' | raise error.RevlogError(_('unknown flags (%#04x) in version %d ' | ||||
'revlog %s') % | 'revlog %s') % | ||||
(flags >> 16, fmt, self.indexfile)) | (flags >> 16, fmt, self.indexfile)) | ||||
else: | else: | ||||
raise RevlogError(_('unknown version (%d) in revlog %s') % | raise error.RevlogError(_('unknown version (%d) in revlog %s') % | ||||
(fmt, self.indexfile)) | (fmt, self.indexfile)) | ||||
self._storedeltachains = True | self._storedeltachains = True | ||||
self._io = revlogio() | self._io = revlogio() | ||||
if self.version == REVLOGV0: | if self.version == REVLOGV0: | ||||
self._io = revlogoldio() | self._io = revlogoldio() | ||||
try: | try: | ||||
d = self._io.parseindex(indexdata, self._inline) | d = self._io.parseindex(indexdata, self._inline) | ||||
except (ValueError, IndexError): | except (ValueError, IndexError): | ||||
raise RevlogError(_("index %s is corrupted") % (self.indexfile)) | raise error.RevlogError(_("index %s is corrupted") % | ||||
self.indexfile) | |||||
self.index, nodemap, self._chunkcache = d | self.index, nodemap, self._chunkcache = d | ||||
if nodemap is not None: | if nodemap is not None: | ||||
self.nodemap = self._nodecache = nodemap | self.nodemap = self._nodecache = nodemap | ||||
if not self._chunkcache: | if not self._chunkcache: | ||||
self._chunkclear() | self._chunkclear() | ||||
# revnum -> (chain-length, sum-delta-length) | # revnum -> (chain-length, sum-delta-length) | ||||
self._chaininfocache = {} | self._chaininfocache = {} | ||||
# revlog header -> revlog compressor | # revlog header -> revlog compressor | ||||
self._nodecache = {nullid: nullrev} | self._nodecache = {nullid: nullrev} | ||||
self._nodepos = None | self._nodepos = None | ||||
def rev(self, node): | def rev(self, node): | ||||
try: | try: | ||||
return self._nodecache[node] | return self._nodecache[node] | ||||
except TypeError: | except TypeError: | ||||
raise | raise | ||||
except RevlogError: | except error.RevlogError: | ||||
# parsers.c radix tree lookup failed | # parsers.c radix tree lookup failed | ||||
if node == wdirid or node in wdirfilenodeids: | if node == wdirid or node in wdirfilenodeids: | ||||
raise error.WdirUnsupported | raise error.WdirUnsupported | ||||
raise LookupError(node, self.indexfile, _('no node')) | raise LookupError(node, self.indexfile, _('no node')) | ||||
except KeyError: | except KeyError: | ||||
# pure python cache lookup failed | # pure python cache lookup failed | ||||
n = self._nodecache | n = self._nodecache | ||||
i = self.index | i = self.index | ||||
def _partialmatch(self, id): | def _partialmatch(self, id): | ||||
# we don't care wdirfilenodeids as they should be always full hash | # we don't care wdirfilenodeids as they should be always full hash | ||||
maybewdir = wdirhex.startswith(id) | maybewdir = wdirhex.startswith(id) | ||||
try: | try: | ||||
partial = self.index.partialmatch(id) | partial = self.index.partialmatch(id) | ||||
if partial and self.hasnode(partial): | if partial and self.hasnode(partial): | ||||
if maybewdir: | if maybewdir: | ||||
# single 'ff...' match in radix tree, ambiguous with wdir | # single 'ff...' match in radix tree, ambiguous with wdir | ||||
raise RevlogError | raise error.RevlogError | ||||
return partial | return partial | ||||
if maybewdir: | if maybewdir: | ||||
# no 'ff...' match in radix tree, wdir identified | # no 'ff...' match in radix tree, wdir identified | ||||
raise error.WdirUnsupported | raise error.WdirUnsupported | ||||
return None | return None | ||||
except RevlogError: | except error.RevlogError: | ||||
# parsers.c radix tree lookup gave multiple matches | # parsers.c radix tree lookup gave multiple matches | ||||
# fast path: for unfiltered changelog, radix tree is accurate | # fast path: for unfiltered changelog, radix tree is accurate | ||||
if not getattr(self, 'filteredrevs', None): | if not getattr(self, 'filteredrevs', None): | ||||
raise AmbiguousPrefixLookupError(id, self.indexfile, | raise AmbiguousPrefixLookupError(id, self.indexfile, | ||||
_('ambiguous identifier')) | _('ambiguous identifier')) | ||||
# fall through to slow path that filters hidden revisions | # fall through to slow path that filters hidden revisions | ||||
except (AttributeError, ValueError): | except (AttributeError, ValueError): | ||||
# we are pure python, or key was too short to search radix tree | # we are pure python, or key was too short to search radix tree | ||||
prefix = hexnode[:length] | prefix = hexnode[:length] | ||||
if not maybewdir(prefix): | if not maybewdir(prefix): | ||||
return prefix | return prefix | ||||
if not getattr(self, 'filteredrevs', None): | if not getattr(self, 'filteredrevs', None): | ||||
try: | try: | ||||
length = max(self.index.shortest(node), minlength) | length = max(self.index.shortest(node), minlength) | ||||
return disambiguate(hexnode, length) | return disambiguate(hexnode, length) | ||||
except RevlogError: | except error.RevlogError: | ||||
if node != wdirid: | if node != wdirid: | ||||
raise LookupError(node, self.indexfile, _('no node')) | raise LookupError(node, self.indexfile, _('no node')) | ||||
except AttributeError: | except AttributeError: | ||||
# Fall through to pure code | # Fall through to pure code | ||||
pass | pass | ||||
if node == wdirid: | if node == wdirid: | ||||
for length in range(minlength, 41): | for length in range(minlength, 41): | ||||
""" | """ | ||||
# fast path: no flag processors will run | # fast path: no flag processors will run | ||||
if flags == 0: | if flags == 0: | ||||
return text, True | return text, True | ||||
if not operation in ('read', 'write'): | if not operation in ('read', 'write'): | ||||
raise ProgrammingError(_("invalid '%s' operation ") % (operation)) | raise ProgrammingError(_("invalid '%s' operation ") % (operation)) | ||||
# Check all flags are known. | # Check all flags are known. | ||||
if flags & ~REVIDX_KNOWN_FLAGS: | if flags & ~REVIDX_KNOWN_FLAGS: | ||||
raise RevlogError(_("incompatible revision flag '%#x'") % | raise error.RevlogError(_("incompatible revision flag '%#x'") % | ||||
(flags & ~REVIDX_KNOWN_FLAGS)) | (flags & ~REVIDX_KNOWN_FLAGS)) | ||||
validatehash = True | validatehash = True | ||||
# Depending on the operation (read or write), the order might be | # Depending on the operation (read or write), the order might be | ||||
# reversed due to non-commutative transforms. | # reversed due to non-commutative transforms. | ||||
orderedflags = REVIDX_FLAGS_ORDER | orderedflags = REVIDX_FLAGS_ORDER | ||||
if operation == 'write': | if operation == 'write': | ||||
orderedflags = reversed(orderedflags) | orderedflags = reversed(orderedflags) | ||||
for flag in orderedflags: | for flag in orderedflags: | ||||
# If a flagprocessor has been registered for a known flag, apply the | # If a flagprocessor has been registered for a known flag, apply the | ||||
# related operation transform and update result tuple. | # related operation transform and update result tuple. | ||||
if flag & flags: | if flag & flags: | ||||
vhash = True | vhash = True | ||||
if flag not in self._flagprocessors: | if flag not in self._flagprocessors: | ||||
message = _("missing processor for flag '%#x'") % (flag) | message = _("missing processor for flag '%#x'") % (flag) | ||||
raise RevlogError(message) | raise error.RevlogError(message) | ||||
processor = self._flagprocessors[flag] | processor = self._flagprocessors[flag] | ||||
if processor is not None: | if processor is not None: | ||||
readtransform, writetransform, rawtransform = processor | readtransform, writetransform, rawtransform = processor | ||||
if raw: | if raw: | ||||
vhash = rawtransform(self, text) | vhash = rawtransform(self, text) | ||||
elif operation == 'read': | elif operation == 'read': | ||||
""" | """ | ||||
try: | try: | ||||
if p1 is None and p2 is None: | if p1 is None and p2 is None: | ||||
p1, p2 = self.parents(node) | p1, p2 = self.parents(node) | ||||
if node != self.hash(text, p1, p2): | if node != self.hash(text, p1, p2): | ||||
revornode = rev | revornode = rev | ||||
if revornode is None: | if revornode is None: | ||||
revornode = templatefilters.short(hex(node)) | revornode = templatefilters.short(hex(node)) | ||||
raise RevlogError(_("integrity check failed on %s:%s") | raise error.RevlogError(_("integrity check failed on %s:%s") | ||||
% (self.indexfile, pycompat.bytestr(revornode))) | % (self.indexfile, pycompat.bytestr(revornode))) | ||||
except RevlogError: | except error.RevlogError: | ||||
if self._censorable and _censoredtext(text): | if self._censorable and _censoredtext(text): | ||||
raise error.CensoredNodeError(self.indexfile, node, text) | raise error.CensoredNodeError(self.indexfile, node, text) | ||||
raise | raise | ||||
def _enforceinlinesize(self, tr, fp=None): | def _enforceinlinesize(self, tr, fp=None): | ||||
"""Check if the revlog is too big for inline and convert if so. | """Check if the revlog is too big for inline and convert if so. | ||||
This should be called after revisions are added to the revlog. If the | This should be called after revisions are added to the revlog. If the | ||||
revlog has grown too large to be an inline revlog, it will convert it | revlog has grown too large to be an inline revlog, it will convert it | ||||
to use multiple index and data files. | to use multiple index and data files. | ||||
""" | """ | ||||
tiprev = len(self) - 1 | tiprev = len(self) - 1 | ||||
if (not self._inline or | if (not self._inline or | ||||
(self.start(tiprev) + self.length(tiprev)) < _maxinline): | (self.start(tiprev) + self.length(tiprev)) < _maxinline): | ||||
return | return | ||||
trinfo = tr.find(self.indexfile) | trinfo = tr.find(self.indexfile) | ||||
if trinfo is None: | if trinfo is None: | ||||
raise RevlogError(_("%s not found in the transaction") | raise error.RevlogError(_("%s not found in the transaction") | ||||
% self.indexfile) | % self.indexfile) | ||||
trindex = trinfo[2] | trindex = trinfo[2] | ||||
if trindex is not None: | if trindex is not None: | ||||
dataoff = self.start(trindex) | dataoff = self.start(trindex) | ||||
else: | else: | ||||
# revlog was stripped at start of transaction, use all leftover data | # revlog was stripped at start of transaction, use all leftover data | ||||
trindex = len(self) - 1 | trindex = len(self) - 1 | ||||
dataoff = self.end(tiprev) | dataoff = self.end(tiprev) | ||||
node - nodeid of revision; typically node is not specified, and it is | node - nodeid of revision; typically node is not specified, and it is | ||||
computed by default as hash(text, p1, p2), however subclasses might | computed by default as hash(text, p1, p2), however subclasses might | ||||
use different hashing method (and override checkhash() in such case) | use different hashing method (and override checkhash() in such case) | ||||
flags - the known flags to set on the revision | flags - the known flags to set on the revision | ||||
deltacomputer - an optional deltacomputer instance shared between | deltacomputer - an optional deltacomputer instance shared between | ||||
multiple calls | multiple calls | ||||
""" | """ | ||||
if link == nullrev: | if link == nullrev: | ||||
raise RevlogError(_("attempted to add linkrev -1 to %s") | raise error.RevlogError(_("attempted to add linkrev -1 to %s") | ||||
% self.indexfile) | % self.indexfile) | ||||
if flags: | if flags: | ||||
node = node or self.hash(text, p1, p2) | node = node or self.hash(text, p1, p2) | ||||
rawtext, validatehash = self._processflags(text, flags, 'write') | rawtext, validatehash = self._processflags(text, flags, 'write') | ||||
# If the flag processor modifies the revision data, ignore any provided | # If the flag processor modifies the revision data, ignore any provided | ||||
# cachedelta. | # cachedelta. | ||||
if rawtext != text: | if rawtext != text: | ||||
cachedelta = None | cachedelta = None | ||||
if len(rawtext) > _maxentrysize: | if len(rawtext) > _maxentrysize: | ||||
raise RevlogError( | raise error.RevlogError( | ||||
_("%s: size of %d bytes exceeds maximum revlog storage of 2GiB") | _("%s: size of %d bytes exceeds maximum revlog storage of 2GiB") | ||||
% (self.indexfile, len(rawtext))) | % (self.indexfile, len(rawtext))) | ||||
node = node or self.hash(rawtext, p1, p2) | node = node or self.hash(rawtext, p1, p2) | ||||
if node in self.nodemap: | if node in self.nodemap: | ||||
return node | return node | ||||
if validatehash: | if validatehash: | ||||
# According to `hg perfrevlogchunks`, this is ~0.5% faster for zlib | # According to `hg perfrevlogchunks`, this is ~0.5% faster for zlib | ||||
# compressed chunks. And this matters for changelog and manifest reads. | # compressed chunks. And this matters for changelog and manifest reads. | ||||
t = data[0:1] | t = data[0:1] | ||||
if t == 'x': | if t == 'x': | ||||
try: | try: | ||||
return _zlibdecompress(data) | return _zlibdecompress(data) | ||||
except zlib.error as e: | except zlib.error as e: | ||||
raise RevlogError(_('revlog decompress error: %s') % | raise error.RevlogError(_('revlog decompress error: %s') % | ||||
stringutil.forcebytestr(e)) | stringutil.forcebytestr(e)) | ||||
# '\0' is more common than 'u' so it goes first. | # '\0' is more common than 'u' so it goes first. | ||||
elif t == '\0': | elif t == '\0': | ||||
return data | return data | ||||
elif t == 'u': | elif t == 'u': | ||||
return util.buffer(data, 1) | return util.buffer(data, 1) | ||||
try: | try: | ||||
compressor = self._decompressors[t] | compressor = self._decompressors[t] | ||||
except KeyError: | except KeyError: | ||||
try: | try: | ||||
engine = util.compengines.forrevlogheader(t) | engine = util.compengines.forrevlogheader(t) | ||||
compressor = engine.revlogcompressor() | compressor = engine.revlogcompressor() | ||||
self._decompressors[t] = compressor | self._decompressors[t] = compressor | ||||
except KeyError: | except KeyError: | ||||
raise RevlogError(_('unknown compression type %r') % t) | raise error.RevlogError(_('unknown compression type %r') % t) | ||||
return compressor.decompress(data) | return compressor.decompress(data) | ||||
def _addrevision(self, node, rawtext, transaction, link, p1, p2, flags, | def _addrevision(self, node, rawtext, transaction, link, p1, p2, flags, | ||||
cachedelta, ifh, dfh, alwayscache=False, | cachedelta, ifh, dfh, alwayscache=False, | ||||
deltacomputer=None): | deltacomputer=None): | ||||
"""internal function to add revisions to the log | """internal function to add revisions to the log | ||||
see addrevision for argument descriptions. | see addrevision for argument descriptions. | ||||
note: "addrevision" takes non-raw text, "_addrevision" takes raw text. | note: "addrevision" takes non-raw text, "_addrevision" takes raw text. | ||||
if "deltacomputer" is not provided or None, a defaultdeltacomputer will | if "deltacomputer" is not provided or None, a defaultdeltacomputer will | ||||
be used. | be used. | ||||
invariants: | invariants: | ||||
- rawtext is optional (can be None); if not set, cachedelta must be set. | - rawtext is optional (can be None); if not set, cachedelta must be set. | ||||
if both are set, they must correspond to each other. | if both are set, they must correspond to each other. | ||||
""" | """ | ||||
if node == nullid: | if node == nullid: | ||||
raise RevlogError(_("%s: attempt to add null revision") % | raise error.RevlogError(_("%s: attempt to add null revision") % | ||||
(self.indexfile)) | self.indexfile) | ||||
if node == wdirid or node in wdirfilenodeids: | if node == wdirid or node in wdirfilenodeids: | ||||
raise RevlogError(_("%s: attempt to add wdir revision") % | raise error.RevlogError(_("%s: attempt to add wdir revision") % | ||||
(self.indexfile)) | self.indexfile) | ||||
if self._inline: | if self._inline: | ||||
fh = ifh | fh = ifh | ||||
else: | else: | ||||
fh = dfh | fh = dfh | ||||
btext = [rawtext] | btext = [rawtext] | ||||
attr, | attr, | ||||
) | ) | ||||
from .. import ( | from .. import ( | ||||
error, | error, | ||||
mdiff, | mdiff, | ||||
) | ) | ||||
RevlogError = error.RevlogError | |||||
CensoredNodeError = error.CensoredNodeError | CensoredNodeError = error.CensoredNodeError | ||||
# maximum <delta-chain-data>/<revision-text-length> ratio | # maximum <delta-chain-data>/<revision-text-length> ratio | ||||
LIMIT_DELTA2TEXT = 2 | LIMIT_DELTA2TEXT = 2 | ||||
class _testrevlog(object): | class _testrevlog(object): | ||||
"""minimalist fake revlog to use in doctests""" | """minimalist fake revlog to use in doctests""" | ||||
fulltext = mdiff.patch(basetext, delta) | fulltext = mdiff.patch(basetext, delta) | ||||
try: | try: | ||||
res = revlog._processflags(fulltext, flags, 'read', raw=True) | res = revlog._processflags(fulltext, flags, 'read', raw=True) | ||||
fulltext, validatehash = res | fulltext, validatehash = res | ||||
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 RevlogError(_('node %s is not censored') % expectednode) | raise error.RevlogError(_('node %s is not censored') % expectednode) | ||||
except CensoredNodeError: | except CensoredNodeError: | ||||
# must pass the censored index flag to add censored revisions | # must pass the censored index flag to add censored revisions | ||||
if not flags & REVIDX_ISCENSORED: | if not flags & REVIDX_ISCENSORED: | ||||
raise | raise | ||||
return fulltext | return fulltext | ||||
@attr.s(slots=True, frozen=True) | @attr.s(slots=True, frozen=True) | ||||
class _deltainfo(object): | class _deltainfo(object): |
for flag in orderedflags: | for flag in orderedflags: | ||||
# If a flagprocessor has been registered for a known flag, apply the | # If a flagprocessor has been registered for a known flag, apply the | ||||
# related operation transform and update result tuple. | # related operation transform and update result tuple. | ||||
if flag & flags: | if flag & flags: | ||||
vhash = True | vhash = True | ||||
if flag not in revlog._flagprocessors: | if flag not in revlog._flagprocessors: | ||||
message = _("missing processor for flag '%#x'") % (flag) | message = _("missing processor for flag '%#x'") % (flag) | ||||
raise revlog.RevlogError(message) | raise error.RevlogError(message) | ||||
processor = revlog._flagprocessors[flag] | processor = revlog._flagprocessors[flag] | ||||
if processor is not None: | if processor is not None: | ||||
readtransform, writetransform, rawtransform = processor | readtransform, writetransform, rawtransform = processor | ||||
if raw: | if raw: | ||||
vhash = rawtransform(self, text) | vhash = rawtransform(self, text) | ||||
elif operation == 'read': | elif operation == 'read': |