sapling/tests/test-show-work.t
Gregory Szorc f621d5ad49 show: show all namespaces in "work" view
This commit addresses a number of deficiencies in `hg show work`'s
output:

* Failure to render tags (it just wasn't implemented)
* Failure to render names associated with non-built-in namespaces
  (e.g. remotenames)
* Color names were hardcoded instead of coming from the canonical
  source in the namespace

This change has the intended effect of rendering tags and extra
namespaces. It solves an immediate need at Mozilla of having
names from a custom namespace printed, which is blocking us from
switching from a custom `hg wip` revset/template combo to `hg show
work`.

Note that the order of branches and bookmarks changes. This is
because bookmarks are registered before branches in namespaces.py.
We may want to register them last, after tags and branches. Or we
may want to added a weighted field to the namespace to control
display order. Something to think about.

I'm not a big fan of the complexity in the templating layer. There
is a lot of code to basically filter out the special case of
branch=='default' and tag=='tip'. Ideally, we would iterate over
a data structure that had irrelevant/unwanted names pre-filtered.
However, I wasn't sure how to best implement this. We probably
want {namespaces} to emit everything (its current behavior). I
was toying with the following:

* {namespacesnondefaults} variation that filtered values
* A filter function that operated on {namespaces} (I wasn't sure
  how to implement this since the filtering layer would see a
  "hybrid" instance as opposed to something that was definitely
  an iterable of namespaces.)
* A namespaces(...) function where you could specify which values
  to return. I like this the most. But it really wants named
  arguments to control filtering and we only support named arguments
  on revsets, not templates.

I figure perfect is the enemy of good and we can refine templating
support for namespaces in the future. At least now we have a
concrete example of a use case.
2017-06-24 15:11:05 -07:00

238 lines
4.1 KiB
Perl

$ cat >> $HGRCPATH << EOF
> [extensions]
> show =
> EOF
$ hg init repo0
$ cd repo0
Command works on an empty repo
$ hg show work
Single draft changeset shown
$ echo 0 > foo
$ hg -q commit -A -m 'commit 0'
$ hg show work
@ 9f171 commit 0
Even when it isn't the wdir
$ hg -q up null
$ hg show work
o 9f171 commit 0
Single changeset is still there when public because it is a head
$ hg phase --public -r 0
$ hg show work
o 9f171 commit 0
A draft child will show both it and public parent
$ hg -q up 0
$ echo 1 > foo
$ hg commit -m 'commit 1'
$ hg show work
@ 181cc commit 1
o 9f171 commit 0
Multiple draft children will be shown
$ echo 2 > foo
$ hg commit -m 'commit 2'
$ hg show work
@ 128c8 commit 2
o 181cc commit 1
o 9f171 commit 0
Bumping first draft changeset to public will hide its parent
$ hg phase --public -r 1
$ hg show work
@ 128c8 commit 2
o 181cc commit 1
|
~
Multiple DAG heads will be shown
$ hg -q up -r 1
$ echo 3 > foo
$ hg commit -m 'commit 3'
created new head
$ hg show work
@ f0abc commit 3
| o 128c8 commit 2
|/
o 181cc commit 1
|
~
Even when wdir is something else
$ hg -q up null
$ hg show work
o f0abc commit 3
| o 128c8 commit 2
|/
o 181cc commit 1
|
~
Draft child shows public head (multiple heads)
$ hg -q up 0
$ echo 4 > foo
$ hg commit -m 'commit 4'
created new head
$ hg show work
@ 668ca commit 4
| o f0abc commit 3
| | o 128c8 commit 2
| |/
| o 181cc commit 1
|/
o 9f171 commit 0
$ cd ..
Branch name appears in output
$ hg init branches
$ cd branches
$ echo 0 > foo
$ hg -q commit -A -m 'commit 0'
$ echo 1 > foo
$ hg commit -m 'commit 1'
$ echo 2 > foo
$ hg commit -m 'commit 2'
$ hg phase --public -r .
$ hg -q up -r 1
$ hg branch mybranch
marked working directory as branch mybranch
(branches are permanent and global, did you want a bookmark?)
$ echo 3 > foo
$ hg commit -m 'commit 3'
$ echo 4 > foo
$ hg commit -m 'commit 4'
$ hg show work
@ f8dd3 (mybranch) commit 4
o 90cfc (mybranch) commit 3
| o 128c8 commit 2
|/
o 181cc commit 1
|
~
$ cd ..
Bookmark name appears in output
$ hg init bookmarks
$ cd bookmarks
$ echo 0 > foo
$ hg -q commit -A -m 'commit 0'
$ echo 1 > foo
$ hg commit -m 'commit 1'
$ echo 2 > foo
$ hg commit -m 'commit 2'
$ hg phase --public -r .
$ hg bookmark @
$ hg -q up -r 1
$ echo 3 > foo
$ hg commit -m 'commit 3'
created new head
$ echo 4 > foo
$ hg commit -m 'commit 4'
$ hg bookmark mybook
$ hg show work
@ cac82 (mybook) commit 4
o f0abc commit 3
| o 128c8 (@) commit 2
|/
o 181cc commit 1
|
~
$ cd ..
Tags are rendered
$ hg init tags
$ cd tags
$ echo 0 > foo
$ hg -q commit -A -m 'commit 1'
$ echo 1 > foo
$ hg commit -m 'commit 2'
$ hg tag 0.1
$ hg phase --public -r .
$ echo 2 > foo
$ hg commit -m 'commit 3'
$ hg tag 0.2
$ hg show work
@ 37582 Added tag 0.2 for changeset 6379c25b76f1
o 6379c (0.2) commit 3
o a2ad9 Added tag 0.1 for changeset 6a75536ea0b1
|
~
$ cd ..
Multiple names on same changeset render properly
$ hg init multiplenames
$ cd multiplenames
$ echo 0 > foo
$ hg -q commit -A -m 'commit 1'
$ hg phase --public -r .
$ hg branch mybranch
marked working directory as branch mybranch
(branches are permanent and global, did you want a bookmark?)
$ hg bookmark mybook
$ echo 1 > foo
$ hg commit -m 'commit 2'
$ hg show work
@ 34834 (mybook) (mybranch) commit 2
o 97fcc commit 1
Multiple bookmarks on same changeset render properly
$ hg book mybook2
$ hg show work
@ 34834 (mybook mybook2) (mybranch) commit 2
o 97fcc commit 1
$ cd ..
Extra namespaces are rendered
$ hg init extranamespaces
$ cd extranamespaces
$ echo 0 > foo
$ hg -q commit -A -m 'commit 1'
$ hg phase --public -r .
$ echo 1 > foo
$ hg commit -m 'commit 2'
$ echo 2 > foo
$ hg commit -m 'commit 3'
$ hg --config extensions.revnames=$TESTDIR/revnamesext.py show work
@ 32f3e (r2) commit 3
o 6a755 (r1) commit 2
o 97fcc (r0) commit 1
$ cd ..