Mercurial > hg
annotate tests/helpers-testrepo.sh @ 34857:84c6b9384d6a
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.
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Tue, 17 Oct 2017 21:15:31 +0200 |
parents | 45d6e2767a93 |
children | 4e6a6d0dccee |
rev | line source |
---|---|
33206
45d6e2767a93
tests: use system hg only if changelog or dirstate can't be read
Yuya Nishihara <yuya@tcha.org>
parents:
33205
diff
changeset
|
1 # In most cases, the mercurial repository can be read by the bundled hg, but |
45d6e2767a93
tests: use system hg only if changelog or dirstate can't be read
Yuya Nishihara <yuya@tcha.org>
parents:
33205
diff
changeset
|
2 # that isn't always true because third-party extensions may change the store |
45d6e2767a93
tests: use system hg only if changelog or dirstate can't be read
Yuya Nishihara <yuya@tcha.org>
parents:
33205
diff
changeset
|
3 # format, for example. In which case, the system hg installation is used. |
29219
3c9066ed557c
tests: silence test-repo obsolete warning
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
4 # |
33116
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
5 # We want to use the hg version being tested when interacting with the test |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
6 # repository, and the system hg when interacting with the mercurial source code |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
7 # repository. |
29219
3c9066ed557c
tests: silence test-repo obsolete warning
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
8 # |
33116
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
9 # The mercurial source repository was typically orignally cloned with the |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
10 # system mercurial installation, and may require extensions or settings from |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
11 # the system installation. |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
12 syshg () { |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
13 ( |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
14 syshgenv |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
15 exec hg "$@" |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
16 ) |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
17 } |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
18 |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
19 # Revert the environment so that running "hg" runs the system hg |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
20 # rather than the test hg installation. |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
21 syshgenv () { |
33126
98e2c78e309c
tests: more completely restore the environment in syshgenv
Adam Simpkins <simpkins@fb.com>
parents:
33125
diff
changeset
|
22 . "$HGTEST_RESTOREENV" |
33116
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
23 HGPLAIN=1 |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
24 export HGPLAIN |
6c113a7dec52
tests: use the system hg for examining the local repository
Adam Simpkins <simpkins@fb.com>
parents:
29219
diff
changeset
|
25 } |
33125
acfce52518c4
tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents:
33116
diff
changeset
|
26 |
33205
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
27 # The test-repo is a live hg repository which may have evolution markers |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
28 # created, e.g. when a ~/.hgrc enabled evolution. |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
29 # |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
30 # Tests may be run using a custom HGRCPATH, which do not enable evolution |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
31 # markers by default. |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
32 # |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
33 # If test-repo includes evolution markers, and we do not enable evolution |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
34 # markers, hg will occasionally complain when it notices them, which disrupts |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
35 # tests resulting in sporadic failures. |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
36 # |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
37 # Since we aren't performing any write operations on the test-repo, there's |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
38 # no harm in telling hg that we support evolution markers, which is what the |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
39 # following lines for the hgrc file do: |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
40 cat >> "$HGRCPATH" << EOF |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
41 [experimental] |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
42 evolution = createmarkers |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
43 EOF |
2d7300cf3f3f
tests: restore workaround of obsolete warning from 3c9066ed557c
Yuya Nishihara <yuya@tcha.org>
parents:
33204
diff
changeset
|
44 |
33206
45d6e2767a93
tests: use system hg only if changelog or dirstate can't be read
Yuya Nishihara <yuya@tcha.org>
parents:
33205
diff
changeset
|
45 # Use the system hg command if the bundled hg can't read the repository with |
45d6e2767a93
tests: use system hg only if changelog or dirstate can't be read
Yuya Nishihara <yuya@tcha.org>
parents:
33205
diff
changeset
|
46 # no warning nor error. |
45d6e2767a93
tests: use system hg only if changelog or dirstate can't be read
Yuya Nishihara <yuya@tcha.org>
parents:
33205
diff
changeset
|
47 if [ -n "`hg id -R "$TESTDIR/.." 2>&1 >/dev/null`" ]; then |
33204
ddd65b4f3ae6
tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents:
33126
diff
changeset
|
48 alias testrepohg=syshg |
ddd65b4f3ae6
tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents:
33126
diff
changeset
|
49 alias testrepohgenv=syshgenv |
ddd65b4f3ae6
tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents:
33126
diff
changeset
|
50 else |
ddd65b4f3ae6
tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents:
33126
diff
changeset
|
51 alias testrepohg=hg |
ddd65b4f3ae6
tests: alias syshg and syshgenv so they can be switched conditionally
Yuya Nishihara <yuya@tcha.org>
parents:
33126
diff
changeset
|
52 alias testrepohgenv=: |
33125
acfce52518c4
tests: do not use system hg if it does not have "files" command
Jun Wu <quark@fb.com>
parents:
33116
diff
changeset
|
53 fi |