# HG changeset patch # User Mads Kiilerich # Date 2012-06-26 01:35:22 # Node ID 0413f68da85c943a1754c5d0e67bc743edc57381 # Parent 7dd82e0c43ea34f0b3f9b38f0fcd843800f1799c 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. diff --git a/tests/test-convert-hg-svn.t b/tests/test-convert-hg-svn.t --- a/tests/test-convert-hg-svn.t +++ b/tests/test-convert-hg-svn.t @@ -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 < "$SVNREPOPATH"/hooks/pre-revprop-change < #!/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 @@ adding an empty revision 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 @@ echo hg to svn 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... diff --git a/tests/test-convert-svn-move.t b/tests/test-convert-svn-move.t --- a/tests/test-convert-svn-move.t +++ b/tests/test-convert-svn-move.t @@ -1,10 +1,6 @@ $ "$TESTDIR/hghave" svn svn-bindings || exit 80 - $ fixpath() - > { - > tr '\\' / - > } $ cat >> $HGRCPATH < [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... diff --git a/tests/test-convert-svn-sink.t b/tests/test-convert-svn-sink.t --- a/tests/test-convert-svn-sink.t +++ b/tests/test-convert-svn-sink.t @@ -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" diff --git a/tests/test-convert-svn-source.t b/tests/test-convert-svn-source.t --- a/tests/test-convert-svn-source.t +++ b/tests/test-convert-svn-source.t @@ -1,10 +1,6 @@ $ "$TESTDIR/hghave" svn svn-bindings || exit 80 - $ fixpath() - > { - > tr '\\' / - > } $ cat >> $HGRCPATH < [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 @@ Initial svn import $ 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 @@ Initial svn import 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 @@ Update svn repository 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 @@ Update svn repository 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 @@ Update svn repository again 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 @@ Update svn repository again 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 @@ Update svn repository again Test incremental conversion - $ hg convert "$svnurl" B-hg + $ hg convert "$SVNREPOURL/proj%20B" B-hg scanning source... sorting... converting... @@ -150,7 +143,7 @@ Test incremental conversion 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 filemap 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 @@ Test converting empty heads (issue3347) 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... diff --git a/tests/test-mq-subrepo-svn.t b/tests/test-mq-subrepo-svn.t --- a/tests/test-mq-subrepo-svn.t +++ b/tests/test-mq-subrepo-svn.t @@ -16,21 +16,23 @@ fn to create new repository, and cd into 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 diff --git a/tests/test-subrepo-svn.t b/tests/test-subrepo-svn.t --- a/tests/test-subrepo-svn.t +++ b/tests/test-subrepo-svn.t @@ -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 @@ create subversion repo 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 @@ first revision, no sub 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 @@ missing svn file, commit should fail 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 @@ should be empty despite change to s/a 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 @@ this commit fails because of externals m 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 @@ update to nullrev (must delete the subre $ 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 @@ Check hg update --clean 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 subrepo already at intended revisio 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 @@ are unknown directories being replaced b $ 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 @@ Modify one of the externals to point to 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 @@ First, create that condition in the repo 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 @@ First, create that condition in the repo 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 @@ First, create that condition in the repo 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 @@ Test a subrepo referencing a just moved 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 @@ well. 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