Commit Graph

34613 Commits

Author SHA1 Message Date
Boris Feld
4b2916f625 config: gather allowdivergence under the evolution namespace
Grouping all evolution related-config under the experimental.evolution
namespace would helps the future migration outside [experimental].

Differential Revision: https://phab.mercurial-scm.org/D1155
2017-10-17 16:54:31 +02:00
Boris Feld
03a11d7666 config: remove stabilization.* aliases
Stabilization config items were never part of a release, remove them now that
we cleaned up the evolution related configuration.

Differential Revision: https://phab.mercurial-scm.org/D1154
2017-10-17 15:57:56 +02:00
Boris Feld
e2184ba620 config: rename stabilization.track-operation
We want to get rid of stabilization.* configuration, back out to the old
configuration 'evolution.track-operation'.

Differential Revision: https://phab.mercurial-scm.org/D1153
2017-10-17 15:56:49 +02:00
Boris Feld
7aaf02f1ae config: rename stabilization.bundle-obsmarker
We want to get rid of stabilization.* configuration, back out to the old
configuration 'evolution.bundle-obsmarker'.

Differential Revision: https://phab.mercurial-scm.org/D1152
2017-10-17 15:54:05 +02:00
Boris Feld
9c4599c477 config: use 'experimental.evolution.exchange'
Extract 'experimental.evolution' = exchange as
'experimental.evolution.exchange'.

We keep the new option in the 'experimental.evolution' namespace in order to
stay coherent with other options ('experimental.evolution.bundle-obsmarker'
and 'experimental.evolution.track-operation') ease the renaming as possibly
'evolution.exchange'.

Differential Revision: https://phab.mercurial-scm.org/D1151
2017-09-28 21:07:58 +01:00
Boris Feld
50cd57c3da config: use 'experimental.evolution.allowunstable'
Extract 'experimental.evolution' = allowunstable as
'experimental.evolution.allowunstable'.

We keep the new option in the 'experimental.evolution' namespace in order to
stay coherent with other options ('experimental.evolution.bundle-obsmarker'
and 'experimental.evolution.track-operation') ease the renaming as possibly
'evolution.allowunstable'.

Differential Revision: https://phab.mercurial-scm.org/D1150
2017-09-28 18:56:40 +01:00
Boris Feld
a95ef2baa9 config: use 'experimental.evolution.create-markers'
Extract 'experimental.evolution' = createmarkers as
'experimental.evolution.createmarkers'.

We keep the new option in the 'experimental.evolution' namespace in order to
stay coherent with other options ('experimental.evolution.bundle-obsmarker'
and 'experimental.evolution.track-operation') ease the renaming as possibly
'evolution.createmarkers'.

Differential Revision: https://phab.mercurial-scm.org/D1149
2017-09-28 18:19:06 +01:00
Boris Feld
3276655886 config: replace experimental.stabilization by experimental.evolution
We replace 'experimental.stabilization=all' by 'experimental.evolution=true'
as we will extract individual config in their own config in later patches.

Differential Revision: https://phab.mercurial-scm.org/D1148
2017-10-17 11:29:26 +02:00
Boris Feld
5f77fdf0f1 config: update evolution-related config
Update the evolution helpers function to support both old-style configuration and
new-style configuration:

    experimental.evolution=all is renamed into experimental.evolution=true

    experimental.evolution=createmarkers is renamed into
    experimental.evolution.createmarkers=true

    experimental.evolution=allowunstable is renamed into
    experimental.evolution.allowunstable=true

    experimental.evolution=exchange is renamed into
    experimental.evolution.exchange=true

We choose to not rename individual config options; keeping the same names
would easy the transition for users but it's something that could be easily
done in the future.

Differential Revision: https://phab.mercurial-scm.org/D1147
2017-10-16 17:14:47 +02:00
Boris Feld
35adc999b8 config: invert evolution-related configuration aliases
We want to split the evolution-related configuration and back-out the renaming
from evolution.* to stabilization.*.

