Commit Graph

90 Commits

Author SHA1 Message Date
Pierre-Yves David
34ff160b27 graphmod: move the graphstyle options to experimental
I let this slip in the [ui] section during the review, as far as I understand we
don't plan to actually support customisation of the output on we are happy with
our choice.  The option are just here to help people tests various options so we
can decide which one we'll actually use.

I'm moving the config option in the experimental section to make this clearer
and avoid making them part of the public API by mistake.
2016-03-24 00:09:58 -07:00
Martijn Pieters
146cd7366a graphmod: allow edges to end early
Rather than draw an edge all the way to the bottom of the graph, make it
possible to end an edge to parents that are not part of the graph early on.
This results in a far cleaner graph.

Any edge type can be set to end early; set the ui.graphstyle.<edgetype>
parameter to the empty string to enable this.

For example, setting the following configuration:

    [ui]
    graphstyle.grandparent = :
    graphstyle.missing =

would result in a graph like this:

  o    changeset:   32:d06dffa21a31
  |\   parent:      27:886ed638191b
  | :  parent:      31:621d83e11f67
  | :
  o :  changeset:   31:621d83e11f67
  |\:  parent:      21:d42a756af44d
  | :  parent:      30:6e11cd4b648f
  | :
  o :    changeset:   30:6e11cd4b648f
  |\ \   parent:      28:44ecd0b9ae99
  | ~ :  parent:      29:cd9bb2be7593
  |  /
  o :    changeset:   28:44ecd0b9ae99
  |\ \   parent:      1:6db2ef61d156
  | ~ :  parent:      26:7f25b6c2f0b9
  |  /
  o :    changeset:   26:7f25b6c2f0b9
  |\ \   parent:      18:1aa84d96232a
  | | :  parent:      25:91da8ed57247
  | | :
  | o :  changeset:   25:91da8ed57247
  | |\:  parent:      21:d42a756af44d
  | | :  parent:      24:a9c19a3d96b7
  | | :
  | o :    changeset:   24:a9c19a3d96b7
  | |\ \   parent:      0:e6eb3150255d
  | | ~ :  parent:      23:a01cddf0766d
  | |  /
  | o :    changeset:   23:a01cddf0766d
  | |\ \   parent:      1:6db2ef61d156
  | | ~ :  parent:      22:e0d9cccacb5d
  | |  /
  | o :  changeset:   22:e0d9cccacb5d
  |/:/   parent:      18:1aa84d96232a
  | :    parent:      21:d42a756af44d
  | :
  | o    changeset:   21:d42a756af44d
  | |\   parent:      19:31ddc2c1573b
  | | |  parent:      20:d30ed6450e32
  | | |
  +---o  changeset:   20:d30ed6450e32
  | | |  parent:      0:e6eb3150255d
  | | ~  parent:      18:1aa84d96232a
  | |
  | o    changeset:   19:31ddc2c1573b
  | |\   parent:      15:1dda3f72782d
  | ~ ~  parent:      17:44765d7c06e0
  |
  o  changeset:   18:1aa84d96232a
     parent:      1:6db2ef61d156
     parent:      15:1dda3f72782d

The default configuration leaves all 3 types set to |.

This is part of the work towards moving smartlog upstream; currently smartlog
injects extra nodes into the graph to indicate grandparent relationships (nodes
elided).
2016-03-19 16:37:47 -07:00
Martijn Pieters
32562c645b graphmod: allow for different styles for different edge types
Rather than draw all edges as solid lines, allow for using different styles for
different edge types. For example you could use dotted lines for edges that
do not connect to a parent, and dashed lines when connecting to a grandparent
(implying missing nodes in between).

For example, setting the following configuration:

    [ui]
    graphstyle.grandparent = :
    graphstyle.missing = .

would result in a graph like this:

  o    changeset:   32:d06dffa21a31
  |\   parent:      27:886ed638191b
  | :  parent:      31:621d83e11f67
  | :
  o :  changeset:   31:621d83e11f67
  |\:  parent:      21:d42a756af44d
  | :  parent:      30:6e11cd4b648f
  | :
  o :    changeset:   30:6e11cd4b648f
  |\ \   parent:      28:44ecd0b9ae99
  | . :  parent:      29:cd9bb2be7593
  | . :
  o . :    changeset:   28:44ecd0b9ae99
  |\ \ \   parent:      1:6db2ef61d156
  | . . :  parent:      26:7f25b6c2f0b9
  | . . :
  o . . :    changeset:   26:7f25b6c2f0b9
  |\ \ \ \   parent:      18:1aa84d96232a
  | | . . :  parent:      25:91da8ed57247
  | | . . :
  | o-----+  changeset:   25:91da8ed57247
  | | . . :  parent:      21:d42a756af44d
  | | . . :  parent:      24:a9c19a3d96b7
  | | . . :
  | o . . :    changeset:   24:a9c19a3d96b7
  | |\ \ \ \   parent:      0:e6eb3150255d
  | | . . . :  parent:      23:a01cddf0766d
  | | . . . :
  | o---+ . :  changeset:   23:a01cddf0766d
  | | . . . :  parent:      1:6db2ef61d156
  | | . . . :  parent:      22:e0d9cccacb5d
  | | . . . :
  | o-------+  changeset:   22:e0d9cccacb5d
  | . . . . :  parent:      18:1aa84d96232a
  |/ / / / /   parent:      21:d42a756af44d
  | . . . :
  | . . . o    changeset:   21:d42a756af44d
  | . . . |\   parent:      19:31ddc2c1573b
  | . . . | |  parent:      20:d30ed6450e32
  | . . . | |
  +-+-------o  changeset:   20:d30ed6450e32
  | . . . |    parent:      0:e6eb3150255d
  | . . . |    parent:      18:1aa84d96232a
  | . . . |
  | . . . o    changeset:   19:31ddc2c1573b
  | . . . .\   parent:      15:1dda3f72782d
  | . . . . |  parent:      17:44765d7c06e0
  | . . . . |
  o---+---+ |  changeset:   18:1aa84d96232a
    . . . . |  parent:      1:6db2ef61d156
   / / / / /   parent:      15:1dda3f72782d
  . . . . .


Edge styles can be altered by setting the following one-character config options::

    [ui]
    graphstyle.parent = |
    graphstyle.grandparent = :
    graphstyle.missing = .

The default configuration leaves all 3 types set to |, leaving graph styles
unaffected.

This is part of the work towards moving smartlog upstream; currently smartlog
injects extra nodes into the graph to indicate grandparent relationships (nodes
elided).
2016-03-19 16:46:15 -07:00
Yuya Nishihara
3e3e4eca75 graphlog: bring back color to node symbol template
Follows up 64cf8f39aac2. A ui object is required to render labels.
2016-03-09 23:57:15 +09:00
Yuya Nishihara
6b8c99a6d3 revset: flatten chained 'list' operations (aka function args) (issue5072)
Internal _matchfiles() function can take bunch of arguments, which would
lead to a maximum recursion depth error. This patch avoids the excessive
stack use by flattening 'list' nodes beforehand.

Since getlist() no longer takes a nested 'list' nodes, _parsealiasdecl()
also needs to flatten argument list, "aliasname($1, $2, ...)".
2016-02-02 23:49:49 +09:00
Augie Fackler
3fdeab8ee1 test-glog: avoid check-code violation after next patch
Danek's patch will help us avoid spurious test breakages on
Solaris. This test wasn't broken on Solaris because of the grep(1)
use, but it will upset check-code. Use cmp to silence check-code since
it doesn't matter.
2015-12-29 18:11:14 -05:00
Yuya Nishihara
10b6f5819b graphlog: make node symbol templatable by ui.graphnodetemplate option
New ui.graphnodetemplate option allows us to colorize a node symbol by phase
or branch,

  [ui]
  graphnodetemplate = {label('graphnode.{phase}', graphnode)}
  [color]
  graphnode.draft = yellow bold

or use a variety of unicode emoji characters, and so on. (You'll need less-481
to display non-BMP unicode character.)

  [ui]
  graphnodetemplate = {ifeq(obsolete, 'stable', graphnode, '\xf0\x9f\x92\xa9')}
