tests/test-show-stack.t
author Gregory Szorc <gregory.szorc@gmail.com>
Sat, 01 Jul 2017 22:38:42 -0700
changeset 33197 c5a07a3abe7d
child 33208 9e7efe421395
permissions -rw-r--r--
show: implement "stack" view People often want to know what they are working on *now*. As part of this, they also commonly want to know how that work is related to other changesets in the repo so they can perform common actions like rebase, histedit, and merge. `hg show work` made headway into this space. However, it is geared towards a complete repo view as opposed to just the current line of work. If you have a lot of in-flight work or the repo has many heads, the output can be overwhelming. The closest thing Mercurial has to "show me the current thing I'm working on" that doesn't require custom revsets is `hg qseries`. And this requires MQ, which completely changes workflows and repository behavior and has horrible performance on large repos. But as sub-optimal as MQ is, it does some things right, such as expose a model of the repo that is easy for people to reason about. This simplicity is why I think a lot of people prefer to use MQ, despite its shortcomings. One common development workflow is to author a series of linear changesets, using bookmarks, branches, anonymous heads, or even topics (3rd party extension). I'll call this a "stack." You periodically rewrite history in place (using `hg histedit`) and reparent the stack against newer changesets (using `hg rebase`). This workflow can be difficult because there is no obvious way to quickly see the current "stack" nor its relation to other changesets. Figuring out arguments to `hg rebase` can be difficult and may require highlighting and pasting multiple changeset nodes to construct a command. The goal of this commit is to make stack based workflows simpler by exposing a view of the current stack and its relationship to other releant changesets, notably the parent of the base changeset in the stack and newer heads that the stack could be rebased or merged into. Introduced is the `hg show stack` view. Essentially, it finds all mutable changesets from the working directory revision in both directions, stopping at a merge or branch point. This limits the revisions to a DAG linear range. The stack is rendered as a concise list of changesets. Alongside the stack is a visualization of the DAG, similar to `hg log -G`. Newer public heads from the branch point of the stack are rendered above the stack. The presence of these heads helps people understand the DAG model and the relationship between the stack and changes made since the branch point of that stack. If the "rebase" command is available, a `hg rebase` command is printed for each head so a user can perform a simple copy and paste to perform a rebase. This view is alpha quality. There are tons of TODOs documented inline. But I think it is good enough for a first iteration.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33197
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     1
  $ cat >> $HGRCPATH << EOF
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     2
  > [extensions]
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     3
  > show =
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     4
  > EOF
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     5
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     6
  $ hg init repo0
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     7
  $ cd repo0
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     8
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     9
Empty repo / no checkout results in error
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    10
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    11
  $ hg show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    12
  abort: stack view only available when there is a working directory
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    13
  [255]
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    14
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    15
Stack displays single draft changeset as root revision
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    16
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    17
  $ echo 0 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    18
  $ hg -q commit -A -m 'commit 0'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    19
  $ hg show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    20
    @  9f171 commit 0
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    21
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    22
Stack displays multiple draft changesets
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    23
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    24
  $ echo 1 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    25
  $ hg commit -m 'commit 1'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    26
  $ echo 2 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    27
  $ hg commit -m 'commit 2'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    28
  $ echo 3 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    29
  $ hg commit -m 'commit 3'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    30
  $ echo 4 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    31
  $ hg commit -m 'commit 4'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    32
  $ hg show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    33
    @  2737b commit 4
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    34
    o  d1a69 commit 3
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    35
    o  128c8 commit 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    36
    o  181cc commit 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    37
    o  9f171 commit 0
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    38
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    39
Public parent of draft base is displayed, separated from stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    40
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    41
  $ hg phase --public -r 0
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    42
  $ hg show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    43
    @  2737b commit 4
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    44
    o  d1a69 commit 3
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    45
    o  128c8 commit 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    46
    o  181cc commit 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    47
   /   (stack base)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    48
  o  9f171 commit 0
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    49
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    50
  $ hg phase --public -r 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    51
  $ hg show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    52
    @  2737b commit 4
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    53
    o  d1a69 commit 3
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    54
    o  128c8 commit 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    55
   /   (stack base)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    56
  o  181cc commit 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    57
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    58
Draft descendants are shown
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    59
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    60
  $ hg -q up 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    61
  $ hg show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    62
    o  2737b commit 4
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    63
    o  d1a69 commit 3
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    64
    @  128c8 commit 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    65
   /   (stack base)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    66
  o  181cc commit 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    67
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    68
  $ hg -q up 3
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    69
  $ hg show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    70
    o  2737b commit 4
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    71
    @  d1a69 commit 3
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    72
    o  128c8 commit 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    73
   /   (stack base)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    74
  o  181cc commit 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    75
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    76
working dir on public changeset should display special message
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    77
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    78
  $ hg -q up 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    79
  $ hg show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    80
  (empty stack; working directory is a published changeset)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    81
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    82
Branch point in descendants displayed at top of graph
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    83
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    84
  $ hg -q up 3
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    85
  $ echo b > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    86
  $ hg commit -m 'commit 5 (new dag branch)'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    87
  created new head
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    88
  $ hg -q up 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    89
  $ hg show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    90
   \ /  (multiple children)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    91
    |
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    92
    o  d1a69 commit 3
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    93
    @  128c8 commit 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    94
   /   (stack base)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    95
  o  181cc commit 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    96
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    97
  $ cd ..
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    98
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    99
Base is stopped at merges
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   100
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   101
  $ hg init merge-base
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   102
  $ cd merge-base
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   103
  $ echo 0 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   104
  $ hg -q commit -A -m initial
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   105
  $ echo h1 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   106
  $ hg commit -m 'head 1'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   107
  $ hg -q up 0
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   108
  $ echo h2 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   109
  $ hg -q commit -m 'head 2'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   110
  $ hg phase --public -r 0:tip
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   111
  $ hg -q up 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   112
  $ hg merge -t :local 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   113
  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   114
  (branch merge, don't forget to commit)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   115
  $ hg commit -m 'merge heads'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   116
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   117
TODO doesn't yet handle case where wdir is a draft merge
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   118
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   119
  $ hg show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   120
    @  8ee90 merge heads
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   121
   /   (stack base)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   122
  o  59478 head 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   123
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   124
  $ echo d1 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   125
  $ hg commit -m 'draft 1'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   126
  $ echo d2 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   127
  $ hg commit -m 'draft 2'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   128
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   129
  $ hg show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   130
    @  430d5 draft 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   131
    o  787b1 draft 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   132
   /   (stack base)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   133
  o  8ee90 merge heads
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   134
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   135
  $ cd ..
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   136
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   137
Now move on to stacks when there are more commits after the base branchpoint
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   138
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   139
  $ hg init public-rebase
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   140
  $ cd public-rebase
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   141
  $ echo 0 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   142
  $ hg -q commit -A -m 'base'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   143
  $ hg phase --public -r .
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   144
  $ echo d1 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   145
  $ hg commit -m 'draft 1'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   146
  $ echo d2 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   147
  $ hg commit -m 'draft 2'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   148
  $ hg -q up 0
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   149
  $ echo 1 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   150
  $ hg commit -m 'new 1'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   151
  created new head
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   152
  $ echo 2 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   153
  $ hg commit -m 'new 2'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   154
  $ hg -q up 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   155
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   156
Newer draft heads don't impact output
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   157
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   158
  $ hg show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   159
    @  eaffc draft 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   160
    o  2b218 draft 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   161
   /   (stack base)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   162
  o  b66bb base
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   163
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   164
Newer public heads are rendered
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   165
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   166
  $ hg phase --public -r '::tip'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   167
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   168
  $ hg show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   169
    o  baa4b new 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   170
   /    (2 commits ahead)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   171
  :
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   172
  :    (stack head)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   173
  : @  eaffc draft 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   174
  : o  2b218 draft 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   175
  :/   (stack base)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   176
  o  b66bb base
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   177
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   178
If rebase is available, we show a hint how to rebase to that head
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   179
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   180
  $ hg --config extensions.rebase= show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   181
    o  baa4b new 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   182
   /    (2 commits ahead; hg rebase --source 2b218 --dest baa4b)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   183
  :
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   184
  :    (stack head)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   185
  : @  eaffc draft 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   186
  : o  2b218 draft 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   187
  :/   (stack base)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   188
  o  b66bb base
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   189
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   190
Similar tests but for multiple heads
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   191
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   192
  $ hg -q up 0
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   193
  $ echo h2 > foo
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   194
  $ hg -q commit -m 'new head 2'
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   195
  $ hg phase --public -r .
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   196
  $ hg -q up 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   197
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   198
  $ hg show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   199
    o  baa4b new 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   200
   /    (2 commits ahead)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   201
  : o  9a848 new head 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   202
  :/    (1 commits ahead)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   203
  :
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   204
  :    (stack head)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   205
  : @  eaffc draft 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   206
  : o  2b218 draft 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   207
  :/   (stack base)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   208
  o  b66bb base
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   209
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   210
  $ hg --config extensions.rebase= show stack
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   211
    o  baa4b new 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   212
   /    (2 commits ahead; hg rebase --source 2b218 --dest baa4b)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   213
  : o  9a848 new head 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   214
  :/    (1 commits ahead; hg rebase --source 2b218 --dest 9a848)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   215
  :
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   216
  :    (stack head)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   217
  : @  eaffc draft 2
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   218
  : o  2b218 draft 1
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   219
  :/   (stack base)
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   220
  o  b66bb base