First invert the configuration and aliases, so next changesets will be
cleaner.

Differential Revision: https://phab.mercurial-scm.org/D1146
2017-10-16 17:14:32 +02:00
Augie Fackler
7ca1f09f81 parsers: allow clang-format here
# skip-blame because parsers.c is mechanically rewritten by
clang-format with no semantic change.

Differential Revision: https://phab.mercurial-scm.org/D1170
2017-10-16 14:53:57 -04:00
Augie Fackler
90df42e97c cext: add /* header */ comment to all PyVarObject_HEAD_INIT() calls
This gives clang-format the right notion about formatting these struct
initializers, therefore allowing us to automatically format several
additional files.

# skip-blame because this is just a content-free comment addition

Differential Revision: https://phab.mercurial-scm.org/D1169
2017-10-16 14:49:35 -04:00
Augie Fackler
9ae9ebef63 parsers: protect some case-folding tables from clang-format
We want a slightly weird format here so that it's easier to read, but
in order to preserve that we need to disable clang-format.

Differential Revision: https://phab.mercurial-scm.org/D1168
2015-04-21 16:02:23 -04:00
Augie Fackler
631f1e4b95 makefile: add target to apply clang-format in-place
This makes it easy to reformat files after you finish editing them.

Differential Revision: https://phab.mercurial-scm.org/D1167
2015-09-14 14:52:20 -04:00
Boris Feld
38f9c73dbd configitems: adds a developer warning when accessing undeclared configuration
Now that all known options are declared, we setup a warning to make sure it will
stay this way.

We disable the warning in two tests checking other behavior with random options.
2017-10-16 17:41:27 +02:00
Denis Laxalde
75398ab7ec log: add -L/--line-range option to follow file history by line range
We add an experimental -L/--line-range option to 'hg log' taking file patterns
along with a line range using the (new) FILE,FROMLINE-TOLINE syntax where FILE
may be a pattern (matching exactly one file). The resulting history is similar
to what the "followlines" revset except that, if --patch is specified,
only diff hunks within specified line range are shown.

Basically, this brings the CLI on par with what currently only exists in hgweb
through line selection in "file" and "annotate" views resulting in a file log
with filtered patch to only display followed line range.

The option may be specified multiple times and can be combined with --rev and
regular file patterns to further restrict revisions. Usage of this option
requires --follow; revisions are shown in descending order and renames are
followed. Only the --graph option is currently not supported.

The UI is the result of a consensus from review feedback at:

  https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-October/106749.html


The implementation spreads between commands.log() and cmdutil module.
In commands.log(), the main loop may now use a "hunksfilter" factory (similar
to "filematcher") that, for a given "rev", produces a filtering function
for diff hunks for a given file context object.
The logic to build revisions from -L/--line-range options lives in
cmdutil.getloglinerangerevs() which produces "revs", "filematcher" and
"hunksfilter" information. Revisions obtained by following files' line range
are filtered if they do not match the revset specified by --rev option. If
regular FILE arguments are passed along with -L options, both filematchers are
combined into a new matcher.

.. feature::

   Add an experimental -L/--line-range FILE,FROMLINE-TOLINE option to 'hg log'
   command to follow the history of files by line range. In combination with
   -p/--patch option, only diff hunks within specified line range will be
   displayed. Feedback, especially on UX aspects, is welcome.
