Commit Graph

20104 Commits

Author SHA1 Message Date
Kevin Bullock
8b1854807c internals: copy-edit "register" -> "registrar" in configitem docs 2017-11-01 13:24:08 -05:00
Matt Harbison
ba66d4513f help: minor copy editing for grammar 2017-10-31 23:09:29 -04:00
Yuya Nishihara
21161a9bda configitems: relax warning about unwanted default value
The original condition was a bit harsh for extension authors since third-party
extensions need to preserve compatibility with older Mercurial versions, where
no defaults would be loaded from the configtable. So let's silence the warning
if the given default value matches, which should be harmless.
2017-10-31 22:37:30 +09:00
Kostia Balytskyi
b244c1e330 filemerge: pass a default value to _toolstr (issue5718)
After a refactoring, _toolstr stopped having default="" as one of it's args,
therefore when called without a default it returns None and not "". This causes
concatenation to fail.
2017-10-26 11:07:06 -07:00
Yuya Nishihara
956c057ed5 statichttprepo: do not use platform path separator to build a URL
It wouldn't work between Windows client and Unix server.
2017-10-28 17:23:52 +09:00
Siddharth Agarwal
2d9d1fcc19 merge: disable path conflict checking by default (issue5716)
We shouldn't ship a severe perf regression in hg update for 4.4.

Differential Revision: https://phab.mercurial-scm.org/D1223
2017-10-24 11:15:30 -07:00
Siddharth Agarwal
1fe04b20a0 merge: add a config option to disable path conflict checking
We've found a severe perf regression in `hg update` caused by the path conflict
checking code. The next patch will disable this by default.

Differential Revision: https://phab.mercurial-scm.org/D1222
2017-10-24 11:14:38 -07:00
Mark Thomas
1d4d162882 dirstate: clean up when restoring identical backups
When a dirstate backup is restored, it is possible that no actual changes to
the dirstate have been made.  In this case, the backup is still a hardlink
to the original dirstate.

Unfortunately, `os.rename` silently fails (nothing happens, and no error
occurs) when `src` and `dst` are hardlinks to the same file.  As a result,
the backup is left lying around.  Over time, these files accumulate.

When restoring dirstate backups, check if the backup and the dirstate are
the same file, and if so, just delete the backup.

Differential Revision: https://phab.mercurial-scm.org/D1201
2017-10-20 05:53:35 -07:00
Durham Goode
35f758a851 dirstate: remove excess attribute lookups for dirstate.status (issue5714)
A recent refactor added a layer of abstraction to the dirstate which makes doing
things like 'foo in dirstate' now require some extra Python attribute lookups.
This is causing a 100ms slow down in hg status for mozilla-central.

The fix is to hoist the inner dict's functions onto the main class once the lazy
loading it complete, as well as store the actual functions before doing the
status loop (as is done for other such functions).

In my testing, it seems to address the performance regression, but we'll
need to see the perf run results to know for sure.

Differential Revision: https://phab.mercurial-scm.org/D1257
2017-10-28 12:35:54 -07:00
Durham Goode
c83eaaa0f1 dirstate: avoid reading the map when possible (issue5713) (issue5717)
Before the recent refactor, we would not load the entire map until it was
accessed. As part of the refactor, that got lost and even just trying to load
the dirstate parents would load the whole map. This caused a perf regression
(issue5713) and a regression with static http serving (issue5717).

Making it lazy loaded again fixes both.

Differential Revision: https://phab.mercurial-scm.org/D1253
2017-10-26 16:15:36 -07:00
Durham Goode
6a075fddcc dirstate: move clear onto dirstatemap class
A future diff will move the lazy loading aspect of dirstate to the dirstatemap
class. This means it requires a slightly different strategy of clearing than
just reinstantiating the object (since just reinstantiating the object will
lazily load the on disk data again later instead of remaining permanently
empty).

So let's give it it's own clear function.

Differential Revision: https://phab.mercurial-scm.org/D1252
2017-10-26 16:15:31 -07:00
Boris Feld
2d8cec51a9 internal-doc: document the config register mechanism
This explains the various usage and feature of the config register introduced
in Mercurial 4.3 and 4.4.
2017-10-27 18:19:07 +02:00
Boris Feld
51339acb82 help: clarify the pre-txnclose-phase documentation
Gregory Szorc requested some clarification.
2017-10-27 21:43:22 +02:00
Boris Feld
33f349a991 internal-doc: document the 'phases' parameters to 'getbundle'
The getbundle wireprotocol method has some extended documentation. We update it
with the next parameters introduced for binary phases.
2017-10-27 21:35:34 +02:00
Matt Harbison
258062fa5b status: update the help to indicate that clean files are not normally tersed
The same applies to '?' if --quiet is used (or any of the other states if some
of -marduic is specified), but I couldn't figure out how to express that
clearly.
2017-10-28 00:00:05 -04:00
Matt Harbison
9eb4def389 terse: split on repo separator instead of os.sep (issue5715)
The paths being processed are from scmutil.status, and therefore normalized to
'/' separators.
2017-10-27 23:48:38 -04:00
Yuya Nishihara
73e9f96212 statichttprepo: prevent loading dirstate over HTTP on node lookup (issue5717)
This seems a bit hacky, but works well. There should be no reason that
static-http repo had to load dirstate.

Initially I tried to proxy os.stat() call through vfs so that statichttpvfs
could hook it, but there wasn't a good error value which the statichttpvfs
could return to get around the util.filestat issue.
2017-10-25 21:58:03 +09:00
Yuya Nishihara
86972fbe07 server: drop executable bit from daemon log file
The logfile option was unused, so it was okay until now.
2017-10-25 21:20:01 +09:00
muxator
aaf12eb558 commands: be more uniform in an "hg update" error message
"can only specify one of -C/--clean, -c/--check, or -m/merge"
becomes
"can only specify one of -C/--clean, -c/--check, or -m/--merge"
2017-10-23 22:45:24 +02:00
Boris Feld
057760a2d2 obsfate: makes successorsetverb takes the markers as argument
Right now, successorsetverb only needs successors to compute the verb. But we
will want use additional information (effect-flags and operation) in the near
future to compute a better verb.

Add the markers parameter now so extensions (like Evolve) could wrap the
function and start experimenting around better obsfate verbs.

As successorsetverb now takes both successorset and markers parameters, rename
it to obsfateverb, successorsetandmarkersverb was too long.

Differential Revision: https://phab.mercurial-scm.org/D1191
2017-10-19 12:35:47 +02:00
Ryan McElroy
b4e9abb79e cmdutil: create dirs for templated cat file output
Previously, the caller was responsible for creating the directory structure of
files written out using a path template. This is onerous, especially if the
exact filenames are not known upfront, but are being accessed via a matcher.

This patch changes things so that hg will attempt to create the appropriate
directories before writing the output file.

Differential Revision: https://phab.mercurial-scm.org/D1332
2017-11-07 13:48:33 -08:00
Augie Fackler
7ed032e935 merge with stable 2017-11-07 13:18:49 -05:00
Yuya Nishihara
dfea246882 templatekw: add verbosity keyword to select template by -q/-v/--debug flag
This can be used in conjunction with the ifeq() function.
2017-10-21 17:46:41 +09:00
Yuya Nishihara
7f232b3ac0 templatekw: move loadkeyword() to bottom
loadkeyword() isn't a template keyword function.
2017-10-21 17:31:13 +09:00
Yuya Nishihara
1a42d3581c help: hide phaseidx template keyword
I don't think it's great idea to expose the internal representation of phases.
Let's discourage use of the phaseidx keyword.
2017-10-21 17:05:04 +09:00
Denis Laxalde
e400287a20 revert: do not reverse hunks in interactive when REV is not parent (issue5096)
And introduce a new "apply" operation verb for this case as suggested in
issue5096. This replaces the no longer used "revert" operation.

In interactive revert, when reverting to something else that the parent
revision, display an "apply this change" message with a diff that is not
reversed.

The rationale is that `hg revert -i -r REV` will show hunks of the diff from
the working directory to REV and prompt the user to select them for applying
(to working directory). This contradicts 79cc693b4406 in which it was
decided to have the "direction" of prompted hunks reversed. Later on
[1], there was a broad consensus (but no decision) towards the "as to
be applied direction". Now that --interactive is no longer experimental
(97d754ba45c4), it's time to switch and thus we drop no longer used
"experimental.revertalternateinteractivemode" configuration option.

[1]: https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-November/090142.html


.. feature::

  When interactive revert is run against a revision other than the working
  directory parent, the diff shown is the diff to *apply* to the working directory,
  rather than the diff to *discard* from the working copy. This is in line with
  related user experiences with `git` and appears to be less confusing with
  `ui.interface=curses`.