2015-11-14 17:25:43 +09:00
Yuya Nishihara
3732960ab3 revset: use integer representation of wdir() in revset
This is the simplest way to handle wdir() revision in revset. None didn't
work well because revset heavily depends on integer operations such as min(),
max(), sorted(), x:y, etc.

One downside is that we cannot do "wctx.rev() in set" because wctx.rev() is
still None. We could wrap the result set by wdirproxyset that translates None
to wdirrev, but it seems overengineered at this point.

    result = getset(repo, subset, tree)
    if 'wdir' in funcsused(tree):
        result = wdirproxyset(result)

Test cases need the '(all() + wdir()) &' hack because we have yet to fix the
bootstrapping issue of null and wdir.
2015-03-16 16:17:06 +09:00
Matt Mackall
2173cc3777 merge with stable 2015-06-29 16:38:22 -05:00
Matt Harbison
d4e8d4f13c archive: don't assume '.' is being archived for changessincelatesttag
Hardcoding '.' is wrong, and yielded strange results when archiving old
revisions.  For example, when archiving the cset that adds the signature to 3.4
(a4f6d198e7df), the resulting value was previously 51 (the number of commits on
stable between 3.4 and today), even though it was a direct descendant of a tag,
with a {latesttagdistance} of 2.  This still includes all other _ancestor_ paths
not included in {latesttag}.

Note that archiving wdir() currently blows up several lines above this when
building the 'base' variable.  Since wdir() isn't documented, ignore that it
needs work to handle wdir() here for now.
2015-06-25 21:16:47 -04:00
Yuya Nishihara
799e490a3c revset: drop magic of fullreposet membership test (issue4682)
This patch partially backs out a9a86cbbc5b2 and adds an alternative workaround
to functions that evaluate "null" and "wdir()". Because the new workaround is
incomplete, "first(null)" and "min(null)" don't work as expected. But they were
not usable until 3.4 and "null" isn't commonly used, we can postpone a complete
fix for 3.5.

The issue4682 was caused because "branch(default)" is evaluated to
"<filteredset <fullreposet>>", keeping fullreposet magic. The next patch will
fix crash on "branch(null)", but without this patch, it would make
"null in <branch(default)>" be True, which means "children(branch(default))"
would return all revisions but merge (p2 != null).

I believe the right fix is to stop propagating fullreposet magic on filter(),
but it wouldn't fit to stable release. Also, we should discuss how to handle
"null" and "wdir()" in revset before.
2015-05-24 10:29:33 +09:00
Yuya Nishihara
ee4ca20b38 revset: have all() filter out null revision
I'm not sure if "all()" should filter out "null", but "all()" is stated as
'the same as "0:tip"' (except that it doesn't reorder the subset, I think.)

This patch is intended to avoid exposing a fullreposet to graphmod.dagwalker(),
which would result in strange drawing in future version:

  |
  o  changeset:   0:f8035bb17114
  |  user:        test
  |  date:        Thu Jan 01 00:00:00 1970 +0000
  |  summary:     add a

caused by:

    parents = sorted(set([p.rev() for p in ctx.parents()
                          if p.rev() in revs]))

We cannot add "and p.rev() != nullrev" here because revs may actually include
"null" revision.
2015-01-10 14:49:50 +09:00
Yuya Nishihara
74fe7e4a0f graphlog: do not bypass commands.log so that -fr works
Since 1c6485ced49b, opts dict can be modified in commands.log() before calling
cmdutil.graphlog().
2015-03-04 21:47:07 +09:00
Durham Goode
0744c2b71c log: make -fr show complete history from the given revs
Right now it's very obtuse to show the history of a particular rev (hg log -r
'reverse(::foo)'). This changes the -f option to make it follow history for the
revs specified by -r.

The current -f -r behavior is to limit the result of -r to only the
commits that are ancestors of the current working copy. Changing this
is a bit of a BC break, but the old behavior is A) rare, B) easy to
emulate (& ::.), and C) currently undefined. The new behavior is
frequently requested enough that I think the change is worth it.
2015-02-06 11:04:55 -08:00
Yuya Nishihara
ea398a57c8 log: fix --follow null parent not to include revision 0
If p1 is null, ':.' is translated as '0:null'. But rangeset can't handle null,
only revision 0 was visible.  Because 'null' should not be listed implicitly,
"log --follow" (without -r) should be empty if p1 is null.