2017-10-17 21:15:31 +02:00
Denis Laxalde
356644ac1a diff: pass a diff hunks filter function from changeset_printer to patch.diff()
We add a 'hunksfilterfn' keyword argument in all functions of the call
stack from changeset_printer.show() to patch.diff(). This is a callable
that will be used to filter out hunks by line range and will be used in
the "-L/--line-range" option of "hg log" command introduced in the
following changesets.
2017-10-06 14:45:17 +02:00
Denis Laxalde
f37bd71289 diff: also yield file context objects in patch.trydiff() (API)
And retrieve them in patch.diffhunks(). We'll use these in forthcoming
changesets to filter diff hunks by line range.
2017-10-05 21:20:08 +02:00
Denis Laxalde
5c56737c70 revset: extract a parsefollowlinespattern helper function
We'll need the same logic in forthcoming changeset to handle --line-range
option in 'hg log' command.
The function lives in scmutil.py (rather than util.py) as it uses match and
pathutil modules.
2017-10-04 15:27:43 +02:00
Boris Feld
c3010f59dd obsfate: add obsfate to default mapfile
Use the verbosity aware template keyword introduced earlier. It has the nice
property of being verbosity dependent but in order to customize the obsfate
part, users will need to replace the lobsfate definition from default mapfile
with the one using template functions (by copying the one from test-obsmarker-
template.t for example).

As it's a more advanced use-case, I'm more inclined to have the same code for
the {obsfate} keyword, in the changeset printer and in the default mapfile for
consistency.

But, the definition in default mapfile could be replaced with one based on
template filter to obsfate output customization if it is a big need for users.
2017-10-06 17:53:36 +02:00
Boris Feld
d09c69f7b8 log: add obsfate by default in changeset printer
Having an obsfate by default in log will be useful for users to understand why
they have obsolete and unstable changesets. Obsfate will only be shown for
obsolete changesets, which only happens if people opt-in to experimental feature.

But when obsolete changeset are visible, it is very useful to understand where
they are. Having it in log could be sufficient for most people, so they don't
have to learn a new command (like obslog which is itself useful in case of
divergences).

For example, when pulling and working directory parent become obsolete:

  $ hg pull
  ...
  working directory parent is obsolete! (f936c1697205)

This message comes from the Evolve extension.

Obsfate would comes handy:

  $ hg log -G
  o  changeset:   2:6f91013c5136
  |  tag:         tip
  |  parent:      0:4ef7b558f3ec
  |  user:        Boris Feld <boris.feld@octobus.net>
  |  date:        Mon Oct 09 16:00:27 2017 +0200
  |  summary:     A
  |
  | @  changeset:   1:f936c1697205
  |/   user:        Boris Feld <boris.feld@octobus.net>
  |    date:        Mon Oct 09 16:00:27 2017 +0200
  |    obsfate:     rewritten using amend as 2:6f91013c5136
  |    summary:     -A
  |
  o  changeset:   0:feb4dd822b8c
     user:        Boris Feld <boris.feld@octobus.net>
     date:        Tue Oct 09 16:00:00 2017 +0200
     summary:     ROOT

And once we update, we don't have an obsolete changeset in the log anymore so
we don't show obsfate anymore, most users won't see obsfate often if they
don't have obsolete changeset often:

  @  changeset:   2:6f91013c5136
  |  tag:         tip
  |  parent:      0:4ef7b558f3ec
  |  user:        Boris Feld <boris.feld@octobus.net>
  |  date:        Mon Oct 09 16:00:27 2017 +0200
  |  summary:     A
  |
  o  changeset:   0:feb4dd822b8c
     user:        Boris Feld <boris.feld@octobus.net>
     date:        Tue Oct 09 16:00:00 2017 +0200
     summary:     ROOT
2017-10-05 15:25:18 +02:00
Boris Feld
d580cec6cc obsfate: only display date in verbose mode
The date is also not that helpful in most cases but we show it in verbose mode.
2017-10-09 15:34:26 +02:00
Boris Feld
98e0e19dcc obsfate: filter out current user if not in verbose
Obsolescence is sometimes used only locally so the obs-marker users is always
the same. Showing the user in this case does not bring much values.

