SBB: man: make the table of contents one level more detailed
SBB: man: give the table of contents its own section header.

The `.. contents::` restructuredtext directive seems to produce a level
header that is one level lower than we want it to be. It is not trivial to
change the header level output by rst; instead, this commit adds a section
header of the appropriate level just above the table of contents.
SBB: add a table of contents to the hg.1 man page
SBB: docs: nest command headers under category headers
SBB: order commands in man page by category
SBB: indent help command loop to prepare for next patch
subrepo: reject potentially unsafe subrepo paths (BC) (SEC)

In addition to the previous patch, this prohibits '~', '$nonexistent', etc.
for any subrepo types. I think this is safer, and real-world subrepos wouldn't
use such (local) paths.
subrepo: prohibit variable expansion on creation of hg subrepo (SEC)

It's probably wrong to expand path at localrepo.*repository() layer, but
fixing the layering issue would require careful inspection of call paths.
So, this patch adds add a validation to the subrepo constructor.

os.path.realpath(util.expandpath(root)) is what vfsmod.vfs() would do.
subrepo: extend path auditing test to include more weird patterns (SEC)

While reviewing patches for the issue 5739, "$foo in repository path
expanded", I realized that subrepo paths can also be cheated. This patch
includes various subrepo paths which are potentially unsafe.

Since an expanded subrepo path isn't audited, this bug allows symlink check
bypass. As a result, a malicious subrepository could be checked out to a
sub tree of e.g. $HOME directory. The good news is that the destination
directory must be empty or nonexistent, so the existing ~/.bashrc wouldn't
be overwritten. See the last part of the tests for details.
8427fea04017 — Anton Shestakov 3 years ago
copyright: update to 2019

Differential Revision: https://phab.mercurial-scm.org/D5779
189e06b2d719 — Boris Feld 3 years ago
revlog: make sure we never use sparserevlog without general delta (issue6056)

We are getting user report where the delta code tries to use `sparse-revlog`
logic on repository where `generaldelta` is disabled. This can't work so we
ensure the two booleans have a consistent value.

Creating this kind of repository is not expected to be possible the current bug
report point at a clonebundle related bug that is still to be properly isolated
(Yuya Nishihara seems to a have done it).

Corrupting a repository to reproduce the issue is possible. A test using this
method is included in this fix.
261d37b94d31 — Boris Feld 3 years ago
sparserevlog: document the config option

This was overlooked when this graduated from experimental.
rust-cpython: raising error.WdirUnsupported

The Graph implementation of hg-cpython returns the appropriate error
upon encounter with the working directory special revision number, and
this gives us in particular a code path to test from test-rust-ancestors.py

In the current implementation, the exception is actually raised from
the iterator instantiation; we are nonetheless consuming the iterator
in the test with `list()` in order not to depend on implementation details.
rust: error for WdirUnsupported with cpython conversion as exception

This introduces WorkingDirectoryUnsupported as an enum variant
of GraphError in the core and converts it to the expected
`mercurial.error.WdirUnsupported`.
rust: working directory revision number constant

This introduces the constant, but does not use it anywhere yet.
ui: remove unreachable branches and function calls from write() (issue6059)

This is at least faster than ui.write() of 4.8.2.

  $ HGRCPATH=/dev/null hg files -R mozilla-central --time >/dev/null
  4.8.2:  time: real 2.340 secs (user 2.310+0.000 sys 0.020+0.000)
  4.9rc0: time: real 2.580 secs (user 2.550+0.000 sys 0.020+0.000)
  this:   time: real 2.230 secs (user 2.210+0.000 sys 0.020+0.000)

Maybe the formatter should own a resolved write() function because it will
just call dest.write(msg) most of the time, but that would be too much for
stable.
ui: inline _writenobuf() into write() due to performance issue

I'll remove redundant conditions later in this series.
ui: inline _write() into write() due to performance issue

I'll remove redundant conditions later in this series.
ui: optimize buffered write with no label

This was spotted while making fastannotate faster again after ditching its
own formatter. Since I'm going to inline _write() into ui.write(), I decided
to include this patch in this series.

Here, the cost of '(self.label(a, label) for a in args)' was significant
in hot loops.
76873548b051 — Boris Feld 3 years ago
partialdiscovery: avoid `undecided` related computation sooner than necessary

Changeset 1d30be90c move the update of the `undecided` set within the
`partialdiscovery` object in order to clarify the API.

The update to the `undecided` set was unconditional in 1d30be90c and the first
access to the `self.undecided` property triggered the initial computation of
the set of undecided revisions. As a result, the set was computed much
earlier, at a time where less information is available, immediately followed
by an update of this set to remove common revisions.

To fix this regression, we ignore the `undecided` related logic in
`addcommons` when that `undecided` set has not been computed yet. Code that
actually needs to know the `undecided` set will trigger its computation later.
The change has no effects on semantic because the initial computation
`undecided` set takes all knowns `common` into account.

Example performance running `hg debugdiscovery` from a pypy repo missing 10
changesets:

870a89c6909d: 52.3ms (regression parent)
1d30be90c9dc: 72.0ms (regression)
5a5f504a7175: 64.8ms (this fix parent)
this fix:     52.6ms
Next