Test of "hg grep -f" is added for cmdutil.walkchangerevs().
2015-02-06 21:53:39 +09:00
Yuya Nishihara
f70a0be178 graphlog: remove too early return from getgraphlogrevs() for empty repo
Even if repository is empty, null revision should exist.
2015-02-05 23:14:44 +09:00
Yuya Nishihara
ed458b9332 log: use rev() to build revset of --follow option from numeric revision
startrev can be -1.
2015-01-10 13:14:00 +09:00
Yuya Nishihara
d23a5c2002 revset: reduce nesting of chained 'or' operations (issue4624)
This reduces the stack depth of chained 'or' operations:
 - from O(n) to O(1) at the parsing, alias expansion and optimization phases
 - from O(n) to O(log(n)) at the evaluation phase

simplifyinfixops() must be applied immediately after the parsing phase.
Otherwise, alias expansion would crash by "maximum recursion depth exceeded"
error.

Test cases use 'x:y|y:z' instead of 'x|y' because I'm planning to optimize
'x|y' in a different way.

Benchmarks:

0) a2acce8dcd95
1) this patch

revset #0: 0 + 1 + 2 + ... + 200
0) wall 0.026347 comb 0.030000 user 0.030000 sys 0.000000 (best of 101)
1) wall 0.023858 comb 0.030000 user 0.030000 sys 0.000000 (best of 112)

revset #1: 0 + 1 + 2 + ... + 1000
0) maximum recursion depth exceeded
1) wall 0.483341 comb 0.480000 user 0.480000 sys 0.000000 (best of 20)

revset #2: sort(0 + 1 + 2 + ... + 200)
0) wall 0.013404 comb 0.010000 user 0.010000 sys 0.000000 (best of 196)
1) wall 0.006814 comb 0.010000 user 0.010000 sys 0.000000 (best of 375)

revset #3: sort(0 + 1 + 2 + ... + 1000)
0) maximum recursion depth exceeded
1) wall 0.035240 comb 0.040000 user 0.040000 sys 0.000000 (best of 100)
2015-04-26 18:13:48 +09:00
Matt Mackall
07ca4361bb merge with stable 2015-05-26 07:44:37 -05:00
Yuya Nishihara
0aa2a7df4d revset: move validation of incomplete parsing to parse() function
revset.parse() should be responsible for all parsing errors. Perhaps it wasn't
because 'revset.parse' was not a real function when the validation code was
added at ac01134d0a40.
2015-04-26 19:42:47 +09:00
Durham Goode
fd373c16b0 log: fix log revset instability
The log/graphlog revset was not producing stable results since it was
iterating over a dict. Now we sort before iterating to guarantee a fixed order.

This fixes some potential flakiness in the tests.
2014-12-08 15:41:54 -08:00
Durham Goode
74a5156e21 log: fix log -f slow path to actually follow history
The revset created when -f was used with a slow path (for patterns and
directories) did not actually contain any logic to enforce follow. Instead it
was depending on the passed in subset to already be limited (which was limited
to :. but not ::.). This fixes it by adding a '& ::.' to any -f log revset.

hg log -f <file> is still broken, in that it can return results that aren't
actually ancestors of the current file, but fixing that has major perf
implications, so we'll deal with it later.
2014-12-05 14:27:32 -08:00
Durham Goode
312ed291dd obsolete: update tests to use obsolete options
The obsolete._enabled flag has become a config option. This updates all but one
of the tests to use the minimal number of flags necessary for them to pass.  For
most tests this is just 'createmarkers', for a couple tests it's
'allowunstable', and for even fewer it's 'exchange'.
2014-10-14 13:34:25 -07:00
Augie Fackler
a5ddb1dcfe tests: use $PYTHON instead of hardcoding python
This makes running the testsuite with pypy possible.
2014-10-15 15:35:59 -04:00
Pierre-Yves David
2213bfcae4 revset-_descendant: rework the whole sorting and combining logic
We use the & operator to combine with subset (since this is more likely to be
optimised than filter) and we enforce the sorting of the result. Without this
enforced sorting, we may result in a different iteration order than the set
_descendent was computed from.

This reverts a bad `test-glog.t` change from 7904906883bd.

Another side effect is that `test-mq.t` shows `qparent::` including `-1` if
`qparent is -1`. This sound like a positive change.

This has good and bad impacts on the benchmarks, here is a good ones:

revset: 0::
before) wall 0.045489 comb 0.040000 user 0.040000 sys 0.000000 (best of 100)
after)  wall 0.034330 comb 0.030000 user 0.030000 sys 0.000000 (best of 100)

revset: roots((0::) - (0::tip))
before)  wall 0.134090 comb 0.140000 user 0.140000 sys 0.000000 (best of 63)
after) wall 0.128346 comb 0.130000 user 0.130000 sys 0.000000 (best of 69)

revset: ::p1(p1(tip))::
before) wall 0.143892 comb 0.140000 user 0.140000 sys 0.000000 (best of 55)
after)  wall 0.124502 comb 0.130000 user 0.130000 sys 0.000000 (best of 65)

revset: roots((0:tip)::)
before) wall 0.204966 comb 0.200000 user 0.200000 sys 0.000000 (best of 43)
after) wall 0.184455 comb 0.180000 user 0.180000 sys 0.000000 (best of 47)

Here is a bad one:

revset: (20000::) - (20000)
before) wall 0.009592 comb 0.010000 user 0.010000 sys 0.000000 (best of 222)
after)  wall 0.029837 comb 0.030000 user 0.030000 sys 0.000000 (best of 100)
2014-10-09 09:12:54 -07:00
Durham Goode
4bf8cd87a5 log: allow patterns with -f
It's not uncommon for a user to want to run log with a pattern or directory name
on the history of their current commit.  Currently we prevent that, but
I can't think of any reason to continue blocking that.

This commit removes the restriction and allows 'hg log -f <dir/pat>'
2014-07-22 22:40:16 -07:00
Lucas Moscovicz
2794920df6 log: changed implementation to use graphlog code
Now that revsets work in a lazy way, log code can be changed to parse every
option into a revset and then evaluate it lazily.

Now expressions like

  "hg log -b default -b ."

are converted into a revset using the same code as graphlog.
2014-02-28 15:10:56 -08:00
Matt Mackall
34b49de789 diff: use second filename for --stat reporting on git patches (issue4221) 2014-04-11 16:38:55 -04:00
Cristian Zamfir
c85ed151ff hg log: solves bug regarding hg log -r 0:null (issue4039)
'hg log -r 0:null' was showing only one changeset(the '-1' one) instead of the first two changesets.
2014-03-12 10:26:48 +02:00
Martin Geisler
7316194bdf tests: don't load unnecessary graphlog extension
Since graphlog is in core, we can use 'hg log -G' instead.
2013-11-22 19:14:17 +01:00
Alexander Plavin
48936f264c revlog: fix a regression with null revision
Introduced in the patch which fixes issue3497
Part of that patch was erroneously submitted and it shouldn't be in the code
2013-04-18 16:46:09 +04:00
Alexander Plavin
829cf92d16 log: fix behavior with empty repositories (issue3497)
Make output in this special case consistent with general case one.
2013-04-17 00:29:54 +04:00
Kevin Bullock
c54ed8bf64 tests: add regression tests for another revrange edge case
These tests would've passed before 99686e12b04e and a8620592704a.
Inserting them to make sure that continues to be the case.
2013-01-23 11:55:39 -06:00
Bryan O'Sullivan
9937540784 graphmod: don't try to visit nullrev (issue3772) 2013-01-23 00:20:26 -06:00
Pierre-Yves David
e30cc15ae0 test: use obsolescence marker to test hidden
Instead of using a custom dedicated extension.
2012-12-04 15:25:22 +01:00
Pierre-Yves David
76446449c3 test: remove invalid hidden rev in graphlog test
The hidden set of revision can not have descendant outside this set.