In the case where multiple users rewrite the commit, display the full list of
users. Also show all users in verbose mode.
2017-10-09 15:34:12 +02:00
Boris Feld
142a0c0bf5 ui: add the possibility to returns None as username in ui
In a later patch we want to retrieve the current username or None if it isn't
defined. Add the acceptempty parameter instead of catching Abort.
2017-10-06 16:23:47 +02:00
Boris Feld
eaded5c294 test: test obfate template keyword in test-obsmarker-template.t
These test updates are pretty big by themselves so put it in a separate patch
for easing the review process.
2017-10-06 17:15:49 +02:00
Boris Feld
4ed4f0d702 templatekw: introduce obsfate keyword
Introduce an obsfate printer that uses all helpers functions defined in
obsutil to get all the obsfate-related data and format a string according to
the current format in test-obsmarker-template.t.

Then, introduce an obsfate templatekw that uses the obsfateprinter to return a
list of strings.

The goal is not to replace existing obsfate template functions but to propose
a default, good-enough and easily usable obsfate definition for end-users that
don't want to customize it. Such output would ultimately get included in the
default log output.

Here are some output examples for a commit amended:

rewritten using amend as 5:a9b1f8652753 by test (at 1970-01-01 00:00 +0000)

Next patches will make the output dependent on the verbosity.

Exemple of use-cases:

For having the obsfate on a single-line between brackets:

  {if(obsfate, " [{join(obsfate, "; ")}]")}

For having the obsfate in several lines:

  {if(obsfate, "{obsfate % "  Obsfate: {fate}\n"}")}
2017-10-05 17:42:56 +02:00
Pulkit Goyal
98c13e4c70 copies: add a config to limit the number of candidates to check in heuristics
The heuristics algorithm find possible candidates for move/copy and then check
whether they are actually a copy or move. In some cases, there can be lot of
candidates possible which can actually slow down the algorithm.

This patch introduces a config option
`experimental.copytrace.movecandidateslimit` using which one can limit the
candidates to check. The limit defaults to 100.

Thanks to Yuya for suggesting to skip copytracing for that file with a
warning.

Differential Revision: https://phab.mercurial-scm.org/D987
2017-10-10 02:25:03 +05:30
Martin von Zweigbergk
3fba6ca94a extensions: always include traceback when extension setup fails
I have spent a lot of time debugging extensions that failed to load
because we don't include a traceback and I didn't realize I could get
traceback for the extension failure with --traceback. Let's just turn
them on by default, since it should be rare that the user sees these
tracebacks anyway (and if they do, it's not so bad if the extra
traceback pushes them a little harder to report the problem).

Since we already had a test case with --traceback and one without, I
just removed the one with the flag.

Differential Revision: https://phab.mercurial-scm.org/D1164
2017-10-17 10:31:44 -07:00
Martin von Zweigbergk
6835c48840 tests: move baduisetup() test out of "#if demandimport"
It no longer depends on demandimport.

Differential Revision: https://phab.mercurial-scm.org/D1163
2017-10-17 10:25:32 -07:00
Martin von Zweigbergk
b60712b3ab tests: make test-extension.t's baduisetup.py test fail even if bdiff exists
A mercurial.bdiff module has existed at some point and when I have
built at an old version, some .pyc file or something seems to stick
around and test-extension.t fails. Let's remove the reference to bdiff
and simplify the test.

Differential Revision: https://phab.mercurial-scm.org/D1162
2017-10-17 09:46:31 -07:00
Martin von Zweigbergk
4046d59941 run-tests: move newline out of colorized message
The leading newline before "ERROR:" led to an incorrect lexing of the
message and the newline got lost.

The fixed formatting can be seen in the test case. The reason we
didn't notice before was that the bad formatting just led to the loss
of a blank line in the test. However, there are other cases where it
would be joined with a line saying "Accept this change? [n]" or
"Reference output has changed (run again to prompt changes)".