2017-11-03 14:47:37 +01:00
Kevin Bullock
d82cceaa42 merge with stable 2017-11-03 10:32:38 -05:00
Yuya Nishihara
57fc1b2b62 patch: improve heuristics to not take the word "diff" as header (issue1879)
The word "diff" is likely to appear in a commit message. Let's make it less
likely by requiring "diff -" for "diff -r" or "diff --git".
2017-10-21 16:50:57 +09:00
muxator
571ba67b50 update: mention long options explicitly in description of merge.update()
The short options "-c" and "-C" may be confusing for a novice reading the
documentation. Let's try to be more explicit, also mentioning the equivalent
long options ("--check" and "--clean") in the comments.
2017-10-04 23:22:34 +02:00
Yuya Nishihara
9e02f75b4c registrar: host "dynamicdefault" constant by configitem object
This is the common pattern seen in the other registrar classes.
2017-10-21 13:13:20 +09:00
Yuya Nishihara
74c1bd2363 configitems: register 'ui.editor' 2017-10-21 13:04:58 +09:00
Joe Blaylock
f9b24c83ac help: fix typo in hg merge documentation 2017-10-20 14:15:46 -07:00
Yuya Nishihara
1d02a603e8 help: do not abort topicmatch() because of unimportable extensions
This is alternative workaround to D1198, originally spotted by the earlier
version of the releasenotes extension.
2017-08-05 23:15:37 +09:00
Yuya Nishihara
6e8c1d0f1a configitems: register 'email.to' and 'patchbomb.to' 2017-10-20 22:25:09 +09:00
Boris Feld
87151ab0b0 exchange: propagate the subfunctions return
The parts generator can return a callback to handle server reply. We should
propagate the return for correctness.
2017-10-19 21:50:14 +02:00
Denis Laxalde
6a72a6393c log: add an assertion about fctx not being None in patch.diff()
As noted in the comment, this should not happen as removed files (the cause of
fctx2 being None) are caught earlier.
2017-10-19 15:06:33 +02:00
Denis Laxalde
daa0a6c266 log: handle removed files with --line-range patterns
I.e. abort when the pattern corresponds to a removed file, as done with bare
file patterns.
2017-10-19 14:55:10 +02:00
Denis Laxalde
40359bfd01 log: disable bare file patterns with --line-range
Currently, specifying both a line-range pattern and a bare file pattern
results in an AND operation whereas we probably want an OR so that bare file
patterns are like a line-range pattern with all lines specified.

So, until this works as expected, we disable this.
2017-10-19 14:12:49 +02:00
Denis Laxalde
21cd66f96c log: switch to FROMLINE:TOLINE syntax for -L/--line-range
This is more consistent with the followlines() revset.
2017-10-19 12:37:26 +02:00
Denis Laxalde
7b3941db14 log: handle binary files in --line-range patterns
When a file is binary patch.trydiff() would yield None for 'hunkrange'. Handle
this case in the hunksfilter() callback.
Add tests with and without diff.git option as binary handling differs
depending on this option's value.
2017-10-18 19:00:33 +02:00
Boris Feld
bd26fb4ef0 config: also gather effect-flags on experimental.evolution
Effect-flags config was in flight while the previous evolve config renaming
was written. Now that both landed, gather effect-flags in
experimental.evolution like the others evolve-related configurations.

Differential Revision: https://phab.mercurial-scm.org/D1197
2017-10-19 17:50:20 +02:00
Boris Feld
b2b964dde1 obsfate: rename obsfate into obsolete in default mapfile
Like the previous patch, replace obsfate by obsolete in default mapfile.

Differential Revision: https://phab.mercurial-scm.org/D1190
2017-10-19 12:33:53 +02:00
Boris Feld
540b37e2a9 obsfate: rename obsfate into obsolete in changeset_printer
Yuja's comment on the original obsfate about how we would translate obsfate
and the recent discussions about exposing users to new concepts and names lead
have led me to think that 'obsfate' should be treated as internal jargon. End-
users should not be aware of obsfate, so we replace 'obsfate' by 'obsolete' in
changeset_printer.

It will be easier to understand for end-users, easier to translate and closer
to the original Evolve obsfate output.

I'm aware it's extremely late in the cycle but I think it's an UX improvement
for the end-users.

Differential Revision: https://phab.mercurial-scm.org/D1189
2017-10-19 12:32:42 +02:00
Paul Morelle
80d72dfb5f sparse-read: ignore trailing empty revs in each read chunk
An empty entry in the revlog may happen for two reasons:
- when the file is empty, and the revlog stores a snapshot;
- when there is a merge and both parents were identical.

`hg debugindex -m | awk '$3=="0"{print}' | wc -l` gives 1917 of such entries
in my clone of pypy, and 113 on my clone of mercurial.

