# HG changeset patch # User Nicolas Dumazet # Date 1281877643 -32400 # Node ID 0e4bbe18ff955db782ff64ad82d7282f6a9d6d95 # Parent 286693eaba476903ee8c99b689c719f8b230cf36 tests: unify test-mq-caches diff -r 286693eaba47 -r 0e4bbe18ff95 tests/test-mq-caches --- a/tests/test-mq-caches Sun Aug 15 21:58:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -#!/bin/sh - -branches=.hg/branchheads.cache -echo '[extensions]' >> $HGRCPATH -echo 'mq =' >> $HGRCPATH - -show_branch_cache() -{ - # force cache (re)generation - hg log -r does-not-exist 2> /dev/null - hg log -r tip --template 'tip: {rev}\n' - if [ -f $branches ]; then - sort $branches - else - echo No branch cache - fi - if [ "$1" = 1 ]; then - for b in foo bar; do - hg log -r $b --template "branch $b: "'{rev}\n' - done - fi -} - -hg init a -cd a -hg qinit -c - -echo '# mq patch on an empty repo' -hg qnew p1 -show_branch_cache - -echo > pfile -hg add pfile -hg qrefresh -m 'patch 1' -show_branch_cache - -echo -echo '# some regular revisions' -hg qpop -echo foo > foo -hg add foo -echo foo > .hg/branch -hg ci -m 'branch foo' -d '1000000 0' - -echo bar > bar -hg add bar -echo bar > .hg/branch -hg ci -m 'branch bar' -d '1000000 0' -show_branch_cache - -echo -echo '# add some mq patches' -hg qpush -show_branch_cache - -hg qnew p2 -echo foo > .hg/branch -echo foo2 >> foo -hg qrefresh -m 'patch 2' -show_branch_cache 1 - -echo -echo '# removing the cache' -rm $branches -show_branch_cache 1 - -echo -echo '# importing rev 1 (the cache now ends in one of the patches)' -hg qimport -r 1 -n p0 -show_branch_cache 1 -hg log -r qbase --template 'qbase: {rev}\n' - -echo -echo '# detect an invalid cache' -hg qpop -a -hg qpush -a -show_branch_cache - diff -r 286693eaba47 -r 0e4bbe18ff95 tests/test-mq-caches.out --- a/tests/test-mq-caches.out Sun Aug 15 21:58:43 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -# mq patch on an empty repo -tip: 0 -No branch cache -tip: 0 -No branch cache - -# some regular revisions -popping p1 -patch queue now empty -tip: 1 -3f910abad313ff802d3a23a7529433872df9b3ae 1 -3f910abad313ff802d3a23a7529433872df9b3ae bar -9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo - -# add some mq patches -applying p1 -now at: p1 -tip: 2 -3f910abad313ff802d3a23a7529433872df9b3ae 1 -3f910abad313ff802d3a23a7529433872df9b3ae bar -9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo -tip: 3 -3f910abad313ff802d3a23a7529433872df9b3ae 1 -3f910abad313ff802d3a23a7529433872df9b3ae bar -9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo -branch foo: 3 -branch bar: 2 - -# removing the cache -tip: 3 -3f910abad313ff802d3a23a7529433872df9b3ae 1 -3f910abad313ff802d3a23a7529433872df9b3ae bar -9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo -branch foo: 3 -branch bar: 2 - -# importing rev 1 (the cache now ends in one of the patches) -tip: 3 -3f910abad313ff802d3a23a7529433872df9b3ae 1 -3f910abad313ff802d3a23a7529433872df9b3ae bar -9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo -branch foo: 3 -branch bar: 2 -qbase: 1 - -# detect an invalid cache -popping p2 -popping p1 -popping p0 -patch queue now empty -applying p0 -applying p1 -applying p2 -now at: p2 -tip: 3 -9539f35bdc80732cc9a3f84e46508f1ed1ec8cff 0 -9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo diff -r 286693eaba47 -r 0e4bbe18ff95 tests/test-mq-caches.t --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-mq-caches.t Sun Aug 15 22:07:23 2010 +0900 @@ -0,0 +1,124 @@ + $ branches=.hg/branchheads.cache + $ echo '[extensions]' >> $HGRCPATH + $ echo 'mq =' >> $HGRCPATH + + $ show_branch_cache() + > { + > # force cache (re)generation + > hg log -r does-not-exist 2> /dev/null + > hg log -r tip --template 'tip: {rev}\n' + > if [ -f $branches ]; then + > sort $branches + > else + > echo No branch cache + > fi + > if [ "$1" = 1 ]; then + > for b in foo bar; do + > hg log -r $b --template "branch $b: "'{rev}\n' + > done + > fi + > } + + $ hg init a + $ cd a + $ hg qinit -c + + +mq patch on an empty repo + + $ hg qnew p1 + $ show_branch_cache + tip: 0 + No branch cache + + $ echo > pfile + $ hg add pfile + $ hg qrefresh -m 'patch 1' + $ show_branch_cache + tip: 0 + No branch cache + +some regular revisions + + $ hg qpop + popping p1 + patch queue now empty + $ echo foo > foo + $ hg add foo + $ echo foo > .hg/branch + $ hg ci -m 'branch foo' -d '1000000 0' + + $ echo bar > bar + $ hg add bar + $ echo bar > .hg/branch + $ hg ci -m 'branch bar' -d '1000000 0' + $ show_branch_cache + tip: 1 + 3f910abad313ff802d3a23a7529433872df9b3ae 1 + 3f910abad313ff802d3a23a7529433872df9b3ae bar + 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo + +add some mq patches + + $ hg qpush + applying p1 + now at: p1 + $ show_branch_cache + tip: 2 + 3f910abad313ff802d3a23a7529433872df9b3ae 1 + 3f910abad313ff802d3a23a7529433872df9b3ae bar + 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo + + $ hg qnew p2 + $ echo foo > .hg/branch + $ echo foo2 >> foo + $ hg qrefresh -m 'patch 2' + $ show_branch_cache 1 + tip: 3 + 3f910abad313ff802d3a23a7529433872df9b3ae 1 + 3f910abad313ff802d3a23a7529433872df9b3ae bar + 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo + branch foo: 3 + branch bar: 2 + +removing the cache + + $ rm $branches + $ show_branch_cache 1 + tip: 3 + 3f910abad313ff802d3a23a7529433872df9b3ae 1 + 3f910abad313ff802d3a23a7529433872df9b3ae bar + 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo + branch foo: 3 + branch bar: 2 + +importing rev 1 (the cache now ends in one of the patches) + + $ hg qimport -r 1 -n p0 + $ show_branch_cache 1 + tip: 3 + 3f910abad313ff802d3a23a7529433872df9b3ae 1 + 3f910abad313ff802d3a23a7529433872df9b3ae bar + 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo + branch foo: 3 + branch bar: 2 + $ hg log -r qbase --template 'qbase: {rev}\n' + qbase: 1 + +detect an invalid cache + + $ hg qpop -a + popping p2 + popping p1 + popping p0 + patch queue now empty + $ hg qpush -a + applying p0 + applying p1 + applying p2 + now at: p2 + $ show_branch_cache + tip: 3 + 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff 0 + 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo +