comparison tests/test-show-stack.t @ 34191:e6b5e7329ff2

show: use consistent (and possibly shorter) node lengths `hg show` makes heavy use of shortest() to limit the length of the node hash. For the "stack" and "work" views, you are often looking at multiple lines of similar output for "lines" of work. It is visually appeasing for things to vertically align. A naive use of {shortest(node, N)} could result in variable length nodes and for the first character of the description to vary by a column or two. We implement a function to determine the longest shortest prefix for a set of revisions. The new function is used to determine the printed node length for all `hg show` views. .. feature:: show: use consistent node length in views Our previous shortest node length of 5 was arbitrarily chosen. shortest() already does the work of ensuring that a partial node isn't ambiguous with an integer revision, which is our primary risk of a collision for very short nodes. It should be safe to go with the shortest node possible. Existing code is also optimized to handle nodes as short as 4. So, we decrease the minimum hash length from 5 to 4. We also add a test demonstrating that prefix collisions increase the node length. .. feature:: show: decrease minimum displayed hash length from 5 to 4 Differential Revision: https://phab.mercurial-scm.org/D558
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 13 Sep 2017 21:15:46 -0700
parents 9e7efe421395
children
comparison
equal deleted inserted replaced
34190:4441c1113eb2 34191:e6b5e7329ff2
15 Stack displays single draft changeset as root revision 15 Stack displays single draft changeset as root revision
16 16
17 $ echo 0 > foo 17 $ echo 0 > foo
18 $ hg -q commit -A -m 'commit 0' 18 $ hg -q commit -A -m 'commit 0'
19 $ hg show stack 19 $ hg show stack
20 @ 9f171 commit 0 20 @ 9f17 commit 0
21 21
22 Stack displays multiple draft changesets 22 Stack displays multiple draft changesets
23 23
24 $ echo 1 > foo 24 $ echo 1 > foo
25 $ hg commit -m 'commit 1' 25 $ hg commit -m 'commit 1'
28 $ echo 3 > foo 28 $ echo 3 > foo
29 $ hg commit -m 'commit 3' 29 $ hg commit -m 'commit 3'
30 $ echo 4 > foo 30 $ echo 4 > foo
31 $ hg commit -m 'commit 4' 31 $ hg commit -m 'commit 4'
32 $ hg show stack 32 $ hg show stack
33 @ 2737b commit 4 33 @ 2737 commit 4
34 o d1a69 commit 3 34 o d1a6 commit 3
35 o 128c8 commit 2 35 o 128c commit 2
36 o 181cc commit 1 36 o 181c commit 1
37 o 9f171 commit 0 37 o 9f17 commit 0
38 38
39 Public parent of draft base is displayed, separated from stack 39 Public parent of draft base is displayed, separated from stack
40 40
41 $ hg phase --public -r 0 41 $ hg phase --public -r 0
42 $ hg show stack 42 $ hg show stack
43 @ 2737b commit 4 43 @ 2737 commit 4
44 o d1a69 commit 3 44 o d1a6 commit 3
45 o 128c8 commit 2 45 o 128c commit 2
46 o 181cc commit 1 46 o 181c commit 1
47 / (stack base) 47 / (stack base)
48 o 9f171 commit 0 48 o 9f17 commit 0
49 49
50 $ hg phase --public -r 1 50 $ hg phase --public -r 1
51 $ hg show stack 51 $ hg show stack
52 @ 2737b commit 4 52 @ 2737 commit 4
53 o d1a69 commit 3 53 o d1a6 commit 3
54 o 128c8 commit 2 54 o 128c commit 2
55 / (stack base) 55 / (stack base)
56 o 181cc commit 1 56 o 181c commit 1
57 57
58 Draft descendants are shown 58 Draft descendants are shown
59 59
60 $ hg -q up 2 60 $ hg -q up 2
61 $ hg show stack 61 $ hg show stack
62 o 2737b commit 4 62 o 2737 commit 4
63 o d1a69 commit 3 63 o d1a6 commit 3
64 @ 128c8 commit 2 64 @ 128c commit 2
65 / (stack base) 65 / (stack base)
66 o 181cc commit 1 66 o 181c commit 1
67 67
68 $ hg -q up 3 68 $ hg -q up 3
69 $ hg show stack 69 $ hg show stack
70 o 2737b commit 4 70 o 2737 commit 4
71 @ d1a69 commit 3 71 @ d1a6 commit 3
72 o 128c8 commit 2 72 o 128c commit 2
73 / (stack base) 73 / (stack base)
74 o 181cc commit 1 74 o 181c commit 1
75 75
76 working dir on public changeset should display special message 76 working dir on public changeset should display special message
77 77
78 $ hg -q up 1 78 $ hg -q up 1
79 $ hg show stack 79 $ hg show stack
87 created new head 87 created new head
88 $ hg -q up 2 88 $ hg -q up 2
89 $ hg show stack 89 $ hg show stack
90 \ / (multiple children) 90 \ / (multiple children)
91 | 91 |
92 o d1a69 commit 3 92 o d1a6 commit 3
93 @ 128c8 commit 2 93 @ 128c commit 2
94 / (stack base) 94 / (stack base)
95 o 181cc commit 1 95 o 181c commit 1
96 96
97 $ cd .. 97 $ cd ..
98 98
99 Base is stopped at merges 99 Base is stopped at merges
100 100
115 $ hg commit -m 'merge heads' 115 $ hg commit -m 'merge heads'
116 116
117 TODO doesn't yet handle case where wdir is a draft merge 117 TODO doesn't yet handle case where wdir is a draft merge
118 118
119 $ hg show stack 119 $ hg show stack
120 @ 8ee90 merge heads 120 @ 8ee9 merge heads
121 / (stack base) 121 / (stack base)
122 o 59478 head 1 122 o 5947 head 1
123 123
124 $ echo d1 > foo 124 $ echo d1 > foo
125 $ hg commit -m 'draft 1' 125 $ hg commit -m 'draft 1'
126 $ echo d2 > foo 126 $ echo d2 > foo
127 $ hg commit -m 'draft 2' 127 $ hg commit -m 'draft 2'
128 128
129 $ hg show stack 129 $ hg show stack
130 @ 430d5 draft 2 130 @ 430d draft 2
131 o 787b1 draft 1 131 o 787b draft 1
132 / (stack base) 132 / (stack base)
133 o 8ee90 merge heads 133 o 8ee9 merge heads
134 134
135 $ cd .. 135 $ cd ..
136 136
137 Now move on to stacks when there are more commits after the base branchpoint 137 Now move on to stacks when there are more commits after the base branchpoint
138 138
154 $ hg -q up 2 154 $ hg -q up 2
155 155
156 Newer draft heads don't impact output 156 Newer draft heads don't impact output
157 157
158 $ hg show stack 158 $ hg show stack
159 @ eaffc draft 2 159 @ eaff draft 2
160 o 2b218 draft 1 160 o 2b21 draft 1
161 / (stack base) 161 / (stack base)
162 o b66bb base 162 o b66b base
163 163
164 Newer public heads are rendered 164 Newer public heads are rendered
165 165
166 $ hg phase --public -r '::tip' 166 $ hg phase --public -r '::tip'
167 167
168 $ hg show stack 168 $ hg show stack
169 o baa4b new 2 169 o baa4 new 2
170 / (2 commits ahead) 170 / (2 commits ahead)
171 : 171 :
172 : (stack head) 172 : (stack head)
173 : @ eaffc draft 2 173 : @ eaff draft 2
174 : o 2b218 draft 1 174 : o 2b21 draft 1
175 :/ (stack base) 175 :/ (stack base)
176 o b66bb base 176 o b66b base
177 177
178 If rebase is available, we show a hint how to rebase to that head 178 If rebase is available, we show a hint how to rebase to that head
179 179
180 $ hg --config extensions.rebase= show stack 180 $ hg --config extensions.rebase= show stack
181 o baa4b new 2 181 o baa4 new 2
182 / (2 commits ahead; hg rebase --source 2b218 --dest baa4b) 182 / (2 commits ahead; hg rebase --source 2b21 --dest baa4)
183 : 183 :
184 : (stack head) 184 : (stack head)
185 : @ eaffc draft 2 185 : @ eaff draft 2
186 : o 2b218 draft 1 186 : o 2b21 draft 1
187 :/ (stack base) 187 :/ (stack base)
188 o b66bb base 188 o b66b base
189 189
190 Similar tests but for multiple heads 190 Similar tests but for multiple heads
191 191
192 $ hg -q up 0 192 $ hg -q up 0
193 $ echo h2 > foo 193 $ echo h2 > foo
194 $ hg -q commit -m 'new head 2' 194 $ hg -q commit -m 'new head 2'
195 $ hg phase --public -r . 195 $ hg phase --public -r .
196 $ hg -q up 2 196 $ hg -q up 2
197 197
198 $ hg show stack 198 $ hg show stack
199 o baa4b new 2 199 o baa4 new 2
200 / (2 commits ahead) 200 / (2 commits ahead)
201 : o 9a848 new head 2 201 : o 9a84 new head 2
202 :/ (1 commits ahead) 202 :/ (1 commits ahead)
203 : 203 :
204 : (stack head) 204 : (stack head)
205 : @ eaffc draft 2 205 : @ eaff draft 2
206 : o 2b218 draft 1 206 : o 2b21 draft 1
207 :/ (stack base) 207 :/ (stack base)
208 o b66bb base 208 o b66b base
209 209
210 $ hg --config extensions.rebase= show stack 210 $ hg --config extensions.rebase= show stack
211 o baa4b new 2 211 o baa4 new 2
212 / (2 commits ahead; hg rebase --source 2b218 --dest baa4b) 212 / (2 commits ahead; hg rebase --source 2b21 --dest baa4)
213 : o 9a848 new head 2 213 : o 9a84 new head 2
214 :/ (1 commits ahead; hg rebase --source 2b218 --dest 9a848) 214 :/ (1 commits ahead; hg rebase --source 2b21 --dest 9a84)
215 : 215 :
216 : (stack head) 216 : (stack head)
217 : @ eaffc draft 2 217 : @ eaff draft 2
218 : o 2b218 draft 1 218 : o 2b21 draft 1
219 :/ (stack base) 219 :/ (stack base)
220 o b66bb base 220 o b66b base