curses: do not initialize LC_ALL to user settings (
issue6358)
701341f57ceb moved the setlocale() call to right before curses was used. This
didn’t fully solve the problem it was supposed to solve (locale-dependent
functions, like date formatting/parsing), but only postponed it.
Initializing LC_CTYPE seems to be sufficient for curses to work correctly.
Luckily this is already done at interpreter startup on modern Python versions
and, since recently, by Mercurial in the pycompat module in all other cases.
compat: initialize LC_CTYPE locale on all Python versions and platforms
Previously, the LC_CTYPE locale was not initialized according to user settings
on all Python versions (e.g. never on Python 2) and platforms (e.g. not on
some Python < 3.8 on Windows).
This broke e.g. non-ASCII filenames passed to the Subversion bindings on Python
2, resulting in error messages like "file:///tmp/a%C3%A4 does not look like a
Subversion repository to libsvn version 1.14.0".
The following command could be used to test this functionality. Adding it to the
test suite would be pointless, as the locale is always set to "C" during test
runs.
@command(b'check_initial_codeset', norepo=True)
def check_initial_codeset(ui):
codeset1 = locale.nl_langinfo(locale.CODESET)
locale.setlocale(locale.LC_ALL, '')
codeset2 = locale.nl_langinfo(locale.CODESET)
assert codeset1 == codeset2
merge: don't grab wlock when merging in memory
I noticed this because we have an internal extension that does an
in-memory rebase while holding only a repo lock, which resulted in a
developer warning about the working copy lock being taken after the
repo lock.
Differential Revision: https://phab.mercurial-scm.org/D8665
pycompat: use os.fsencode() to re-encode sys.argv
Historically, the previous code made sense, as Py_EncodeLocale() and
fs.fsencode() could possibly use different encodings. However, this is not the
case anymore for Python 3.2, which uses the locale encoding as the filesystem
encoding (this is not true for later Python versions, but see below). See
https://vstinner.github.io/painful-history-python-filesystem-encoding.html for
a source and more background information.
Using os.fsencode() is safer, as the documentation for sys.argv says that it can
be used to get the original bytes. When doing further changes, the Python
developers will take care that this continues to work.
One concrete case where os.fsencode() is more correct is when enabling Python's
UTF-8 mode. Py_DecodeLocale() will use UTF-8 in this case. Our previous code
would have encoded it using the locale encoding (which might be different),
whereas os.fsencode() will encode it with UTF-8.
Since we don’t claim to support the UTF-8 mode, this is not really a bug and the
patch can go to the default branch. It might be a good idea to not commit this
to the stable branch, as it could in theory introduce regressions.
perf: make `hg perfwrite` more flexible
The more flexible command was used recently while finding a solution for a
buffering bug (eventually fixed in
f9734b2d59cc (the changeset description uses
a different benchmark)).
In comparison to the previous version, the new version is much more flexible.
While using it, the focus was on testing small writes. For this reason, by
default it calls ui.write() 100 times with a single byte plus one newline byte,
for 100 lines.
To get the previous behavior, run `hg perfwrite --nlines=100000 --nitems=1
--item='Testing write performance' --batch-line`.
copies: implement __repr__ on branch_copies for debugging
Differential Revision: https://phab.mercurial-scm.org/D8650
phases: remove useless lookup of repo[rev].rev() in _retractboundary
changectx object is no longer needed thanks to
a54ee130210a.