Joerg Sonnenberger <joerg@bec.de> [Sat, 07 Nov 2020 22:31:29 +0100] rev 45872
transaction: split new files into a separate set
Journal entries with size 0 are common as they represent new revlog
files. Move them from the dictionary into a set as the former is more
dense. This reduces peak RSS by 70MB for the NetBSD test repository with
around 450k files under .hg/store.
Differential Revision: https://phab.mercurial-scm.org/D9278
Joerg Sonnenberger <joerg@bec.de> [Sat, 07 Nov 2020 21:34:09 +0100] rev 45871
transaction: change list of journal entries into a dictionary
The transaction object used to keep a mapping table of path names to
journal entries and a list of journal entries consisting of path and
file offset to truncate on rollback. The offsets are used in three
cases. repair.strip and rollback process all of them in one go, but they
care about the order. For them, it is perfectly reasonable to read the
journal back from disk as both operations already involve at least one
system call per journal entry. The other consumer is the revlog logic
for moving from inline to external data storage. It doesn't care about
the order of the journal and just needs to original offset stored.
Further optimisations are possible here to move the in-memory journal to
a set(), but without memoisation of the original revlog size this could
turn it into O(n^2) behavior in worst case when many revlogs need to
migrated.
Differential Revision: https://phab.mercurial-scm.org/D9277
Joerg Sonnenberger <joerg@bec.de> [Sat, 07 Nov 2020 19:24:12 +0100] rev 45870
transaction: rename find to findoffset and drop backup file support
transaction.find used to support access to both the regular file and
backup file list. They have different formats, so any consumer has to be
aware of the difference alredy. There is no in-core consumer for the
backup file access, so don't provide it.
Differential Revision: https://phab.mercurial-scm.org/D9276
Joerg Sonnenberger <joerg@bec.de> [Sat, 07 Nov 2020 17:56:01 +0100] rev 45869
transaction: drop per-file extra data support
At the moment, transactions support an optional extra data argument for
all files to be stored in addition to the original offset. This is used
in core only by the revlog inline to external data migration. It is used
to memoize the number of revisions before the transaction. That number
of can be computed during the walk easily, so drop the requirement.
Differential Revision: https://phab.mercurial-scm.org/D9275
Martin von Zweigbergk <martinvonz@google.com> [Thu, 12 Nov 2020 14:07:34 -0800] rev 45868
templates: define a {onelinesummary} keyword
It is sometimes useful to be able to use the configured
`command-template.oneline-summary` in higher-level templates. For
example, I would like to use it in an internal template that lists
commits in a "review unit" (kind of a pull request). This patch adds
support for that.
We may want to define a way of formatting a context using a
command-specific override (from
`command-templates.oneline-summary.<command>`), but that will have to
be a template function instead. I don't plan to do that, but I'm
mentioning it now in case reviewers would prefer that we use a no-arg
function (i.e. `{onelinesummary()}`) already today to prepare for
that.
Differential Revision: https://phab.mercurial-scm.org/D9314
Martin von Zweigbergk <martinvonz@google.com> [Fri, 30 Oct 2020 12:46:38 -0700] rev 45867
relnotes: document new [command-templates] section
Differential Revision: https://phab.mercurial-scm.org/D9266
Martin von Zweigbergk <martinvonz@google.com> [Fri, 30 Oct 2020 13:26:18 -0700] rev 45866
help: document the new [command-templates] config section
Differential Revision: https://phab.mercurial-scm.org/D9265
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com> [Sun, 08 Nov 2020 16:23:35 -0500] rev 45865
strip: move into core
As discussed at the 5.2 sprint, replace strip extension by a core
command, debugstrip. Obviously, the extension stays for backwards
compatibility.
As an implementation note, I moved the strip file as is into core,
which is not done elsewhere, AFAIK. I could have inlined it into
debugcommands, but that doesn't sound great.
Differential Revision: https://phab.mercurial-scm.org/D9285
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 07 Nov 2020 16:36:19 -0800] rev 45864
revlog: pass sidedata argument to flagutil.processflagswrite()
Bug found through pytype.
Differential Revision: https://phab.mercurial-scm.org/D9280
Gregory Szorc <gregory.szorc@gmail.com> [Sat, 07 Nov 2020 16:45:58 -0800] rev 45863
pure: guard against empty blocks
If blocks is empty, we append `None` to the returned list, which is
incorrect.
This subtle issue was caught by pytype, which correctly identified
the return value as List[Optional[Tuple]] because of this possibility.
Differential Revision: https://phab.mercurial-scm.org/D9279
Raphaël Gomès <rgomes@octobus.net> [Mon, 16 Nov 2020 16:38:57 +0100] rev 45862
rust-status: don't bubble up os errors, translate them to bad matches
In the rare cases when either the OS/filesystem throws an error on an otherwise
valid action, or because a path is not representable on the filesystem, or
because of concurrent actions in the filesystem, we want to warn the user about
said path instead of bubbling up the error, causing an exception to be raised
in the Python layer.
Differential Revision: https://phab.mercurial-scm.org/D9320
Raphaël Gomès <rgomes@octobus.net> [Mon, 16 Nov 2020 16:36:00 +0100] rev 45861
rust-status: properly translate OSError to Python
This is probably never going to be called after the next few patches, but we
might as well make sure this is done correctly for the future rewrite.
Differential Revision: https://phab.mercurial-scm.org/D9319
Martin von Zweigbergk <martinvonz@google.com> [Mon, 16 Nov 2020 21:28:42 -0800] rev 45860
shelve: clear merge state after partial shelve
Differential Revision: https://phab.mercurial-scm.org/D9335
Martin von Zweigbergk <martinvonz@google.com> [Mon, 16 Nov 2020 22:38:36 -0800] rev 45859
tests: show that interactive shelve can leave the repo with a merge state
If part of a file is shelved (as we already do in a test), there will
be an unfinished merge state left after `hg shelve` finishes. There
should never be a merge conflict and there should never be a reason
that the user would like to re-resolve conflicts, so we should clear
that state (see next patch).
Differential Revision: https://phab.mercurial-scm.org/D9334
Martin von Zweigbergk <martinvonz@google.com> [Mon, 16 Nov 2020 10:30:53 -0800] rev 45858
histedit: disable color while rendering template for use in plan
Differential Revision: https://phab.mercurial-scm.org/D9324
Martin von Zweigbergk <martinvonz@google.com> [Mon, 16 Nov 2020 10:30:06 -0800] rev 45857
tests: show how `hg histedit` can put color codes in histedit plan
Differential Revision: https://phab.mercurial-scm.org/D9323
Martin von Zweigbergk <martinvonz@google.com> [Fri, 13 Nov 2020 09:41:49 -0800] rev 45856
split: disable color while rendering template for use in commit message
Differential Revision: https://phab.mercurial-scm.org/D9322
Martin von Zweigbergk <martinvonz@google.com> [Thu, 12 Nov 2020 17:06:45 -0800] rev 45855
tests: show how `hg split` can put color codes in commit template
With D9255, I made it so `hg split` respects the
`commmand-templates.oneline-summary` config. I don't think I realized
that the output I modified was being put in a commit message
template. The result was that if you have coloring enabled, you get
colors in the commit template. This patch show that. The test is
unfortunately pretty verbose (like most other `hg split` tests) and
shows a bunch of irrelevant "color codes" (templater labels).
Differential Revision: https://phab.mercurial-scm.org/D9321
Martin von Zweigbergk <martinvonz@google.com> [Mon, 16 Nov 2020 16:00:13 -0800] rev 45854
dispatch: move some helper functions down into scmutil
I plan to reuse `formatparse()` in the next patch.
Differential Revision: https://phab.mercurial-scm.org/D9331
Martin von Zweigbergk <martinvonz@google.com> [Mon, 16 Nov 2020 15:11:51 -0800] rev 45853
errors: raise more specific errors from rewriteutil
Differential Revision: https://phab.mercurial-scm.org/D9330
Yuya Nishihara <yuya@tcha.org> [Tue, 17 Nov 2020 19:29:08 +0900] rev 45852
chgserver: backport py3 buffered I/O workarounds from procutil
I've recently switched to new machine and I found chg's stdout is fully
buffered.
Even though chg server is a daemon process, it inherits the environment
where the chg client originally forked the server. This means the server's
stdout might have been wrapped by LineBufferedWrapper. That's why we need
to do wrap/unwrap in both ways.
The "if" condition in _restoreio() looks weird, but I'm not willing to
clean things up because stdio behavior is fundamentally different between
py2 and py3, and py2 support will be dropped anyway.
Yuya Nishihara <yuya@tcha.org> [Tue, 03 Nov 2020 11:24:21 +0900] rev 45851
chg: reset errno prior to calling strtol()
Otherwise we can't figure out if the last strtol() invocation failed or
not.
Yuya Nishihara <yuya@tcha.org> [Tue, 03 Nov 2020 11:15:50 +0900] rev 45850
chg: do not close dir fd while iterating
It works so long as the dp is the last entry, but readdir(dp) would fail
with EBADF. Let's not do that and close the dir fd explicitly.
Yuya Nishihara <yuya@tcha.org> [Tue, 03 Nov 2020 11:12:25 +0900] rev 45849
chg: show debug message for each fd to be closed
It helps debugging. The number of file descriptors should be small in most
cases, so the console output wouldn't get bloated even with CHG_DEBUG=1.
Yuya Nishihara <yuya@tcha.org> [Tue, 03 Nov 2020 11:06:15 +0900] rev 45848
chg: apply clang-format
Martin von Zweigbergk <martinvonz@google.com> [Thu, 12 Nov 2020 15:28:06 -0800] rev 45847
errors: use InputError for some errors on `hg clone`
Differential Revision: https://phab.mercurial-scm.org/D9329
Martin von Zweigbergk <martinvonz@google.com> [Thu, 12 Nov 2020 13:22:40 -0800] rev 45846
errors: raise InputError when given non-existent paths etc
Differential Revision: https://phab.mercurial-scm.org/D9328
Martin von Zweigbergk <martinvonz@google.com> [Thu, 12 Nov 2020 10:35:33 -0800] rev 45845
errors: use InputError for errors about bad label names (tags etc)
Differential Revision: https://phab.mercurial-scm.org/D9327
Martin von Zweigbergk <martinvonz@google.com> [Thu, 12 Nov 2020 09:53:14 -0800] rev 45844
errors: use InputError for errors about bad paths
Differential Revision: https://phab.mercurial-scm.org/D9326
Martin von Zweigbergk <martinvonz@google.com> [Tue, 10 Nov 2020 09:14:01 -0800] rev 45843
destutil: raise more specific error when histedit.defaultrev is empty
Differential Revision: https://phab.mercurial-scm.org/D9313
Martin von Zweigbergk <martinvonz@google.com> [Tue, 20 Oct 2020 08:56:00 -0700] rev 45842
errors: raise more specific errors when default remote not configured
Differential Revision: https://phab.mercurial-scm.org/D9312
Martin von Zweigbergk <martinvonz@google.com> [Thu, 22 Oct 2020 13:56:01 -0700] rev 45841
errors: set detailed exit code to 30 for config errors
This is per https://www.mercurial-scm.org/wiki/ErrorCategoriesPlan.
Differential Revision: https://phab.mercurial-scm.org/D9311
Martin von Zweigbergk <martinvonz@google.com> [Mon, 12 Oct 2020 12:44:18 -0700] rev 45840
errors: introduce StateError and use it from commands and cmdutil
This very similar to an earlier patch (which was for `InputError`).
In this patch, I also updated the transplant extension only because
`test-transplant.t` would otherwise have needed a `#if continueflag`.
Differential Revision: https://phab.mercurial-scm.org/D9310
Martin von Zweigbergk <martinvonz@google.com> [Thu, 22 Oct 2020 13:31:34 -0700] rev 45839
errors: set detailed exit code to 100 for some remote errors
This is per https://www.mercurial-scm.org/wiki/ErrorCategoriesPlan.
Differential Revision: https://phab.mercurial-scm.org/D9309
Martin von Zweigbergk <martinvonz@google.com> [Thu, 12 Nov 2020 21:56:52 -0800] rev 45838
errors: catch urllib errors specifically instead of using safehasattr()
Before this patch, we would catch `IOError` and `OSError` and check if
the instance had a `.code` member (indicates `HTTPError`) or a
`.reason` member (indicates the more generic `URLError`). It seems to
me that can simply catch those exception specifically instead, so
that's what this code does. The existing code is from
fbe8834923c5
(commands: report http exceptions nicely, 2005-06-17), so I suspect
it's just that there was no `urllib2` (where `URLError` lives) back
then.
The old code mentioned `SSLError` in a comment. The new code does
*not* try to catch that. The documentation for `ssl.SSLError` says
that it has a `.reason` property, but `python -c 'import ssl;
print(dir(ssl.SSLError("foo", Exception("bar"))))` doesn't mention
that property on either Python 2 or Python 3 on my system. It also
seems that `sslutil` is pretty careful about converting `ssl.SSLError`
to `error.Abort`. It also is carefult to not assume that instances of
the exception have a `.reason`. So I at least don't want to catch
`ssl.SSLError` and handle it the same way as `URLError` because that
would likely result in a crash. I also wonder if we don't need to
handle it at all (because `sslutil` might handle all the cases). It's
now early in the release cycle, so perhaps we can just see how it
goes?
Differential Revision: https://phab.mercurial-scm.org/D9318
Martin von Zweigbergk <martinvonz@google.com> [Thu, 12 Nov 2020 08:29:55 -0800] rev 45837
errors: raise InputError in fancyopts
If a value of wrong type is passed to a command line flag, that's
cleary an InputError.
Differential Revision: https://phab.mercurial-scm.org/D9308
Mathias De Mare <mathias.de_mare@nokia.com> [Fri, 06 Nov 2020 17:32:23 +0100] rev 45836
packaging: switch centos 7 packaging to python 3
Differential Revision: https://phab.mercurial-scm.org/D9293
Mathias De Mare <mathias.de_mare@nokia.com> [Fri, 06 Nov 2020 11:24:54 +0100] rev 45835
packaging: remove centos5 and centos6 support
Differential Revision: https://phab.mercurial-scm.org/D9292
Mathias De Mare <mathias.de_mare@nokia.com> [Wed, 11 Nov 2020 22:01:45 +0100] rev 45834
test-filecache: use sys.executable to call python
As was mentioned in
c102b704edb5, test scripts calling 'python' or 'python3'
might use the wrong python.
For test-filecache.py, this causes a failed test on CentOS 7.
Differential Revision: https://phab.mercurial-scm.org/D9295
Augie Fackler <augie@google.com> [Tue, 01 Sep 2020 11:03:47 -0400] rev 45833
make: add a pyoxidizer target
Differential Revision: https://phab.mercurial-scm.org/D9291
Augie Fackler <augie@google.com> [Tue, 10 Nov 2020 12:44:15 -0500] rev 45832
pyoxidizer: switch to modern config using run_command instead of run_mode
Differential Revision: https://phab.mercurial-scm.org/D9290
Augie Fackler <augie@google.com> [Tue, 03 Nov 2020 16:25:33 -0500] rev 45831
pyoxidizer: default to one-file binary on non-Windows platforms
Windows has some extra constraints that require a multi-file install,
but we expect folks to use an MSI or similar installer there so it's
less of a big deal.
Differential Revision: https://phab.mercurial-scm.org/D9289
Gregory Szorc <gregory.szorc@gmail.com> [Fri, 06 Nov 2020 13:58:59 -0800] rev 45830
global: use python3 in shebangs
Python 3 is the future. We want Python scripts to be using Python 3
by default.
This change updates all `#!/usr/bin/env python` shebangs to use
`python3`.
Does this mean all scripts use or require Python 3: no.
In the test environment, the `PATH` environment variable in tests is
updated to guarantee that the Python executable used to run
run-tests.py is used. Since test scripts all now use
`#!/usr/bin/env python3`, we had to update this code to install
a `python3` symlink instead of `python`.
It is possible there are some random scripts now executed with the
incorrect Python interpreter in some contexts. However, I would argue
that this was a pre-existing bug: we should almost always be executing
new Python processes using the `sys.executable` from the originating
Python script, as `python` or `python3` won't guarantee we'll use the
same interpreter.
Differential Revision: https://phab.mercurial-scm.org/D9273
Martin von Zweigbergk <martinvonz@google.com> [Mon, 09 Nov 2020 09:58:44 -0800] rev 45829
tests: use python from environment in test-parseindex2.py
Without this, the test starts failing with D9273 (the change to
`pyexename` to be specific).
Differential Revision: https://phab.mercurial-scm.org/D9286
Martin von Zweigbergk <martinvonz@google.com> [Thu, 22 Oct 2020 13:38:14 -0700] rev 45828
errors: set detailed exit code to 20 for locking errors
This is per https://www.mercurial-scm.org/wiki/ErrorCategoriesPlan.
Differential Revision: https://phab.mercurial-scm.org/D9242
Martin von Zweigbergk <martinvonz@google.com> [Tue, 06 Oct 2020 22:36:15 -0700] rev 45827
errors: introduce InputError and use it from commands and cmdutil
This patch introduces a `InputError` class and replaces many uses of
`error.Abort` by it in `commands` and `cmdutil`. This is a part of
https://www.mercurial-scm.org/wiki/ErrorCategoriesPlan. There will
later be a different class for state errors (to raise e.g. when
there's an unfinished operation). It's not always clear when one
should report an input error and when it should be a state error. We
can always adjust later if I got something wrong in this patch (but
feel free to point out any you notice now).
Differential Revision: https://phab.mercurial-scm.org/D9167
Martin von Zweigbergk <martinvonz@google.com> [Wed, 21 Oct 2020 19:00:16 -0700] rev 45826
errors: add config that lets user get more detailed exit codes
This adds an experimental config that lets the user get more detailed
exit codes. For example, there will be a specific error code for
input/user errors. This is part of
https://www.mercurial-scm.org/wiki/ErrorCategoriesPlan. I've made the
config part of tweakdefaults.
I've made the config enabled by default in tests. My reasoning is that
we want to see that each specific error case gives the right exit code
and we don't want to duplicate all error cases in the entire test
suite. It also makes it easy to grep the `.t` files for `[255]` to
find which cases we have left to fix. The logic for the current exit
codes is quite simple, so I'm not too worried about regressions
there. I've added a test case specifically for the "legacy" exit
codes.
I've set the detailed exit status only for the case of
`InterventionRequired` and `SystemExit` for now (the cases where we
currently return something other than 255), just to show that it
works.
Differential Revision: https://phab.mercurial-scm.org/D9238
Martin von Zweigbergk <martinvonz@google.com> [Sat, 07 Nov 2020 21:50:28 -0800] rev 45825
worker: raise exception instead of calling sys.exit() with child's code
When a worker process returns an error code, we would call
`sys.exit()` with that exit code on the main process. The `SystemExit`
exception would then get caught in `scmutil.callcatch()`, which would
return that error code. The comment there says "Commands shouldn't
sys.exit directly", which I agree with. This patch changes it so we
raise a specific exception when a worker fails so we can catch
instead. I think that means that `SystemExit` is now always an
internal error.
(I had earlier thought that this call to `sys.exit()` was from within
the child process until Matt Harbison made me look again, so thanks
for that!)
Differential Revision: https://phab.mercurial-scm.org/D9287
Martin von Zweigbergk <martinvonz@google.com> [Tue, 03 Nov 2020 09:56:02 -0800] rev 45824
config: read system hgrc in lexicographical order
This is similar to
edbcf5b239f9 (config: read configs from directories
in lexicographical order, 2019-04-03). Apparently I forgot to sort the
system hgrc files there. That's fixed by this patch.
Differential Revision: https://phab.mercurial-scm.org/D9269
Joerg Sonnenberger <joerg@bec.de> [Sun, 08 Nov 2020 20:12:32 +0100] rev 45823
relnotes: drop 5.6 release entries from next
Differential Revision: https://phab.mercurial-scm.org/D9282
Augie Fackler <augie@google.com> [Sat, 07 Nov 2020 15:02:53 -0500] rev 45822
merge with stable
Gregory Szorc <gregory.szorc@gmail.com> [Mon, 05 Oct 2020 19:46:31 -0700] rev 45821
makefile: use Python 3 by default (BC)
This change is long overdue IMO.
.. bc::
Makefile now uses `python3` instead of `python` by default on
non-Windows platforms. This means Mercurial will be built and
run with Python 3 instead of Python 2.7 by default.
To continue using Python 2, set the PYTHON variable. e.g.
`make install PYTHON=python2.7`.
Differential Revision: https://phab.mercurial-scm.org/D7258
Martin von Zweigbergk <martinvonz@google.com> [Tue, 03 Nov 2020 20:28:23 -0800] rev 45820
hgweb: don't call sys.exit() in httpservice.run()
If I'm reading the code correctly, `mercurial.server.createservice()`
can return an hgweb service or one of three types of command server
services. The caller then calls `mercurial.server.runservice()`,
passing it the returned service's run method. Only the hgweb service
was calling `sys.exit()`. It has been that way since
8d44649df03b
(refactor ssh server., 2006-06-04). That commit message doesn't
provide any explanation. Let's clean up and have the code follow the
usual return path into the `dispatch` module.
After this patch, there should be no remaining places left where we
call `sys.exit()` except for valid uses in the `dispatch` and `worker`
modules.
Differential Revision: https://phab.mercurial-scm.org/D9272
Martin von Zweigbergk <martinvonz@google.com> [Tue, 03 Nov 2020 20:20:49 -0800] rev 45819
serve: simply return instead of calling sys.exit() in `hg serve --stdio`
The shouldn't be a reason to call `sys.exit()` instead of letting the
code return normally. I've remove the call in both `hg serve` and `hg
debugserve`.
Differential Revision: https://phab.mercurial-scm.org/D9271
Martin von Zweigbergk <martinvonz@google.com> [Tue, 03 Nov 2020 20:18:26 -0800] rev 45818
httpservice: move sys.exit() out of serve_forever()
This is a simple refactoring to show the callers of the method, so
it's easier to reason about the impact of removing the `sys.exit()`
calls in subsequent patches.
Differential Revision: https://phab.mercurial-scm.org/D9270
Martin von Zweigbergk <martinvonz@google.com> [Mon, 22 Jun 2020 22:47:43 -0700] rev 45817
copies: handle more cases where a file got replaced by a copy
This patch fixes the changeset-centric version in a pretty
straight-forward way. It fixes it to automatically resolve the
conflict, which is better than resulting in a modify/delete conflict
as it was before
b4057d001760 (merge: when rename was made on both
sides, use ancestor as merge base, 2020-01-22).
I'll leave it for later to test and explicitly handle cases where
files have been renamed to the same target on different sides of the
merge.
Differential Revision: https://phab.mercurial-scm.org/D8653
Martin von Zweigbergk <martinvonz@google.com> [Mon, 22 Jun 2020 22:47:33 -0700] rev 45816
tests: test more cases where a file got replaced by a copy
This adds a test where a file is modified on one branch and is renamed
onto another file in another branch. That should ideally be
automatically resolved (by propagating the modification to the rename
destination). Alternatively, it could be considered a modify/delete
conflict. It should at least not be automatically resolved by ignoring
the modification. However, that is what actually happens with the
changeset-centric algorithm since I broke it in
b4057d001760 (merge:
when rename was made on both sides, use ancestor as merge base,
2020-01-22). Before that commit, it resulted in a modify/delete
conflict. The filelog-centric algorithm was broken already before that
commit.
Differential Revision: https://phab.mercurial-scm.org/D8652
Joerg Sonnenberger <joerg@bec.de> [Wed, 07 Oct 2020 03:00:26 +0200] rev 45815
unionrepo: don't insert index tuples with None as int field
None is not a valid size. Use -1 as placeholder instead. This will be
necessary when the index starts enforcing type correctness.
Differential Revision: https://phab.mercurial-scm.org/D9161
Joerg Sonnenberger <joerg@bec.de> [Wed, 07 Oct 2020 03:00:01 +0200] rev 45814
bundlerepo: don't insert index tuples with full nodes as linkrev
The index format has a documented format and latter changes will start
to enforce the field types. The bundlerepo uses full nodes for the
linkrev field when it should be using revision numbers. Use the link
mapping to resolve them, except in the special case of self-references.
Those are actually indications of a missing linkrev.
Differential Revision: https://phab.mercurial-scm.org/D9160
Antoine cezar<acezar@chwitlabs.fr> [Tue, 20 Oct 2020 15:09:08 +0200] rev 45813
rhg: add full node id support for `debugdata` command
Unlike other later implemented commands `debugdata` only supported revision
number. This changeset add full node id support for consistency with other
commands.
Differential Revision: https://phab.mercurial-scm.org/D9230