These empty revision may be located at the end of a sparse chain, and in some
special cases may lead to read relatively large amounts of data for nothing.
2017-10-18 15:28:19 +02:00
Martin von Zweigbergk
745cf248e6 registrar: don't i18n ProgrammingError message
Differential Revision: https://phab.mercurial-scm.org/D1188
2017-10-18 22:10:08 -07:00
Martin von Zweigbergk
0975261d97 registrar: move "constant" possiblecmdtypes to class level
While at it, switch to set literal syntax.

Differential Revision: https://phab.mercurial-scm.org/D1187
2017-10-18 22:07:53 -07:00
Augie Fackler
28d451ef21 cmdutil: fix status tersing on Python 3
Differential Revision: https://phab.mercurial-scm.org/D1183
2017-10-18 18:30:02 -04:00
Augie Fackler
a0c006361b configitems: make all regular expressions bytes and not native str
Fixes many tests on Python 3.

Differential Revision: https://phab.mercurial-scm.org/D1181
2017-10-18 18:29:00 -04:00
Jun Wu
c0323e0c94 show: move configitems to core
chgserver.py is also checking the config and will get:

  devel-warn: accessing unregistered config item:
  'commands.show.aliasprefix' at:
  mercurial/chgserver.py:109

if the config is not registered.

Differential Revision: https://phab.mercurial-scm.org/D1178
2017-10-18 15:05:03 -07:00
Jun Wu
d0d741d8a7 chgserver: do not treat HG as sensitive environ when CHGHG is set
When `$CHGHG` is set, `$HG` is ignored by the chg client. Removing it from
chg's sensitive environment list would avoid starting up servers
unnecessarily when `$CHGHG` is the same while `$HG` is different.

Differential Revision: https://phab.mercurial-scm.org/D1177
2017-10-18 14:55:39 -07:00
Gregory Szorc
35538a441a fsmonitor: warn when fsmonitor could be used
fsmonitor can significantly speed up operations on large working
directories. But fsmonitor isn't enabled by default, so naive users
may not realize there is a potential to make Mercurial faster.

This commit introduces a warning to working directory updates when
fsmonitor could be used.

The following conditions must be met:

* Working directory is previously empty
* New working directory adds >= N files (currently 50,000)
* Running on Linux or MacOS
* fsmonitor not enabled
* Warning not disabled via config override

Because of the empty working directory restriction, most users will
only see this warning during `hg clone` (assuming very few users
actually do an `hg up null`).

The addition of a warning may be considered a BC change. However, clone
has printed warnings before. Until recently, Mercurial printed a warning
with the server's certificate fingerprint when it wasn't explicitly
trusted for example. The warning goes to stderr. So it shouldn't
interfere with scripts parsing meaningful output.

The OS restriction was on the advice of Facebook engineers, who only
feel confident with watchman's stability on the supported platforms.

.. feature::

   Print warning when fsmonitor isn't being used on a large repository

Differential Revision: https://phab.mercurial-scm.org/D894
2017-10-18 22:57:15 +02:00
Saurabh Singh
8e631c99b7 ui: move request exit handlers to global state
Since the ui objects can be created with the 'load' class method, it
is possible to lose the exit handlers information from the old ui instance. For
example, running 'test-bad-extension.t' leads to this situation where chg
creates a new ui instance which does not copy the exit handlers from the
earlier ui instance. For exit handlers, which are special cases anyways, it
probably makes sense to have a global state of the handlers. This would ensure
that the exit handlers registered once are definitely executed at the end of
the request.

Test Plan:
Ran all the tests without '--chg' option. This also fixes the
'test-bad-extension.t' with the '--chg' option.

Differential Revision: https://phab.mercurial-scm.org/D1166
2017-10-17 13:20:25 -07:00
Paul Morelle
942b4f2e1a sparse-read: skip gaps too small to be worth splitting
Splitting at too small gaps might not be worthwhile. With this changeset,
we stop considering splitting on too small gaps. The threshold is configurable.
We arbitrarily pick 256K as a default value because it seems "okay".
Further testing on various repositories and setups will be needed to tune it.

The option name is 'experimental.sparse-read.min-gap-size`, and replaces
`experimental.sparse-read.min-block-size` which is not used any more.
2017-10-18 09:07:48 +02:00
Boris Feld
b5ee1a86a9 sparse-read: move from a recursive-based approach to a heap-based one
The previous recursive approach was trying to optimise each read slice to have
a good density. It had the tendency to over-optimize smaller slices while
leaving larger hole in others.