The extension is patched to raise and exception when this happen.
2012-08-30 22:13:24 +02:00
Mads Kiilerich
59664fd950 check-code: fix check for trailing whitespace on continued lines too
The tests in test-annotate.t and test-import-git.t that relied on trailing
space in a file created by a here string is now masked by a literal 'EOL'
string that is removed.
2012-08-08 18:10:37 +02:00
Pierre-Yves David
edc2b520d9 hidden: move hiddenrevs set on the repository
This set is always accessed through the repo for now. Having this set
carried by the changelog make it complicated to:

- initialize it, computing hidden set may involve revset call
- lazy compute it, (1) only the changelog can detect someone access it,
                   (2) only the repo have enought knowledge to compute it.

In later version I expect he changelog to apply filtering itself and the set to
be carried by changelog again.
2012-07-16 17:44:46 +02:00
Patrick Mezard
2d4a0ad972 graphlog: extract revset/support functions into cmdutil 2012-07-14 18:55:21 +02:00
Mads Kiilerich
c60c80f534 graphlog: don't truncate template value at last \n
Most uses of templates requires a trailing newline to get vertical output.

Graphlog with a template without trailing newline did however not just create
horisontal output like other commands would but truncated the output at the
last \n. Template values without any \n were ignored completely.

Graphlog will now only eat one trailing newline before it lets the flow of the
graph add the necessary vertical space.
2012-07-06 00:30:18 +02:00
Mads Kiilerich
db42f91a88 tests: convert some 'hghave no-outer-repo' to #if
In some places we instead use 'hg init' to create a well-known outer repo
without any special extensions or other config settings.
2012-06-20 23:41:21 +02:00
Mads Kiilerich
fa1c4e5ebe tests: add missing trailing 'cd ..'
Many tests didn't change back from subdirectories at the end of the tests ...
and they don't have to. The missing 'cd ..' could always be added when another
test case is added to the test file.

This change do that tests (99.5%) consistently end up in $TESTDIR where they
started, thus making it simpler to extend them or move them around.
2012-06-11 01:40:51 +02:00
Mads Kiilerich
8a7b2bbc7f tests: hide diff -u saying 'No differences encountered' on solaris 2012-04-23 01:39:26 +02:00
Patrick Mezard
aa91736f8f graphlog: fix --follow FILE and relative paths
The situation is complicated because filelog() revset uses a match object in
relpath mode while follow() revset interprets the filename as a manifest entry.
2012-04-14 11:27:11 +02:00
Patrick Mezard
923d3cc5c3 graphlog: implement --hidden 2012-04-14 10:30:38 +02:00
Patrick Mezard
00224d1ac6 graphlog: correctly handle calls in subdirectories 2012-04-11 11:32:00 +02:00
Patrick Mezard
a07861a2e3 graphlog: fix --follow-first --rev combinations
This solves a similar problem than the previous --follow/--rev patch. This time
we need changelog.ancestors()/descendants() filtering on first parent.
Duplicating the code looked better than introducing keyword arguments. Besides,
the ancestors() version was already implemented in follow() revset.
2012-04-11 11:25:34 +02:00
Patrick Mezard
50ca715022 graphlog: fix --follow --rev combinations
The previous behaviour of --follow was really a subset of what is really
happening in log command:
- If --rev is not passed, default to '.:0'
- Resolve --rev into a revision list "revs"
- Set the starting revision to revs[0]
- If revs[1] > revs[0] keep descendants(revs[0]) in revs, otherwise keep
  ancestors.
2012-04-11 11:22:40 +02:00
Patrick Mezard
d269778e3e graphlog: support changeset identifiers in --branch 2012-04-11 11:17:26 +02:00
Patrick Mezard
d282c91c89 graphlog: refactor revset() to return revisions
When --follow and --rev are passed, --follow actual behaviour depends on the
input revision sequence defined by --rev. If --rev is not passed, the default
revision sequence depends on the presence of --follow. It means the revision
sequence generation is part of log logic and must be wrapped. The issue
described above is fixed in following patches.
2012-04-11 11:07:30 +02:00