Mercurial > hg
view doc/docchecker @ 43847:49fa0b31ee1d
cext-revlog: fixed __delitem__ for uninitialized nodetree
This is a bug in a code path that's seldom used, because in practice
(at least in the whole test suite), calls to `del index[i:j]` currently
just don't happen before the nodetree has been initialized.
However, in our current work to replace the nodetree by a Rust implementation,
this is of course systematic.
In `index_slice_del()`, if the slice start is smaller than `self->length`,
the whole of `self->added` has to be cleared.
Before this change, the clearing was done only by the call to
`index_invalidate_added(self, 0)`, that happens only for initialized
nodetrees. Hence the removal was effective only from `start` to `self->length`.
The consequence is index corruption, with bogus results in subsequent calls,
and in particular errors such as `ValueError("parent out of range")`, due to
the fact that parents of entries in `self->added` are now just invalid.
This is detected by the rebase tests, under conditions that the nodetree
of revlog.c is never initialized. The provided specific test is more direct.
Differential Revision: https://phab.mercurial-scm.org/D7603
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Thu, 05 Dec 2019 20:41:23 +0100 |
parents | 47ef023d0165 |
children | c102b704edb5 |
line wrap: on
line source
#!/usr/bin/env python # # docchecker - look for problematic markup # # Copyright 2016 timeless <timeless@mozdev.org> and others # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. from __future__ import absolute_import, print_function import os import re import sys try: import msvcrt msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) except ImportError: pass stdout = getattr(sys.stdout, 'buffer', sys.stdout) leadingline = re.compile(br'(^\s*)(\S.*)$') checks = [ ( br""":hg:`[^`]*'[^`]*`""", b"""warning: please avoid nesting ' in :hg:`...`""", ), (br'\w:hg:`', b'warning: please have a space before :hg:'), ( br"""(?:[^a-z][^'.])hg ([^,;"`]*'(?!hg)){2}""", b'''warning: please use " instead of ' for hg ... "..."''', ), ] def check(line): messages = [] for match, msg in checks: if re.search(match, line): messages.append(msg) if messages: stdout.write(b'%s\n' % line) for msg in messages: stdout.write(b'%s\n' % msg) def work(file): (llead, lline) = (b'', b'') for line in file: # this section unwraps lines match = leadingline.match(line) if not match: check(lline) (llead, lline) = (b'', b'') continue lead, line = match.group(1), match.group(2) if lead == llead: if lline != b'': lline += b' ' + line else: lline = line else: check(lline) (llead, lline) = (lead, line) check(lline) def main(): for f in sys.argv[1:]: try: with open(f, 'rb') as file: work(file) except BaseException as e: sys.stdout.write(r"failed to process %s: %s\n" % (f, e)) main()