The new approach focuses on improving the combined density of all the reads,
instead of the individual slices. It slices at the largest gaps first, as they
reduce the total amount of read data the most efficiently.

Another benefit of this approach is that we iterate over the delta chain only
once, reducing the overhead of slicing long delta chains.

On the repository we use for tests, the new approach shows similar or faster
performance than the current default linear full read.

The repository contains about 450,000 revisions with many concurrent
topological branches. Tests have been run on two versions of the repository:
one built with the current delta constraint, and the other with an unlimited
delta span (using 'experimental.maxdeltachainspan=0')

Below are timings for building 1% of all the revision in the manifest log using
'hg perfrevlogrevisions -m'. Times are given in seconds. They include the new
couple of follow-up changeset in this series.

delta-span  standard    unlimited
linear-read     922s         632s
sparse-read     814s         566s
2017-10-18 12:53:00 +02:00
Matt Harbison
4856e00f46 subrepo: implement 'unshare' for Mercurial subrepos
I think there's a slight hole here in that a subrepo could be shared, removed
from .hgsub, and then it's not part of context.substate (so not iterated over).
But the push command has the same hole IIRC, and I think removing a subrepo is
an edge case.

The import hack is a copy/paste of subrepo.subrepo().
2017-10-17 22:55:33 -04:00
Matt Harbison
ae7841b944 share: move the implementation of 'unshare' to the 'hg' module
This will be used to setup unsharing subrepos.  Usually cmdutil is used for
this purpose.  But the implementation needs hg.copystore(), and the hg module
already imports cmdutil.
2017-10-17 21:48:56 -04:00
Denis Laxalde
13f0a4a653 show: use labelcset() template alias for work (and stack) views
By reusing labelcset() template alias from map-cmdline.default we can now
display obsolescence information in `hg show work/stack`.
2017-10-17 20:25:43 +02:00
Kevin Bullock
d9bf33fad2 phases: pass phase names to hooks instead of internal values 2017-10-18 12:19:53 -05:00
Boris Feld
aab8c43439 configitems: document the choice of using 'match' instead of 'search' 2017-10-18 12:36:23 +02:00
Boris Feld
ad198e9760 configitems: do not directly match generic items
Before this changesets, a literal '.*:foo$' config would match a registered
'.*:foo$' generic. This is wrong since generic should be matched through
regular exception only. This changeset fixes this problem.

Thanks for to Yuya Nishihara for spotting the issue.
2017-10-18 12:26:08 +02:00
Boris Feld
3df0c5d74a obsfate: fix obsfate_printer with empty date list
When the list of dates is empty, `min` and `max` would raises a ValueError.
Protect against this case by checking that the date list is not empty.

I didn't add a test because I couldn't find a reproducing test case.
2017-10-18 15:38:51 +02:00
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
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
Boris Feld
8be76ccfef obsolete: activate effect-flag by default
Let's activate effect-flag by default as Evolve is experimental and in order
to gather feedback from users.
2017-11-01 17:08:33 +01:00
Boris Feld
59dcbd2a4d debug: print parsed bundle2 capabilities with debugcapabilities
The bundle2 capabilities are hard to read in their encoded form. We parse and
print them in a human friendly way.
2017-10-30 17:09:29 +01:00
Boris Feld
9554fcac46 debug: add a debugcapabilities commands
This new debugcommand prints the capabilities of any remote in a human friendly
way. Improved bundle2 capabilities support will be introduced in the next
changesets.
2017-10-30 17:08:16 +01:00
Augie Fackler
3ff9746218 revert: no longer mark --interactive as experimental
We seem to have settled down on behavior changes here (nothing
matching revset `keyword(revert) and keyword(interactive)` since 4.2
was released), so let's go ahead and advertise this excellent feature.

.. feature:: revert --interactive

  The revert command now accepts the flag --interactive to allow reverting
  only some of the changes to the specified files.
2017-10-30 17:46:07 -04:00
Augie Fackler
ffa2157901 ui: add configlist doctest to document a bit more of the whitespace behavior
I'm surprised this wasn't explicitly tested, so I added a test.
2017-10-25 23:01:54 -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
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
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
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
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
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
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
Boris Feld
a3e217804d phase: isolate logic to update remote phrase through bundle2 pushkey
Move the logic to build bundle2 pushkey part into its dedicated function. It
will help to keep the logic clear when adding support for sending phases change
using 'phase-heads' part.
2017-09-20 19:17:37 +02:00