Differential Revision: https://phab.mercurial-scm.org/D1159
2017-10-17 10:33:27 -07:00
Saurabh Singh
f1d4d02412 test-extension: make the test compatible with chg
This test fails when run with chg. This commit just makes the test chg
aware by fixing the output of some of the tests.

Test Plan:
Ran the test 'test-extension.t' with and without '--chg' option.

Differential Revision: https://phab.mercurial-scm.org/D1160
2017-10-17 11:07:18 -07:00
Saurabh Singh
f7a6f008b9 hghave: disable demandimport when chg is running
Chg disables demandimport on purpose for performance wins and
therefore, it probably makes sense to indicate that demandimport is disabled
when chg is running.

Test Plan:
Ran all the tests.

Differential Revision: https://phab.mercurial-scm.org/D1161
2017-10-17 11:35:58 -07:00
Jun Wu
4fede3d6bc test-show: make it compatible with chg
The show extension reads `commands.show.aliasprefix` config in its
`extsetup` and that causes issues with chg. This patch adds that config item
to chg confighash to solve the issue.

Test Plan:
`run-tests.py -l --chg test-show.t`

Differential Revision: https://phab.mercurial-scm.org/D1158
2017-10-17 10:41:56 -07:00
Augie Fackler
22d88dd8c3 templater: use pycompat.sysbytes to bytes-ify some __name__ attrs
Spotted by yuya in review of 093b17c57344.

Differential Revision: https://phab.mercurial-scm.org/D1145
2017-10-17 10:51:43 -04:00
Augie Fackler
d57f1641f5 templatefilters: defend against evil unicode strs in json filter
We only want to do I/O in terms of bytes, so lets explode early
instead of recursing forever.

Differential Revision: https://phab.mercurial-scm.org/D1136
2017-10-16 22:44:43 -04:00
Boris Feld
a5658f8623 phase: use a binary phase part to push through bundle2 (BC)
The part we are using for pull is now used for push too. As we no longer use
pushkey, pushkey hooks are no longer triggered. This is an obvious backward
incompatible change. We could artificially trigger the pushkey hook within the
bundle2 part, but this seemed too hacky to me.

An option would be to disable by default this new mechanism for a couple of
versions to help people migrate to `txnclose-phase`. I took the liberal and
optimistic path to just turn it on by default directly.

.. bc::

   Push no longer triggers a pushkey hook when updating phases. Use the new
   `txnclose-phase` and `txnclose-phase` hooks instead.
   (Applies when both server and client use version 4.4 or above).
2017-09-20 19:38:06 +02:00
Phil Cohen
ed7cf84951 arbitraryfilecontext: skip the cmp fast path if any side is a symlink
`filecmp` follows symlinks by default, which a `filectx.cmp()` call should not
be doing as it should only compare the  requested entry. After this patch, only
the contexts' data are compared, which is the correct contract.

This is a corrected version of D1122.

Differential Revision: https://phab.mercurial-scm.org/D1165
2017-10-17 12:41:24 -07:00
Augie Fackler
89b5ee7ac3 test-clang-format: new test to verify that files stay clang-formatted
For now all .c and .h files are blacklisted. As they become
clang-formatted, we'll remove them from the blacklist,and then this
test will produce output if there are diffs.

Differential Revision: https://phab.mercurial-scm.org/D1133
2015-09-14 14:17:27 -04:00
Mark Thomas
8e56a1507b context: audit paths before clearing unknown files and dirs
Fix regression introduced in D785.

In some circumstances, context.clearunknown can be called before the path is
audited. Audit the path before deleting any conflicting files.

Differential Revision: https://phab.mercurial-scm.org/D1157
2017-10-17 08:11:13 -07:00
Mark Thomas
e356526dc7 tests: add test demonstrating regression in path audit
D785 regressed behavior in path auditing: files can be deleted if they have a
path that conflicts with a filename from a malicious remote or bundle.

This test demonstrates the problem - the file should not have been deleted.

