##// END OF EJS Templates
show: use consistent (and possibly shorter) node lengths...
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

File last commit:

r33768:6c1a9fd8 default
r34192:e6b5e732 default
Show More
test-cache-abuse.t
97 lines | 2.4 KiB | text/troff | Tads3Lexer
/ tests / test-cache-abuse.t
Matt Mackall
tests: test a variety of cache invariants...
r29041 Enable obsolete markers
$ cat >> $HGRCPATH << EOF
> [experimental]
Boris Feld
test: update evolution config...
r33768 > stabilization=createmarkers
Matt Mackall
tests: test a variety of cache invariants...
r29041 > [phases]
> publish=False
> EOF
Build a repo with some cacheable bits:
$ hg init a
$ cd a
$ echo a > a
$ hg ci -qAm0
$ hg tag t1
$ hg book -i bk1
$ hg branch -q b2
$ hg ci -Am1
$ hg tag t2
$ echo dumb > dumb
$ hg ci -qAmdumb
$ hg debugobsolete b1174d11b69e63cb0c5726621a43c859f0858d7f
Boris Feld
debugobsolete: also report the number of obsoleted changesets...
r33542 obsoleted 1 changesets
Matt Mackall
tests: test a variety of cache invariants...
r29041
$ hg phase -pr t1
$ hg phase -fsr t2
Make a helper function to check cache damage invariants:
- command output shouldn't change
- cache should be present after first use
- corruption/repair should be silent (no exceptions or warnings)
- cache should survive deletion, overwrite, and append
- unreadable / unwriteable caches should be ignored
- cache should be rebuilt after corruption
$ damage() {
> CMD=$1
> CACHE=.hg/cache/$2
> CLEAN=$3
> hg $CMD > before
> test -f $CACHE || echo "not present"
> echo bad > $CACHE
> test -z "$CLEAN" || $CLEAN
> hg $CMD > after
FUJIWARA Katsunori
tests: use pdiff instead of diff for portability...
r33614 > "$RUNTESTDIR/pdiff" before after || echo "*** overwrite corruption"
Matt Mackall
tests: test a variety of cache invariants...
r29041 > echo corruption >> $CACHE
> test -z "$CLEAN" || $CLEAN
> hg $CMD > after
FUJIWARA Katsunori
tests: use pdiff instead of diff for portability...
r33614 > "$RUNTESTDIR/pdiff" before after || echo "*** append corruption"
Matt Mackall
tests: test a variety of cache invariants...
r29041 > rm $CACHE
> mkdir $CACHE
> test -z "$CLEAN" || $CLEAN
> hg $CMD > after
FUJIWARA Katsunori
tests: use pdiff instead of diff for portability...
r33614 > "$RUNTESTDIR/pdiff" before after || echo "*** read-only corruption"
Matt Mackall
tests: test a variety of cache invariants...
r29041 > test -d $CACHE || echo "*** directory clobbered"
> rmdir $CACHE
> test -z "$CLEAN" || $CLEAN
> hg $CMD > after
FUJIWARA Katsunori
tests: use pdiff instead of diff for portability...
r33614 > "$RUNTESTDIR/pdiff" before after || echo "*** missing corruption"
Matt Mackall
tests: test a variety of cache invariants...
r29041 > test -f $CACHE || echo "not rebuilt"
> }
Beat up tags caches:
$ damage "tags --hidden" tags2
$ damage tags tags2-visible
$ damage "tag -f t3" hgtagsfnodes1
Beat up branch caches:
$ damage branches branch2-base "rm .hg/cache/branch2-[vs]*"
$ damage branches branch2-served "rm .hg/cache/branch2-[bv]*"
$ damage branches branch2-visible
$ damage "log -r branch(.)" rbc-names-v1
$ damage "log -r branch(default)" rbc-names-v1
$ damage "log -r branch(b2)" rbc-revs-v1
We currently can't detect an rbc cache with unknown names:
$ damage "log -qr branch(b2)" rbc-names-v1
--- before * (glob)
+++ after * (glob)
Danek Duvall
test-cache-abuse: correct for different hunk headers between Solaris and GNU...
r29255 @@ -1,8 +?,0 @@ (glob)
Matt Mackall
tests: test a variety of cache invariants...
r29041 -2:5fb7d38b9dc4
-3:60b597ffdafa
-4:b1174d11b69e
-5:6354685872c0
-6:5ebc725f1bef
-7:7b76eec2f273
-8:ef3428d9d644
-9:ba7a936bc03c
*** append corruption