Mercurial > hg-stable
diff tests/test-show.t @ 34203: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 | 4441c1113eb2 |
children | 51057ab0dffa |
line wrap: on
line diff
--- a/tests/test-show.t Thu Aug 03 21:51:34 2017 -0700 +++ b/tests/test-show.t Wed Sep 13 21:15:46 2017 -0700 @@ -95,8 +95,8 @@ $ hg bookmark a-longer-bookmark $ hg show bookmarks - * a-longer-bookmark 7b570 - book1 b757f + * a-longer-bookmark 7b57 + book1 b757 A custom bookmarks template works @@ -113,14 +113,14 @@ "bookmark": "a-longer-bookmark", "longestbookmarklen": 17, "node": "7b5709ab64cbc34da9b4367b64afff47f2c4ee83", - "nodelen": 5 + "nodelen": 4 }, { "active": false, "bookmark": "book1", "longestbookmarklen": 17, "node": "b757f780b8ffd71267c6ccb32e0882d9d32a8cc0", - "nodelen": 5 + "nodelen": 4 } ] @@ -138,19 +138,19 @@ (no bookmarks set) $ hg --config commands.show.aliasprefix=sh shwork - @ 7b570 commit for book2 - o b757f commit for book1 - o ba592 initial + @ 7b57 commit for book2 + o b757 commit for book1 + o ba59 initial $ hg --config commands.show.aliasprefix='s sh' swork - @ 7b570 commit for book2 - o b757f commit for book1 - o ba592 initial + @ 7b57 commit for book2 + o b757 commit for book1 + o ba59 initial $ hg --config commands.show.aliasprefix='s sh' shwork - @ 7b570 commit for book2 - o b757f commit for book1 - o ba592 initial + @ 7b57 commit for book2 + o b757 commit for book1 + o ba59 initial The aliases don't appear in `hg config`