diff tests/test-convert-hg-svn.t @ 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 9a0528fd9172
children e61a8395c3c1
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...