statprof: with Python 3.12, lineno is (more) often None
test-profile.t failed with errors like:
TypeError: %d format: a real number is required, not NoneType
statprof.py already handled None values as -1 in some cases. Do the same in
more cases.
py3: fix for Python 3.12 emitting SyntaxWarning on invalid escape sequences
Mercurial became very noisy after https://github.com/python/cpython/commit/
a60ddd31be7ff96a8189e7483bf1eb2071d2bddf ,
for example:
$ python3.12 mercurial/store.py
mercurial/store.py:406: SyntaxWarning: invalid escape sequence '\.'
EXCLUDED = re.compile(b'.*undo\.[^/]+\.(nd?|i)$')
This verbosity made some tests fail.
The problems were mostly insufficiently escaped regexps, relying on the Python
parser/scanner preserving invalid escape sequences.
cext: fix for PyLong refactoring in CPython 3.12
Compiling Mercurial with Python 3.12 a5 would fail with:
mercurial/cext/dirs.c: In function '_addpath':
mercurial/cext/dirs.c:19:44: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
19 | #define PYLONG_VALUE(o) ((PyLongObject *)o)->ob_digit[0]
| ^~
mercurial/cext/dirs.c:97:25: note: in expansion of macro 'PYLONG_VALUE'
97 | PYLONG_VALUE(val) += 1;
| ^~~~~~~~~~~~
mercurial/cext/dirs.c:19:44: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
19 | #define PYLONG_VALUE(o) ((PyLongObject *)o)->ob_digit[0]
| ^~
mercurial/cext/dirs.c:108:17: note: in expansion of macro 'PYLONG_VALUE'
108 | PYLONG_VALUE(val) = 1;
| ^~~~~~~~~~~~
mercurial/cext/dirs.c: In function '_delpath':
mercurial/cext/dirs.c:19:44: error: 'PyLongObject' {aka 'struct _longobject'} has no member named 'ob_digit'
19 | #define PYLONG_VALUE(o) ((PyLongObject *)o)->ob_digit[0]
| ^~
mercurial/cext/dirs.c:145:23: note: in expansion of macro 'PYLONG_VALUE'
145 | if (--PYLONG_VALUE(val) <= 0) {
| ^~~~~~~~~~~~
This was caused by
https://github.com/python/cpython/commit/
c1b1f51cd1632f0b77dacd43092fb44ed5e053a9 .
histedit: fix diff colors
The problem here is that indexing a bytestring gives you integers, not
chars, so the comparison to b'+' ends up being wrong.
We don't really have a way to test curses output, so no tests to
verify the correctness of this behaviour.
dirstate: fix a potential traceback when in `copy` and `rename`
Before this changes, calling `hg copy` or `hg rename` could trigger a traceback
about using an invalidated dirstate. This wasn't caught by the test as it needed
the blackbox extension to preload the dirstate first in a way "refresh"
invalidates it.
Changing the context creation patterns fixes it.
dirstate: fix the bug in [status] dealing with committed&ignored directories
In particular, these directories can "infect" their sibling directories with
ignored status due to using a shared memoization cell by accident.
This fixes bug #6795.