Differential Revision: https://phab.mercurial-scm.org/D1156
2017-10-17 08:07:43 -07:00
Boris Feld
ad5f3bc109 configitems: move rebase config into core
The shelve extensions import and call rebase content without loading the
extension. This is problematic as the config items rebase uses are not
declared and the default value are not set, etc...

The shelve extension should be using core utilities only and the necessary bit
should be moved from rebase into core. In the meantime, I'm taking a small
step to get config registration completed with minimal overhead. The rebase
extension is shipped with core so registering its config option within core is
not a big issue.

This is the last step needed before we can install a warning that enforces all
config to be registered.
2017-10-13 23:00:31 +02:00
Boris Feld
0e5c2b08a6 eol: ensure the eol extensions is loaded when hooks run
Similar to the change we did to the 'acl' extensions, we want to make sure the
config items are registered before we run the hooks.
2017-10-14 01:09:46 +02:00
Boris Feld
b0d5f7ccc5 acl: make sure the extensions is enabled when the acl-hooks run
The acl extension is usually setup through hooks and never directly activated.
This means the config item declared in the extension are not loaded.
We add the necessary logic to make sure the extensions are loaded before the hook
run.
2017-10-14 01:16:03 +02:00
Boris Feld
3796be0790 configitems: register the 'web.archivesubrepos' config 2017-10-16 18:16:29 +02:00
Boris Feld
6241e08062 configitems: register the 'experimental.effect-flags' config 2017-10-08 22:22:27 +02:00
Boris Feld
ed9a31a26e configitems: register the full 'merge-tools' config and sub-options
We register the merge-tools config section (which has an arbitrary base config
value) and the possible sub-attribute. The sub-attribute has to be registered
first or at the same time otherwise the '.*' item would shadow them.

Merge tools could include "." in their name so we can't constrain any more
than just ".*".
2017-10-08 20:37:13 +02:00
Paul Morelle
549788470a revlog-sparse-read: add a lower-threshold for read block size
The option experimental.sparse-read.min-block-size specifies the minimal size
of a deltachain span, under which it won't be split by _slicechunk.
2017-10-14 17:05:41 +02:00
Paul Morelle
d1288f1f44 revlog: introduce an experimental flag to slice chunks reads when too sparse
Delta chains can become quite sparse if there is a lot of unrelated data between
relevant pieces. Right now, revlog always reads all the necessary data for the
delta chain in one single read. This can lead to a lot of unrelated data to be
read (see issue5482 for more details).
One can use the `experimental.maxdeltachainspan` option with a large value
(or -1) to easily produce a very sparse delta chain.

This change introduces the ability to slice the chunks retrieval into  multiple
reads, skipping large sections of unrelated data. Preliminary testing shows
interesting results. For example the peak memory consumption to read a manifest
on a large repository is reduced from 600MB to 250MB (200MB without
maxdeltachainspan). However, the slicing itself and the multiple reads can have
an negative impact on performance. This is why the new feature is hidden behind
an experimental flag.

Future changesets will add various parameters to control the slicing heuristics.
We hope to experiment a wide variety of repositories during 4.4 and hopefully
turn the feature on by default in 4.5.
As a first try, the algorithm itself is prone to deep changes. However, we wish
to define APIs and have a baseline to work on.
2017-10-10 17:50:27 +02:00
Paul Morelle
6d907667b2 revlog: ignore empty trailing chunks when reading segments
When a merge commit creates an empty diff in the revlog, its offset may still
be quite far from the end of the previous chunk.
Skipping these empty chunks may reduce read size significantly.
In most cases, there is no gain, and in some cases, little gain.
On my clone of pypy, `hg manifest` reads 65% less bytes (96140 i/o 275943) for
revision 4260 by ignoring the only empty trailing diff.
For revision 2229, 35% (34557 i/o 53435)
Sadly, this is difficult to reproduce, as hg clone can make its own different
structure every time.
2017-10-09 15:13:41 +02:00