Rodrigo Damazio Bovendorp <rdamazio@google.com> [Thu, 09 Jul 2020 20:46:52 -0700] rev 45074
fix: prefetch file contents
This prevents the worker subprocesses from contacting the server individually,
which is either inefficient, or leads to problems if the connection is shared
among them.
Differential Revision: https://phab.mercurial-scm.org/D8723
Rodrigo Damazio Bovendorp <rdamazio@google.com> [Thu, 09 Jul 2020 20:45:35 -0700] rev 45073
fix: obtain base paths before starting workers
This moves calculation of base paths to before work is dispatched.
While this does mean that copy tracing will be serialized instead of
parallel, it is necessary to be able to prefetch the base contents
in a batch, which will likely be more efficient.
Differential Revision: https://phab.mercurial-scm.org/D8722
Rodrigo Damazio Bovendorp <rdamazio@google.com> [Thu, 09 Jul 2020 18:48:55 -0700] rev 45072
scmutil: allowing different files to be prefetched per revision
The old API takes a list of revision separate from the file matcher, and thus
provides no way to fetch different sets of files from each revision. In
preparation for adding one such usage, I'm changing the API to take a list of
(revision, file matcher) tuples instead.
Differential Revision: https://phab.mercurial-scm.org/D8721
Pulkit Goyal <7895pulkit@gmail.com> [Sat, 11 Jul 2020 00:31:21 +0530] rev 45071
tests: update test-devel-warnings.t output with chg
Manuel Jacob <me@manueljacob.de> [Tue, 07 Jul 2020 11:10:07 +0200] rev 45070
tests: make names in test-stdio.py more distinctive
This way, more tests can be added without name clashes.
Manuel Jacob <me@manueljacob.de> [Tue, 07 Jul 2020 12:35:29 +0200] rev 45069
tests: terminate subprocess in test-stdio.py in case of exception
If an error happened while reading the output of the subprocess, the pipe / TTY
buffer can fill up and prevent that the subprocess ends. Therefore we should
terminate the subprocess in case of an exception.
Manuel Jacob <me@manueljacob.de> [Tue, 07 Jul 2020 11:06:37 +0200] rev 45068
tests: proof test-stdio.py against buffer fill-up
With the previous code, it could in theory happen that the pipe / PTY buffer of
the child stdout / stderr fills up and the process never finishes.
To prevent that, we read all of the stream before waiting for the end of the
process. To ensure that the stream reaches EOF when the child finishes, we must
close the parent "copy" of the child stdout / stderr.
Matt Harbison <matt_harbison@yahoo.com> [Thu, 09 Jul 2020 23:03:34 -0400] rev 45067
tests: stablize test-serve.t on Windows
I forget the reason that the subprocess on Windows doesn't print this, but all
other instances of this are similarly conditionalized, so I didn't think too
hard about it.
Also, the server needs to be killed so it doesn't prevent the next run from
working, especially since the port isn't randomized.
Differential Revision: https://phab.mercurial-scm.org/D8720
Pierre-Yves David <pierre-yves.david@octobus.net> [Mon, 06 Jul 2020 21:08:15 +0200] rev 45066
commitctx: document the manifest writing function
Same spirit as for `_filecommit` lets document the input and output before
making any change or improvement.
This is part of a larger refactoring/cleanup of the commitctx code to clarify
and augment the logic gathering metadata useful for copy tracing. The current
code is a tad too long and entangled to make such update easy. We start with
easy and small cleanup.
Differential Revision: https://phab.mercurial-scm.org/D8705
Pierre-Yves David <pierre-yves.david@octobus.net> [Mon, 06 Jul 2020 19:16:04 +0200] rev 45065
commitctx: reorder some conditional for efficiency in _filecommit
Checking if a dict is empty will be faster than comparing text. I don't expect
it to be a huge performance win, but still a good (but gratuitous) cleanup to
do while we are at it.
This is part of a larger refactoring/cleanup of the commitctx code to clarify
and augment the logic gathering metadata useful for copy tracing. The current
code is a tad too long and entangled to make such update easy. We start with
easy and small cleanup.
Differential Revision: https://phab.mercurial-scm.org/D8701
Pierre-Yves David <pierre-yves.david@octobus.net> [Mon, 06 Jul 2020 18:52:19 +0200] rev 45064
commitctx: document _filecommit input and output
This is the beginning of a larger refactoring/cleanup of the commitctx code to
clarify and augment the logic gathering metadata useful for copy tracing. The
current code is a tad too long and entangled to make such update easy. We start
with easy and small cleanup.
Differential Revision: https://phab.mercurial-scm.org/D8699
Joerg Sonnenberger <joerg@bec.de> [Tue, 07 Jul 2020 21:57:46 +0200] rev 45063
phases: replace magic number by constant
Differential Revision: https://phab.mercurial-scm.org/D8695
Joerg Sonnenberger <joerg@bec.de> [Mon, 22 Jun 2020 00:00:07 +0200] rev 45062
clonebundles: optional memory-requirement attribution
The new REQUIREDRAM option allows a client to skip bundles it isn't
expected to handle well, e.g. without swapping. This allows a fallback
path to be provided e.g. using zstd level 10 instead of 22.
Differential Revision: https://phab.mercurial-scm.org/D8645
Joerg Sonnenberger <joerg@bec.de> [Tue, 09 Jun 2020 11:22:31 +0200] rev 45061
util: provide a helper function to estimate RAM size
For POSIX systems, it uses sysconf. For Windows, it uses the win32 API
directly.
Differential Revision: https://phab.mercurial-scm.org/D8644
Joerg Sonnenberger <joerg@bec.de> [Thu, 02 Jul 2020 19:59:59 +0200] rev 45060
tests: allow timing difference in output
Differential Revision: https://phab.mercurial-scm.org/D8676
Pierre-Yves David <pierre-yves.david@octobus.net> [Mon, 22 Jun 2020 13:32:20 +0200] rev 45059
documentation: add some internals documentation about bid merge
This is an important algorithm that was only documented on the wiki so far.
Some update to the algorithm (and associated doc) is to expected in the future
since the bid merge algorithm is bug-ridden when it comes to file deletion comes
to play.
Differential Revision: https://phab.mercurial-scm.org/D8711
Yuya Nishihara <yuya@tcha.org> [Sun, 28 Jun 2020 17:32:32 +0900] rev 45058
cmdserver: document message-encodings and channel output options
While writing the previous patch, I noticed these options are undocumented.
In my testing, a separate status/error message channel works well in GUI
frontend as we no longer have to sort out data and message from mixed outputs.
So let's mark it as not experimental.
Yuya Nishihara <yuya@tcha.org> [Sat, 27 Jun 2020 21:46:23 +0900] rev 45057
cmdserver: add option to not exit from message loop on SIGINT
Sending SIGINT to server is the only way to interrupt a command running in
command-server process. SIGINT will be caught at dispatch.dispatch() if
we're lucky. Otherwise it will terminate the serer process. This is
fundamentally unreliable as signals are delivered asynchronously.
"cmdserver.shutdown-on-interrupt=False" mitigate the issue by making the
server basically block SIGINT.
Manuel Jacob <me@manueljacob.de> [Mon, 06 Jul 2020 17:51:18 +0200] rev 45056
pycompat: remove pycompat.{stdin,stdout,stderr}
All users have been changed to use procutil.{stdin,stdout,stderr}, which provide
consistent behavior across platforms and Python versions.
Manuel Jacob <me@manueljacob.de> [Mon, 06 Jul 2020 17:44:25 +0200] rev 45055
pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std*
On Python 3, pycompat.{stdin,stdout,stderr} are usually block-buffered even if
connected to a TTY. procutil.{stdin,stdout,stderr} provide consistent behavior
across platforms and Python versions.
Antoine Cezar <antoine.cezar@octobus.net> [Mon, 06 Jul 2020 10:30:55 +0200] rev 45054
hgignore: add mypy cache files
Differential Revision: https://phab.mercurial-scm.org/D8692
Joerg Sonnenberger <joerg@bec.de> [Mon, 06 Jul 2020 14:30:13 +0200] rev 45053
revlog: avoid hard-coded hash sizes
Differential Revision: https://phab.mercurial-scm.org/D8683
Pierre-Yves David <pierre-yves.david@octobus.net> [Fri, 03 Jul 2020 19:00:01 +0200] rev 45052
test: restore expected output in test-persistent-nodemap.t
The merge
78cafd48b9b2 had a small error and wrongly dropped the output updated
from one side of the merge.
This changeset re-install it.
Differential Revision: https://phab.mercurial-scm.org/D8678
Antoine Cezar <antoine.cezar@octobus.net> [Mon, 06 Jul 2020 09:30:26 +0200] rev 45051
heptapod-ci: build rhg before tests run
Differential Revision: https://phab.mercurial-scm.org/D8682
Antoine Cezar <antoine.cezar@octobus.net> [Tue, 07 Jul 2020 14:05:15 +0530] rev 45050
rhg: add a limited `rhg root` subcommand
Clap has been choosen for argument parsing for the following reasons:
- it's a wildly used and maintained crate
- it can deal with OS encoding making it suitable for any encoding
- it supports nonambiguous prefix matching as already available in hg
- it will soon allow for structopts-style declarative pattern instead of the
currently used builder pattern
Differential Revision: https://phab.mercurial-scm.org/D8613
Antoine Cezar <antoine.cezar@octobus.net> [Fri, 05 Jun 2020 09:01:35 +0200] rev 45049
rhg: add RootCommand using hg-core FindRoot operation to prepare `hg root`
The println macro is not used to avoid string usage.
Dealing only with bytes allows us to be compatible with any encoding
and not just UTF8.
Later on, format macro will be made to have more readable code.
Differential Revision: https://phab.mercurial-scm.org/D8612
Manuel Jacob <me@manueljacob.de> [Wed, 08 Jul 2020 08:57:21 +0200] rev 45048
archival: abort if compression method is unavailable
`tarfile.CompressionError` is documented to be the "exception for unavailable
compression methods".
Also, make tests conditional on whether the lzma module is available or not.
Manuel Jacob <me@manueljacob.de> [Wed, 08 Jul 2020 08:25:30 +0200] rev 45047
demandimport: ignore `lzma` module for demandimport
This makes importing the module fail if the `_lzma` module is not present.
This makes e.g. tarfile correctly recognize if LZMA support is not present. It
changes the exception
File "/usr/lib/python3.6/tarfile.py", line 1694, in xzopen
fileobj = lzma.LZMAFile(fileobj or name, mode, preset=preset)
AttributeError: module 'lzma' has no attribute 'LZMAFile'
to the more correct exception
File "/usr/lib/python3.6/tarfile.py", line 1692, in xzopen
raise CompressionError("lzma module is not available")
tarfile.CompressionError: lzma module is not available
Also, it prevents that the error "abort: No module named '_lzma'!" is shown when
a development warning is to be shown. The reason why that happened is that for
showing the warning, we get information about the stack frames from the inspect
module, which accesses the `__file__` attribute of all modules in `sys.modules`
to build some cache, causing all modules (including `lzma`) to be imported.
Augie Fackler <augie@google.com> [Mon, 06 Jul 2020 22:02:50 -0400] rev 45046
merge with stable
Manuel Jacob <me@manueljacob.de> [Sun, 05 Jul 2020 13:09:22 +0200] rev 45045
procutil: make mercurial.utils.procutil.stderr unbuffered
For most Mercurial code, it doesn’t make a difference, as the ui object flushes
stderr explicitly (after the change, we could get rid of the explicit flush).
One example where it makes a observable difference is mercurial.util.timed().
Without the patch, the time is not immediately shown on Python 3. With the
patch, it’s shown immediately on all Python versions and platforms.
Manuel Jacob <me@manueljacob.de> [Sun, 05 Jul 2020 13:05:06 +0200] rev 45044
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de> [Sat, 04 Jul 2020 11:41:39 +0200] rev 45043
procutil: make stdout line-buffered on Windows if connected to TTY
Windows doesn’t support line buffering. Previously, we worked around that by
setting the stream unbuffered. Instead, we can use our own line buffering we
already use on Python 3.
Manuel Jacob <me@manueljacob.de> [Sat, 04 Jul 2020 11:21:44 +0200] rev 45042
procutil: split import and reassignment
Besides making the code clearer, it will reduce the diff in the next patch.
Manuel Jacob <me@manueljacob.de> [Sat, 04 Jul 2020 11:15:58 +0200] rev 45041
procutil: move assignments closer to reassignments
Doing reassignments is an anti-pattern IMHO, but I see how it makes sense here.
When first looking at this code after jumping here with ctags, I missed the
fact that stdout was reassigned. To make the code clearer, the assignments
should be as close as possible to the reassignments.
Manuel Jacob <me@manueljacob.de> [Sat, 04 Jul 2020 12:15:41 +0200] rev 45040
procutil: factor out conditional creation of LineBufferedWrapper
At the same time, document the logic and generalize it to work on all Python
versions.
Manuel Jacob <me@manueljacob.de> [Thu, 02 Jul 2020 04:37:18 +0200] rev 45039
procutil: define LineBufferedWrapper on all Python versions
There’s nothing Python 3-only about LineBufferedWrapper. In the future, we may
want to use it on Windows, to work around missing line-buffering support.
Manuel Jacob <me@manueljacob.de> [Sat, 04 Jul 2020 10:47:04 +0200] rev 45038
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de> [Thu, 02 Jul 2020 02:51:09 +0200] rev 45037
cleanup: use slightly more meaningful name for temporary variable
Not that it makes a big difference, but using `p` instead of `x` is clearer to
me.
Manuel Jacob <me@manueljacob.de> [Thu, 02 Jul 2020 02:46:15 +0200] rev 45036
cleanup: use any() instead of checking truthiness of temporary list
It was not immediately obvious to me, when first seeing this, why a list was
created. It needed a second look to understand that the purpose was to check
whether the condition is true for any of the parents. Using any() for that is
clearer.
Pulkit Goyal <7895pulkit@gmail.com> [Fri, 03 Jul 2020 13:45:59 +0530] rev 45035
chg: suppress OSError in _restoreio() and add some logging (
issue6330)
According to
issue6330, running chg on heavy loaded systems can lead to
following error:
```
Traceback (most recent call last):
File "path-to-hg/mercurial/commandserver.py", line 650, in _acceptnewconnection
self._runworker(conn)
File "path-to-hg/mercurial/commandserver.py", line 701, in _runworker
prereposetups=[self._reposetup],
File "path-to-hg/mercurial/commandserver.py", line 470, in _serverequest
sv.cleanup()
File "path-to-hg/mercurial/chgserver.py", line 381, in cleanup
self._restoreio()
File "path-to-hg/mercurial/chgserver.py", line 444, in _restoreio
os.dup2(fd, fp.fileno())
OSError: [Errno 16] Device or resource busy
```
[man dup2] indicates that, on Linux, EBUSY comes from a race condition
between open() and dup2().
However it's not clear why open() race occurred for newfd=stdin/out/err.
We suppress the OSError in _restoreio() since the forked worker process will
finish anyway and add some logging.
Thanks to Mitchell Plamann for a detailed bug description and Yuya Nishihara for
suggesting the fix.
Manuel Jacob <me@manueljacob.de> [Fri, 03 Jul 2020 23:25:19 +0200] rev 45034
py3: fix crash when server address is 0.0.0.0 (
issue6362)
`socket.getfqdn()` assumes that the name is passed as `str` on Python 3 and
always returns `str` in this case. Mercurial passed `bytes` (but still expected
a `str` result), which worked by chance in many cases, except for e.g.
b'0.0.0.0', which was returned unchanged, breaking later code.
Instead of calling `socket.getfqdn()`, we can also use `self.server_name` from
the base `HTTPServer` class, which already stores the FQDN of the locally-bound
socket name (see `BaseHTTPServer.py` in the Python 2 stdlib and
`http/server.py` in the Python 3 stdlib).
Joerg Sonnenberger <joerg@bec.de> [Thu, 02 Jul 2020 19:54:44 +0200] rev 45033
ui: fix Python 2.7 support for ui.timestamp-output
Differential Revision: https://phab.mercurial-scm.org/D8675
Augie Fackler <augie@google.com> [Wed, 01 Jul 2020 14:28:12 -0400] rev 45032
merge with stable
Axel Hecht <axel@pike.org> [Wed, 01 Jul 2020 15:43:15 +0200] rev 45031
run-tests: find python binary on Python 3 (
issue6361)
Return strings from _findprogram as all callers expect
unicode strings.
Previously the check in _usecorrectpython agains sysexecutable
was always false on Python 3.
Differential Revision: https://phab.mercurial-scm.org/D8674
Joerg Sonnenberger <joerg@bec.de> [Mon, 29 Jun 2020 16:36:53 +0200] rev 45030
tests: ignore possible diagnostics from gpg 2.2
Differential Revision: https://phab.mercurial-scm.org/D8672
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 01 Jul 2020 23:30:47 +0530] rev 45029
Added signature for changeset
0ea9c86fac89
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 01 Jul 2020 23:30:39 +0530] rev 45028
Added tag 5.4.2 for changeset
0ea9c86fac89
Manuel Jacob <me@manueljacob.de> [Tue, 30 Jun 2020 07:23:29 +0200] rev 45027
convert: handle percent-encoded bytes in file URLs like Subversion
75b59d221aa3 added most of the code that gets removed by this patch. It helped
making progress on Python 3, but the reasoning was wrong in many ways. I tried
to retract it while it was queued, but it was too late.
Back then, I was asssuming that what happened on Python 2 (preserving bytes) is
correct and my Python 3 change is a hack. However it turned out that Subversion
interprets percent-encoded bytes as UTF-8. Accepting the same format as
Subversion is a good idea.
Consistency with urlreq.pathname2url() (as described in the removed comment)
doesn’t matter because that function is only used for passing paths to urllib.
This is not a backwards-incompatible change because before
5c0d5b48e58c,
non-ASCII filenames didn’t work at all on Python 2.
When the locale encoding is ISO-8859-15, `svn` accepts `file:///tmp/a%E2%82%AC`
for `/tmp/a€`. Before this patch, this was the case for this extension on
Python 3, but not on Python 2. This patch makes it work like with `svn` on both
Python 2 and Python 3.
Manuel Jacob <me@manueljacob.de> [Tue, 30 Jun 2020 16:39:45 +0200] rev 45026
convert: add docstring on convert.subversion.geturl()
The function is unusual for a bytes-handling function in Mercurial because it
can’t handle arbitrary bytes. Therefore we should document this fact.
Pointed out by Yuya Nishihara while reviewing
e3b19004087a.
Joerg Sonnenberger <joerg@bec.de> [Thu, 18 Jun 2020 15:13:38 +0200] rev 45025
ui: add option to timestamp status and diagnostic messages
Differential Revision: https://phab.mercurial-scm.org/D8640
Manuel Jacob <me@manueljacob.de> [Tue, 30 Jun 2020 01:32:17 +0200] rev 45024
tests: use path inside test dir
This will make the diff for the next patch less noisy.
Manuel Jacob <me@manueljacob.de> [Tue, 30 Jun 2020 05:30:47 +0200] rev 45023
convert: convert URLs to UTF-8 for Subversion
Preamble: for comprehension, note that the `path` of geturl() would better be
called `path_or_url` (the argument of the call of getsvn() is called `url`).
For HTTP(S) URLs, the changes don’t make a difference, as they are restricted to
ASCII.
For file URLs, the reasoning is the same as for paths: we have to roundtrip with
what Subversion is doing.
When the locale encoding is ISO-8859-15, trying to convert a SVN repo
`file:///tmp/a€` failed before like this:
file:///tmp/a%A4 does not look like a Subversion repository to libsvn version 1.14.0
Decoding the path using the locale encoding can fail. In this case, we have to
bail out, as Subversion won’t be able to do anything useful with the path.
Manuel Jacob <me@manueljacob.de> [Mon, 29 Jun 2020 15:03:36 +0200] rev 45022
convert: correctly convert paths to UTF-8 for Subversion
The previous code using encoding.tolocal() only worked by chance in these
situations:
* The string is ASCII: The fast path was triggered and the string was returned
unmodified.
* The local encoding is UTF-8: The source and target encoding is the same.
* The string is not valid UTF-8 and the native encoding is ISO-8859-1: If the
string doesn’t decode using UTF-8, ISO-8859-1 is tried as a fallback. During
`hg convert`, the local encoding is always UTF-8. The irony is that in this
case, encoding.tolocal() behaves like what someone would expect the reverse
function, encoding.fromlocal(), to do.
When the locale encoding is ISO-8859-15, trying to convert a SVN repo `/tmp/a€`
failed before like this:
file:///tmp/a%C2%A4 does not look like a Subversion repository to libsvn version 1.14.0
The correct URL is `file:///tmp/a%E2%82%AC`.
Unlike previously (with the ISO-8859-1 fallback), decoding the path using the
locale encoding can fail. In this case, we have to bail out, as Subversion
won’t be able to do anything useful with the path.
Manuel Jacob <me@manueljacob.de> [Tue, 30 Jun 2020 05:04:36 +0200] rev 45021
py3: pass URL as str
Before the patch, HTTP(S) URLs were never recognized as a Subversion repository
on Python 3.
Manuel Jacob <me@manueljacob.de> [Tue, 30 Jun 2020 04:55:52 +0200] rev 45020
convert: bail out in Subversion source if encountering non-ASCII HTTP(S) URL
Before this patch, in the tested case, urllib raised `httplib.InvalidURL: URL
can't contain control characters. '/\xff/!svn/ver/0/.svn' (found at least
'\xff')`, which resulted in that the URL was never recognized as a Subversion
repository.
This patch adds a check that bails out if the URL contains non-ASCII characters.
The warning is not overly user-friendly, but giving the user something to type
into a search engine is definitively better than not explaining why the
repository was not recognized.
We could support non-ASCII chracters by quoting them before passing them to
urllib. However, we would want to be compatible with what the `svn` command
does, which converts the URL from the locale encoding to UTF-8, percent-encodes
it and sends it to the server. If the locale encoding is not UTF-8, the
behavior is IMHO not very intuitive, as the `svn` command may send different
(percent-encoded) octets than what was passed on the console. Instead of
copying this behavior, we better leave it forbidden.
Yuya Nishihara <yuya@tcha.org> [Mon, 29 Jun 2020 20:53:32 +0900] rev 45019
merge with stable
Manuel Jacob <me@manueljacob.de> [Sun, 28 Jun 2020 17:52:29 +0200] rev 45018
compat: back out
a25343d16ebe (initialize LC_CTYPE locale on all Python ...)
As Yuya Nishihara pointed out, setting LC_CTYPE changes the behavior of some
str methods on Python 2.
Manuel Jacob <me@manueljacob.de> [Sun, 28 Jun 2020 17:49:14 +0200] rev 45017
curses: back out
d2227d4c9e6b (do not initialize LC_ALL to user settings)
The changeset was based on
a25343d16ebe, which will be backed out, too.
Another fix for the problem will be resubmitted to the stable branch.
Julien Cristau <jcristau@debian.org> [Thu, 25 Jun 2020 11:22:34 +0200] rev 45016
test: redirect stderr so warning messages don't change output (
issue6237)
clone and commit race for the lock, and if commit has to wait more than
a second it prints a warning to stderr. Since this is somewhat expected
here, silence it.
Differential Revision: https://phab.mercurial-scm.org/D8664
Martin von Zweigbergk <martinvonz@google.com> [Thu, 25 Jun 2020 12:02:34 -0700] rev 45015
locks: expect repo lock, not wlock, when writing to .hg/strip-backup/
There should be no need for a working copy lock when creating (or
reading) bundles in `.hg/strip-backup/` since they don't affect the
working copy.
I noticed this because we have an extension that tries to strip some
revisions while holding only a repo lock. I guess we have no such
cases in core, which seems a bit surprising. Maybe we always take a
wlock at a higher level so the working copy is not updated while the
target commit is being stripped.
Differential Revision: https://phab.mercurial-scm.org/D8666