Mercurial > hg
changeset 17033:0413f68da85c
tests: cleanup of svn url handling
The subversion tests used different tricks to create properly encoded URLs,
partly due to partial support for different ways of running the tests on
windows. Now we only need/support one way of running the tests on windows.
Windows URLs should look like 'file:///c:/foo%20bar' and on Unix platforms
like 'file:///tmp/baz'.
'pwd' in the test framework will on Windows emit paths like 'c:/foo bar'.
Explicit handling of backslashes in paths is thus no longer needed and is
removed. Paths on windows do however need an extra '/' compared to other
platforms.
This change makes test-subrepo-svn.t pass on windows with msys. Other tests
might need more work.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Tue, 26 Jun 2012 03:35:22 +0200 |
parents | 7dd82e0c43ea |
children | ab4644c3064f |
files | tests/test-convert-hg-svn.t tests/test-convert-svn-move.t tests/test-convert-svn-sink.t tests/test-convert-svn-source.t tests/test-mq-subrepo-svn.t tests/test-subrepo-svn.t |
diffstat | 6 files changed, 98 insertions(+), 124 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test-convert-hg-svn.t Sat Jun 23 19:54:08 2012 +0300 +++ b/tests/test-convert-hg-svn.t Tue Jun 26 03:35:22 2012 +0200 @@ -1,15 +1,18 @@ $ "$TESTDIR/hghave" svn svn-bindings || exit 80 - $ fix_path() - > { - > tr '\\' / - > } $ echo "[extensions]" >> $HGRCPATH $ echo "convert = " >> $HGRCPATH $ echo "mq = " >> $HGRCPATH - $ svnpath=`pwd | fix_path`/svn-repo - $ svnadmin create "$svnpath" - $ cat > "$svnpath"/hooks/pre-revprop-change <<EOF + + $ SVNREPOPATH=`pwd`/svn-repo +#if windows + $ SVNREPOURL=file:///`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` +#else + $ SVNREPOURL=file://`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` +#endif + + $ svnadmin create "$SVNREPOPATH" + $ cat > "$SVNREPOPATH"/hooks/pre-revprop-change <<EOF > #!/bin/sh > > REPOS="$1" @@ -25,16 +28,10 @@ > echo "Changing prohibited revision property" >&2 > exit 1 > EOF - $ chmod +x "$svnpath"/hooks/pre-revprop-change - $ - $ # SVN wants all paths to start with a slash. Unfortunately, - $ # Windows ones don't. Handle that. - $ svnurl="$svnpath" - $ expr "$svnurl" : "\/" > /dev/null || svnurl="/$svnurl" - $ svnurl="file://$svnurl" - $ svn co "$svnurl" "$svnpath"-wc + $ chmod +x "$SVNREPOPATH"/hooks/pre-revprop-change + $ svn co "$SVNREPOURL" "$SVNREPOPATH"-wc Checked out revision 0. - $ cd "$svnpath"-wc + $ cd "$SVNREPOPATH"-wc $ echo a > a $ svn add a A a @@ -46,33 +43,33 @@ initial roundtrip - $ hg convert -s svn -d hg "$svnpath"-wc "$svnpath"-hg | grep -v initializing + $ hg convert -s svn -d hg "$SVNREPOPATH"-wc "$SVNREPOPATH"-hg | grep -v initializing scanning source... sorting... converting... 0 added a - $ hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc + $ hg convert -s hg -d svn "$SVNREPOPATH"-hg "$SVNREPOPATH"-wc scanning source... sorting... converting... second roundtrip should do nothing - $ hg convert -s svn -d hg "$svnpath"-wc "$svnpath"-hg + $ hg convert -s svn -d hg "$SVNREPOPATH"-wc "$SVNREPOPATH"-hg scanning source... sorting... converting... - $ hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc + $ hg convert -s hg -d svn "$SVNREPOPATH"-hg "$SVNREPOPATH"-wc scanning source... sorting... converting... new hg rev - $ hg clone "$svnpath"-hg "$svnpath"-work + $ hg clone "$SVNREPOPATH"-hg "$SVNREPOPATH"-work updating to branch default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved - $ cd "$svnpath"-work + $ cd "$SVNREPOPATH"-work $ echo b > b $ hg add b $ hg ci -mb @@ -85,8 +82,8 @@ echo hg to svn - $ hg --cwd "$svnpath"-hg pull -q "$svnpath"-work - $ hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc + $ hg --cwd "$SVNREPOPATH"-hg pull -q "$SVNREPOPATH"-work + $ hg convert -s hg -d svn "$SVNREPOPATH"-hg "$SVNREPOPATH"-wc scanning source... sorting... converting... @@ -95,14 +92,14 @@ svn back to hg should do nothing - $ hg convert -s svn -d hg "$svnpath"-wc "$svnpath"-hg + $ hg convert -s svn -d hg "$SVNREPOPATH"-wc "$SVNREPOPATH"-hg scanning source... sorting... converting... hg back to svn should do nothing - $ hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc + $ hg convert -s hg -d svn "$SVNREPOPATH"-hg "$SVNREPOPATH"-wc scanning source... sorting... converting...
--- a/tests/test-convert-svn-move.t Sat Jun 23 19:54:08 2012 +0300 +++ b/tests/test-convert-svn-move.t Tue Jun 26 03:35:22 2012 +0200 @@ -1,10 +1,6 @@ $ "$TESTDIR/hghave" svn svn-bindings || exit 80 - $ fixpath() - > { - > tr '\\' / - > } $ cat >> $HGRCPATH <<EOF > [extensions] > convert = @@ -13,20 +9,16 @@ $ svnadmin create svn-repo $ svnadmin load -q svn-repo < "$TESTDIR/svn/move.svndump" - $ svnpath=`pwd | fixpath` - -SVN wants all paths to start with a slash. Unfortunately, -Windows ones don't. Handle that. - - $ expr "$svnpath" : "\/" > /dev/null - > if [ $? -ne 0 ]; then - > svnpath="/$svnpath" - > fi - > svnurl="file://$svnpath/svn-repo" + $ SVNREPOPATH=`pwd`/svn-repo +#if windows + $ SVNREPOURL=file:///`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` +#else + $ SVNREPOURL=file://`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` +#endif Convert trunk and branches - $ hg convert --datesort "$svnurl"/subproject A-hg + $ hg convert --datesort "$SVNREPOURL"/subproject A-hg initializing destination A-hg repository scanning source... sorting...
--- a/tests/test-convert-svn-sink.t Sat Jun 23 19:54:08 2012 +0300 +++ b/tests/test-convert-svn-sink.t Tue Jun 26 03:35:22 2012 +0200 @@ -1,15 +1,11 @@ $ "$TESTDIR/hghave" svn13 || exit 80 - $ fixpath() - > { - > tr '\\' / - > } $ svnupanddisplay() > { > ( > cd $1; > svn up -q; - > svn st -v | fixpath | sed 's/ */ /g' | sort + > svn st -v | sed 's/ */ /g' | sort > limit='' > if [ $2 -gt 0 ]; then > limit="--limit=$2"
--- a/tests/test-convert-svn-source.t Sat Jun 23 19:54:08 2012 +0300 +++ b/tests/test-convert-svn-source.t Tue Jun 26 03:35:22 2012 +0200 @@ -1,10 +1,6 @@ $ "$TESTDIR/hghave" svn svn-bindings || exit 80 - $ fixpath() - > { - > tr '\\' / - > } $ cat >> $HGRCPATH <<EOF > [extensions] > convert = @@ -14,14 +10,12 @@ > EOF $ svnadmin create svn-repo - $ svnpath=`pwd | fixpath` - - - $ expr "$svnpath" : "\/" > /dev/null - > if [ $? -ne 0 ]; then - > svnpath="/$svnpath" - > fi - > svnurl="file://$svnpath/svn-repo" + $ SVNREPOPATH=`pwd`/svn-repo +#if windows + $ SVNREPOURL=file:///`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` +#else + $ SVNREPOURL=file://`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` +#endif Now test that it works with trunk/tags layout, but no branches yet. @@ -33,8 +27,7 @@ $ mkdir tags $ cd .. - $ svnurl="file://$svnpath/svn-repo/proj%20B" - $ svn import -m "init projB" projB "$svnurl" | fixpath | sort + $ svn import -m "init projB" projB "$SVNREPOURL/proj%20B" | sort Adding projB/mytrunk Adding projB/tags @@ -42,7 +35,7 @@ Update svn repository - $ svn co "$svnurl"/mytrunk B | fixpath + $ svn co "$SVNREPOURL/proj%20B/mytrunk" B Checked out revision 1. $ cd B $ echo hello > 'letter .txt' @@ -59,7 +52,7 @@ Transmitting file data . Committed revision 3. - $ svn copy -m "tag v0.1" "$svnurl"/mytrunk "$svnurl"/tags/v0.1 + $ svn copy -m "tag v0.1" "$SVNREPOURL/proj%20B/mytrunk" "$SVNREPOURL/proj%20B/tags/v0.1" Committed revision 4. @@ -72,7 +65,7 @@ Convert to hg once - $ hg convert "$svnurl" B-hg + $ hg convert "$SVNREPOURL/proj%20B" B-hg initializing destination B-hg repository scanning source... sorting... @@ -96,7 +89,7 @@ Transmitting file data .. Committed revision 6. - $ svn copy -m "tag v0.2" "$svnurl"/mytrunk "$svnurl"/tags/v0.2 + $ svn copy -m "tag v0.2" "$SVNREPOURL/proj%20B/mytrunk" "$SVNREPOURL/proj%20B/tags/v0.2" Committed revision 7. @@ -107,7 +100,7 @@ Committed revision 8. $ cd .. - $ hg convert -s svn "$svnurl/non-existent-path" dest + $ hg convert -s svn "$SVNREPOURL/proj%20B/non-existent-path" dest initializing destination dest repository abort: no revision found in module /proj B/non-existent-path [255] @@ -116,7 +109,7 @@ Test incremental conversion - $ hg convert "$svnurl" B-hg + $ hg convert "$SVNREPOURL/proj%20B" B-hg scanning source... sorting... converting... @@ -150,7 +143,7 @@ Test filemap $ echo 'include letter2.txt' > filemap - $ hg convert --filemap filemap "$svnurl"/mytrunk fmap + $ hg convert --filemap filemap "$SVNREPOURL/proj%20B/mytrunk" fmap initializing destination fmap repository scanning source... sorting... @@ -170,7 +163,7 @@ Test stop revision - $ hg convert --rev 1 "$svnurl"/mytrunk stoprev + $ hg convert --rev 1 "$SVNREPOURL/proj%20B/mytrunk" stoprev initializing destination stoprev repository scanning source... sorting... @@ -200,7 +193,7 @@ converting... 1 init projA 0 adddir - $ hg --config convert.svn.trunk= convert file://$svnpath/svn-empty/trunk + $ hg --config convert.svn.trunk= convert "$SVNREPOURL/../svn-empty/trunk" assuming destination trunk-hg initializing destination trunk-hg repository scanning source...
--- a/tests/test-mq-subrepo-svn.t Sat Jun 23 19:54:08 2012 +0300 +++ b/tests/test-mq-subrepo-svn.t Tue Jun 26 03:35:22 2012 +0200 @@ -16,21 +16,23 @@ handle svn subrepos safely $ svnadmin create svn-repo-2499 - $ curpath=`pwd | tr '\\\\' /` - $ expr "$svnpath" : "\/" > /dev/null - > if [ $? -ne 0 ]; then - > curpath="/$curpath" - > fi - $ svnurl="file://$curpath/svn-repo-2499/project" + + $ SVNREPOPATH=`pwd`/svn-repo-2499/project +#if windows + $ SVNREPOURL=file:///`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` +#else + $ SVNREPOURL=file://`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` +#endif + $ mkdir -p svn-project-2499/trunk - $ svn import -m 'init project' svn-project-2499 "$svnurl" + $ svn import -m 'init project' svn-project-2499 "$SVNREPOURL" Adding svn-project-2499/trunk (glob) Committed revision 1. qnew on repo w/svn subrepo $ mkrepo repo-2499-svn-subrepo - $ svn co "$svnurl"/trunk sub + $ svn co "$SVNREPOURL"/trunk sub Checked out revision 1. $ echo 'sub = [svn]sub' >> .hgsub $ hg add .hgsub
--- a/tests/test-subrepo-svn.t Sat Jun 23 19:54:08 2012 +0300 +++ b/tests/test-subrepo-svn.t Tue Jun 26 03:35:22 2012 +0200 @@ -1,23 +1,17 @@ $ "$TESTDIR/hghave" svn15 || exit 80 - $ fix_path() - > { - > tr '\\' / - > } - -SVN wants all paths to start with a slash. Unfortunately, Windows ones -don't. Handle that. - - $ escapedwd=`pwd | fix_path` - $ expr "$escapedwd" : '\/' > /dev/null || escapedwd="/$escapedwd" - $ escapedwd=`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$escapedwd"` + $ SVNREPOPATH=`pwd`/svn-repo +#if windows + $ SVNREPOURL=file:///`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` +#else + $ SVNREPOURL=file://`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` +#endif create subversion repo - $ SVNREPO="file://$escapedwd/svn-repo" $ WCROOT="`pwd`/svn-wc" $ svnadmin create svn-repo - $ svn co "$SVNREPO" svn-wc + $ svn co "$SVNREPOURL" svn-wc Checked out revision 0. $ cd svn-wc $ mkdir src @@ -38,7 +32,7 @@ Transmitting file data .. Committed revision 1. $ svn up -q - $ echo "externals -r1 $SVNREPO/externals" > extdef + $ echo "externals -r1 $SVNREPOURL/externals" > extdef $ svn propset -F extdef svn:externals src property 'svn:externals' set on 'src' $ svn ci -m 'Setting externals' @@ -62,11 +56,11 @@ add first svn sub with leading whitespaces - $ echo "s = [svn] $SVNREPO/src" >> .hgsub - $ echo "subdir/s = [svn] $SVNREPO/src" >> .hgsub - $ svn co --quiet "$SVNREPO"/src s + $ echo "s = [svn] $SVNREPOURL/src" >> .hgsub + $ echo "subdir/s = [svn] $SVNREPOURL/src" >> .hgsub + $ svn co --quiet "$SVNREPOURL"/src s $ mkdir subdir - $ svn co --quiet "$SVNREPO"/src subdir/s + $ svn co --quiet "$SVNREPOURL"/src subdir/s $ hg add .hgsub $ hg ci -m1 @@ -132,7 +126,7 @@ add an unrelated revision in svn and update the subrepo to without bringing any changes. - $ svn mkdir "$SVNREPO/unrelated" -m 'create unrelated' + $ svn mkdir "$SVNREPOURL/unrelated" -m 'create unrelated' Committed revision 4. $ svn up -q s @@ -151,7 +145,7 @@ add a commit from svn - $ cd "$WCROOT"/src + $ cd "$WCROOT/src" $ svn up -q $ echo xyz >> alpha $ svn propset svn:mime-type 'text/xml' alpha @@ -215,21 +209,21 @@ clone $ cd .. - $ hg clone t tc | fix_path + $ hg clone t tc updating to branch default - A tc/s/alpha - U tc/s + A tc/s/alpha (glob) + U tc/s (glob) Fetching external item into 'tc/s/externals'* (glob) - A tc/s/externals/other + A tc/s/externals/other (glob) Checked out external at revision 1. Checked out revision 3. - A tc/subdir/s/alpha - U tc/subdir/s + A tc/subdir/s/alpha (glob) + U tc/subdir/s (glob) Fetching external item into 'tc/subdir/s/externals'* (glob) - A tc/subdir/s/externals/other + A tc/subdir/s/externals/other (glob) Checked out external at revision 1. Checked out revision 2. @@ -258,7 +252,7 @@ $ ls Check hg update --clean - $ cd $TESTTMP/sub/t + $ cd "$TESTTMP/sub/t" $ cd s $ echo c0 > alpha $ echo c1 > f1 @@ -290,7 +284,7 @@ X * externals (glob) Sticky subrepositories, no changes - $ cd $TESTTMP/sub/t + $ cd "$TESTTMP/sub/t" $ hg id -n 2 $ cd s @@ -421,7 +415,7 @@ Test case where subversion would fail to update the subrepo because there are unknown directories being replaced by tracked ones (happens with rebase). - $ cd $WCROOT/src + $ cd "$WCROOT/src" $ mkdir dir $ echo epsilon.py > dir/epsilon.py $ svn add dir @@ -435,8 +429,8 @@ $ cd ../.. $ hg init rebaserepo $ cd rebaserepo - $ svn co -r5 --quiet "$SVNREPO"/src s - $ echo "s = [svn] $SVNREPO/src" >> .hgsub + $ svn co -r5 --quiet "$SVNREPOURL"/src s + $ echo "s = [svn] $SVNREPOURL/src" >> .hgsub $ hg add .hgsub $ hg ci -m addsub $ echo a > a @@ -462,14 +456,14 @@ test having obstructions when switching branches on checkout: $ hg checkout tip 0 files updated, 0 files merged, 0 files removed, 0 files unresolved - $ echo "obstruct = [svn] $SVNREPO/externals" >> .hgsub - $ svn co -r5 --quiet "$SVNREPO"/externals obstruct + $ echo "obstruct = [svn] $SVNREPOURL/externals" >> .hgsub + $ svn co -r5 --quiet "$SVNREPOURL"/externals obstruct $ hg commit -m 'Start making obstructed working copy' $ hg book other $ hg co -r 'p1(tip)' 2 files updated, 0 files merged, 0 files removed, 0 files unresolved - $ echo "obstruct = [svn] $SVNREPO/src" >> .hgsub - $ svn co -r5 --quiet "$SVNREPO"/src obstruct + $ echo "obstruct = [svn] $SVNREPOURL/src" >> .hgsub + $ svn co -r5 --quiet "$SVNREPOURL"/src obstruct $ hg commit -m 'Other branch which will be obstructed' created new head @@ -495,13 +489,13 @@ Transmitting file data . Committed revision 7. At revision 7. - $ svn mkdir -m "baseline" $SVNREPO/trunk + $ svn mkdir -m "baseline" $SVNREPOURL/trunk Committed revision 8. - $ svn copy -m "initial branch" $SVNREPO/trunk $SVNREPO/branch + $ svn copy -m "initial branch" $SVNREPOURL/trunk $SVNREPOURL/branch Committed revision 9. - $ svn co --quiet "$SVNREPO"/branch tempwc + $ svn co --quiet "$SVNREPOURL"/branch tempwc $ cd tempwc $ echo "something old" > somethingold $ svn add somethingold @@ -510,10 +504,10 @@ Adding somethingold Transmitting file data . Committed revision 10. - $ svn rm -m "remove branch" $SVNREPO/branch + $ svn rm -m "remove branch" $SVNREPOURL/branch Committed revision 11. - $ svn copy -m "recreate branch" $SVNREPO/trunk $SVNREPO/branch + $ svn copy -m "recreate branch" $SVNREPOURL/trunk $SVNREPOURL/branch Committed revision 12. $ svn up -q @@ -526,10 +520,10 @@ Committed revision 13. $ cd .. $ rm -rf tempwc - $ svn co "$SVNREPO/branch"@10 recreated + $ svn co "$SVNREPOURL/branch"@10 recreated A recreated/somethingold (glob) Checked out revision 10. - $ echo "recreated = [svn] $SVNREPO/branch" >> .hgsub + $ echo "recreated = [svn] $SVNREPOURL/branch" >> .hgsub $ hg ci -m addsub $ cd recreated $ svn up -q @@ -573,7 +567,7 @@ be different from the revision, and the path will be different as well. - $ cd $WCROOT + $ cd "$WCROOT" $ svn up > /dev/null $ mkdir trunk/subdir branches $ echo a > trunk/subdir/a @@ -587,17 +581,17 @@ Adding trunk/subdir/a (glob) Transmitting file data . Committed revision 14. - $ svn cp -m branchtrunk $SVNREPO/trunk $SVNREPO/branches/somebranch + $ svn cp -m branchtrunk $SVNREPOURL/trunk $SVNREPOURL/branches/somebranch Committed revision 15. $ cd .. $ hg init repo2 $ cd repo2 - $ svn co $SVNREPO/branches/somebranch/subdir + $ svn co $SVNREPOURL/branches/somebranch/subdir A subdir/a (glob) Checked out revision 15. - $ echo "subdir = [svn] $SVNREPO/branches/somebranch/subdir" > .hgsub + $ echo "subdir = [svn] $SVNREPOURL/branches/somebranch/subdir" > .hgsub $ hg add .hgsub $ hg ci -m addsub $ hg up null