sapling/eden/scm/tests/test-fb-hgext-smartlog.t
Jun Wu 34df768136 log: add a config to simplify graphs
Summary:
This could help simplify the graph a lot for repos with lots of merges. For
example, logging tags on linux.git looks like:

  o                      fb893de3  Yesterday at 17:28  master
  ├─┬─┬─┬─┬─┬─┬─┬─┬─┬─╮
  ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o  bcf87687  Aug 02 at 14:21  v5.8
  ╷ ╷ ╷ ╭─────┬─┬───┬─╯
  ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o  92ed3019  Jul 26 at 14:14  v5.8-rc7
  ╷ ╷ ╷ ╭─────┬─┬─┬─╯
  ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o  ba47d845  Jul 19 at 15:41  v5.8-rc6
  ╷ ╷ ╷ ╭─┬─┬─┬─┬─╯
  ╷ ╷ ╷ ╷ ╷ ╷ ╷ o  11ba4688  Jul 12 at 16:34  v5.8-rc5
  ╷ ╷ ╷ ╭─┬─┬─┬─╯
  ╷ ╷ ╷ ╷ ╷ ╷ o  dcb7fd82  Jul 05 at 16:20  v5.8-rc4
  ╷ ╷ ╷ ╭─┬─┬─┤
  ╷ ╷ ╷ ╷ ╷ o ╷  9ebcfadb  Jun 28 at 15:00  v5.8-rc3
  ╷ ╷ ╭─┬─┬─╯ ╷
  ╷ ╷ ╷ ╷ o   ╷  48778464  Jun 21 at 15:45  v5.8-rc2
  ╷ ╷ ╷ ╭─╯   ╷
  ╷ ╷ ╷ o     ╷                      b3a9e3b9  Jun 14 at 12:45  v5.8-rc1
  ╭─┬─┬─┼─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─╮
  ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷  3d77e6a8  May 31 at 16:49  v5.7
  ╭─┬─┴───────┬───────────┬─┬───┬─╮
  ╷ o   ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷  9cb1fd0e  May 24 at 15:32  v5.7-rc7
  ╷ ╰─────────┬─────────────┬─┬─┬─╮
  ╷     ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o  b9bbe6ed  May 17 at 16:48  v5.7-rc6
  ╭───────────┬─────────────┬─┬─┬─╯
  ╷     ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o  2ef96a5b  May 10 at 15:16  v5.7-rc5
  ╭───────────┬─────────────┬─┬─╯
  ╷     ╷ ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷  0e698dfa  May 03 at 14:56  v5.7-rc4
  ╭───────────┴───────────┬─┬─╮
  o     ╷ ╷ ╷   ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷  6a8b55ed  Apr 26 at 13:51  v5.7-rc3
  ╰─────────────────┬───────┬─╮
        ╷ ╷ ╷   ╷ ╷ ╷ ╷ ╷ ╷ ╷ o  ae83d0b4  Apr 19 at 14:35  v5.7-rc2
        ╷ ╷ ╷   ╷ ╷ ╷ ╷ ╷ ╷ ╭─┤
        ╷ ╷ ╷   ╷ ╷ ╷ ╷ ╷ ╷ o ╷  8f3d9f35  Apr 12 at 12:35  v5.7-rc1
  ╭─┬─┬───────┬─────┬─┬─┬─┬─┼─╮
  ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ ╷  7111951b  Mar 29 at 15:25  v5.6
  ╷ ╭─────────┬─────┬─┬─┬─┴───╮
  ╷ ╷ ╷ ╷ ╷ ╷ o ╷ ╷ ╷ ╷ ╷   ╷ ╷  16fbf79b  Mar 22 at 18:31  v5.6-rc7
  ╷ ╷ ╭───────┴─────┬─┬─┬─────╮
  ╷ ╷ ╷ ╷ ╷ ╷   ╷ ╷ ╷ ╷ ╷   ╷ o  fb33c651  Mar 15 at 15:01  v5.6-rc6
  ╷ ╭─┬─────────────┬─┬─┬─────╯
  ╷ ╷ ╷ ╷ ╷ ╷   ╷ ╷ ╷ ╷ o   ╷  2c523b34  Mar 08 at 17:44  v5.6-rc5
  ╷ ╭─┬─────────────┬─┬─╯   ╷
  ╷ ╷ o ╷ ╷ ╷   ╷ ╷ ╷ ╷     ╷  98d54f81  Mar 01 at 14:38  v5.6-rc4
  ╷ ╭─┴─────────────┬─╮     ╷
  ╷ ╷   ╷ ╷ ╷   ╷ ╷ ╷ o     ╷  f8788d86  Feb 23 at 16:17  v5.6-rc3
  ....

And with simplification turned on, it looks like:

  o    fb893de3  Yesterday at 17:28  master
  ├─╮
  o ╷  bcf87687  Aug 02 at 14:21  v5.8
  ╷ ╷
  o ╷  92ed3019  Jul 26 at 14:14  v5.8-rc7
  ╷ ╷
  o ╷  ba47d845  Jul 19 at 15:41  v5.8-rc6
  ╷ ╷
  o ╷  11ba4688  Jul 12 at 16:34  v5.8-rc5
  ╷ ╷
  o ╷  dcb7fd82  Jul 05 at 16:20  v5.8-rc4
  ╷ ╷
  o ╷  9ebcfadb  Jun 28 at 15:00  v5.8-rc3
  ╷ ╷
  o ╷  48778464  Jun 21 at 15:45  v5.8-rc2
  ├─╯
  o  b3a9e3b9  Jun 14 at 12:45  v5.8-rc1
  ╷
  o  3d77e6a8  May 31 at 16:49  v5.7
  ╷
  o  9cb1fd0e  May 24 at 15:32  v5.7-rc7
  ╷
  o  b9bbe6ed  May 17 at 16:48  v5.7-rc6
  ╷
  o  2ef96a5b  May 10 at 15:16  v5.7-rc5
  ╷
  o  0e698dfa  May 03 at 14:56  v5.7-rc4
  ╷
  o  6a8b55ed  Apr 26 at 13:51  v5.7-rc3
  ╷
  o  ae83d0b4  Apr 19 at 14:35  v5.7-rc2
  ╷
  o  8f3d9f35  Apr 12 at 12:35  v5.7-rc1
  ╷
  o  7111951b  Mar 29 at 15:25  v5.6
  ╷
  o  16fbf79b  Mar 22 at 18:31  v5.6-rc7
  ╷
  o  fb33c651  Mar 15 at 15:01  v5.6-rc6
  ╷
  o  2c523b34  Mar 08 at 17:44  v5.6-rc5
  ╷
  o  98d54f81  Mar 01 at 14:38  v5.6-rc4
  ╷
  o  f8788d86  Feb 23 at 16:17  v5.6-rc3
  ....

Under the hood, the difference is how `reachableroots` gets calculated.
See also D22657197 (a5c36fd0b1) and D22368827 (da42f2c17e).

Since the old behavior almost always seems confusing to human. The new
config is turned on by default (but only takes effect if the "segments"
backend is used).

Reviewed By: sfilipco

Differential Revision: D23095468

fbshipit-source-id: f0fc631d2d9a00e3b36744e4236b43d230d10687
2020-08-21 17:10:36 -07:00

358 lines
7.5 KiB
Perl

#chg-compatible
$ disable treemanifest
$ enable smartlog
$ readconfig <<EOF
> [format]
> use-segmented-changelog=1
> [experimental]
> graphstyle.grandparent=|
> graphstyle.missing=|
> EOF
Build up a repo
$ hg init repo
$ cd repo
Confirm smartlog doesn't error on an empty repo
$ hg smartlog
Continue repo setup
$ hg book master
$ hg sl -r 'smartlog() + master'
$ touch a1 && hg add a1 && hg ci -ma1
$ touch a2 && hg add a2 && hg ci -ma2
$ hg book feature1
$ touch b && hg add b && hg ci -mb
$ hg up -q master
$ touch c1 && hg add c1 && hg ci -mc1
$ touch c2 && hg add c2 && hg ci -mc2
$ hg book feature2
$ touch d && hg add d && hg ci -md
$ hg debugmakepublic master
$ hg log -G -T "{node|short} {bookmarks} {desc}" -r 'sort(:, topo)'
@ db92053d5c83 feature2 d
|
| o 49cdb4091aca feature1 b
| |
o | 38d85b506754 master c2
| |
o | ec7553f7b382 c1
|/
o b68836a6e2ca a2
|
o df4fd610a3d6 a1
Basic test
$ hg smartlog -T '{node|short} {bookmarks} {desc}'
@ db92053d5c83 feature2 d
|
o 38d85b506754 master c2
.
| o 49cdb4091aca feature1 b
|/
o b68836a6e2ca a2
|
With commit info
$ echo "hello" >c2 && hg ci --amend
$ hg smartlog -T '{node|short} {bookmarks} {desc}' --commit-info
@ 05d10250273e feature2 d M c2
| A d
|
o 38d85b506754 master c2
.
| o 49cdb4091aca feature1 b
|/
o b68836a6e2ca a2
|
As a revset
$ hg log -G -T '{node|short} {bookmarks} {desc}' -r 'smartlog()'
@ 05d10250273e feature2 d
|
| o 49cdb4091aca feature1 b
| |
o | 38d85b506754 master c2
|/
o b68836a6e2ca a2
|
With --master
$ hg smartlog -T '{node|short} {bookmarks} {desc}' --master 'desc(a2)'
o 49cdb4091aca feature1 b
|
| @ 05d10250273e feature2 d
| |
| o 38d85b506754 master c2
|/
o b68836a6e2ca a2
|
Specific revs
$ hg smartlog -T '{node|short} {bookmarks} {desc}' -r 'desc(b)' -r 'desc(c2)'
o 49cdb4091aca feature1 b
|
| o 38d85b506754 master c2
|/
o b68836a6e2ca a2
|
$ hg smartlog -T '{node|short} {bookmarks} {desc}' -r 'smartlog()' -r 'desc(a1)'
o 49cdb4091aca feature1 b
|
| @ 05d10250273e feature2 d
| |
| o 38d85b506754 master c2
|/
o b68836a6e2ca a2
|
o df4fd610a3d6 a1
Test master ordering
$ hg debugmakepublic 49cdb4091aca
$ hg boo -f master -r 49cdb4091aca
$ hg smartlog -T '{node|short} {bookmarks} {desc}'
o 49cdb4091aca feature1 master b
|
| @ 05d10250273e feature2 d
| |
| o 38d85b506754 c2
| |
| o ec7553f7b382 c1
|/
o b68836a6e2ca a2
|
Test overriding master
$ hg debugmakepublic 38d85b506754
$ hg boo -f master -r 38d85b506754
$ hg smartlog -T '{node|short} {bookmarks} {desc}'
@ 05d10250273e feature2 d
|
o 38d85b506754 master c2
.
| o 49cdb4091aca feature1 b
|/
o b68836a6e2ca a2
|
$ hg debugmakepublic feature1
$ hg smartlog -T '{node|short} {bookmarks} {desc}' --master feature1
o 49cdb4091aca feature1 b
|
| @ 05d10250273e feature2 d
| |
| o 38d85b506754 master c2
| |
| o ec7553f7b382 c1
|/
o b68836a6e2ca a2
|
$ hg smartlog -T '{node|short} {bookmarks} {desc}' --config smartlog.master=feature1
o 49cdb4091aca feature1 b
|
| @ 05d10250273e feature2 d
| |
| o 38d85b506754 master c2
| |
| o ec7553f7b382 c1
|/
o b68836a6e2ca a2
|
$ hg smartlog -T '{node|short} {bookmarks} {desc}' --config smartlog.master=feature2 --master feature1
o 49cdb4091aca feature1 b
|
| @ 05d10250273e feature2 d
| |
| o 38d85b506754 master c2
| |
| o ec7553f7b382 c1
|/
o b68836a6e2ca a2
|
$ hg debugmakepublic .
Test with weird bookmark names
$ hg book -r 'desc(b)' foo-bar
$ hg smartlog -r 'foo-bar + .' -T '{node|short} {bookmarks} {desc}'
@ 05d10250273e feature2 d
.
| o 49cdb4091aca feature1 foo-bar b
|/
o b68836a6e2ca a2
|
$ hg debugmakepublic foo-bar
$ hg smartlog --config smartlog.master=foo-bar -T '{node|short} {bookmarks} {desc}'
o 49cdb4091aca feature1 foo-bar b
|
| @ 05d10250273e feature2 d
| |
| o 38d85b506754 master c2
| |
| o ec7553f7b382 c1
|/
o b68836a6e2ca a2
|
$ hg smartlog --config smartlog.master=xxxx -T '{node|short} {bookmarks} {desc}'
abort: unknown revision 'xxxx'!
[255]
Test with two unrelated histories
$ hg update null
0 files updated, 0 files merged, 5 files removed, 0 files unresolved
(leaving bookmark feature2)
$ touch u1 && hg add u1 && hg ci -mu1
$ touch u2 && hg add u2 && hg ci -mu2
$ hg smartlog -T '{node|short} {bookmarks} {desc}'
@ 806aaef35296 u2
|
o 8749dc393678 u1
o 05d10250273e feature2 d
|
o 38d85b506754 master c2
|
o ec7553f7b382 c1
|
| o 49cdb4091aca feature1 foo-bar b
|/
o b68836a6e2ca a2
|
A draft stack at the top
$ cd ..
$ hg init repo2
$ cd repo2
$ hg debugbuilddag '+4'
$ hg bookmark curr
$ hg bookmark master -r 'desc(r1)'
$ hg debugmakepublic -r 'desc(r1)'
$ hg smartlog -T '{node|short} {bookmarks} {desc}' --all
o 2dc09a01254d r3
|
o 01241442b3c2 r2
|
o 66f7d451a68b master r1
|
$ hg smartlog -T '{node|short} {bookmarks} {desc}' --all --config smartlog.indentnonpublic=1
o 2dc09a01254d r3
|
o 01241442b3c2 r2
/
o 66f7d451a68b master r1
|
Different number of lines per node
$ hg smartlog -T '{node|short}\n{bookmarks}\n{desc}\n{author}\n{date|isodate}\n' --all --config smartlog.indentnonpublic=1
o 2dc09a01254d
|
| r3
| debugbuilddag
| 1970-01-01 00:00 +0000
o 01241442b3c2
/
| r2
| debugbuilddag
| 1970-01-01 00:00 +0000
o 66f7d451a68b
| master
| r1
| debugbuilddag
| 1970-01-01 00:00 +0000
Add other draft stacks
$ hg up 'desc(r1)' -q
$ echo 1 > a
$ hg ci -A a -m a -q
$ echo 2 >> a
$ hg ci -A a -m a -q
$ hg up 'desc(r2)' -q
$ echo 2 > b
$ hg ci -A b -m b -q
$ hg smartlog -T '{node|short} {bookmarks} {desc}' --all --config smartlog.indentnonpublic=1
o a60fccdcd9e9 a
|
o 8d92afe5abfd a
/
| @ 401cd6213b51 b
| |
| | o 2dc09a01254d r3
| |/
| o 01241442b3c2 r2
|/
o 66f7d451a68b master r1
|
Recent arg select days correctly
$ echo 1 >> b
$ myday=`hg debugsh -c 'import time; ui.write(str(int(time.time()) - 24 * 3600 * 20))'`
$ hg commit --date "$myday 0" -m test2
$ hg update 'desc(r0)' -q
$ hg log -Gr 'smartlog(master="master", heads=((date(-15) & draft()) + .))' -T '{node|short} {bookmarks} {desc}'
o 66f7d451a68b master r1
|
@ 1ea73414a91b r0
$ hg log -Gr 'smartlog((date(-25) & draft()) + .)' -T '{bookmarks} {desc}'
o test2
|
o b
|
o r2
|
o master r1
|
@ r0
Make sure public commits that are descendants of master are not drawn
$ cd ..
$ hg init repo3
$ cd repo3
$ hg debugbuilddag '+5'
$ hg bookmark master -r 'desc(r1)'
$ hg debugmakepublic -r 'desc(r1)'
$ hg smartlog -T '{node|short} {bookmarks} {desc}' --all --config smartlog.indentnonpublic=1
o bebd167eb94d r4
|
o 2dc09a01254d r3
|
o 01241442b3c2 r2
/
o 66f7d451a68b master r1
|
$ hg debugmakepublic 'desc(r3)'
$ hg up -q 'desc(r4)'
$ hg smartlog -T '{node|short} {bookmarks} {desc}' --all --config smartlog.indentnonpublic=1
@ bebd167eb94d r4
/
o 2dc09a01254d r3
.
o 66f7d451a68b master r1
|
$ hg debugmakepublic 'desc(r4)'
$ hg smartlog -T '{node|short} {bookmarks} {desc}' --all --config smartlog.indentnonpublic=1
@ bebd167eb94d r4
.
o 66f7d451a68b master r1
|