# HG changeset patch # User Matt Mackall # Date 2010-09-26 21:53:06 # Node ID 9a0528fd9172ed65a3dea9d501dc8028dd1047ba # Parent 9892949bd969cd6df0889c5138d8de211a2b6259 tests: unify test-convert-hg-svn diff --git a/tests/test-convert-hg-svn.out b/tests/test-convert-hg-svn.out deleted file mode 100644 --- a/tests/test-convert-hg-svn.out +++ /dev/null @@ -1,38 +0,0 @@ -Checked out revision 0. -A a -Adding a -Transmitting file data . -Committed revision 1. -% initial roundtrip -scanning source... -sorting... -converting... -0 added a -scanning source... -sorting... -converting... -% second roundtrip should do nothing -scanning source... -sorting... -converting... -scanning source... -sorting... -converting... -% new hg rev -updating to branch default -1 files updated, 0 files merged, 0 files removed, 0 files unresolved -% adding an empty revision -% echo hg to svn -scanning source... -sorting... -converting... -1 b -0 emtpy -% svn back to hg should do nothing -scanning source... -sorting... -converting... -% hg back to svn should do nothing -scanning source... -sorting... -converting... diff --git a/tests/test-convert-hg-svn b/tests/test-convert-hg-svn.t old mode 100755 new mode 100644 rename from tests/test-convert-hg-svn rename to tests/test-convert-hg-svn.t --- a/tests/test-convert-hg-svn +++ b/tests/test-convert-hg-svn.t @@ -1,79 +1,108 @@ -#!/bin/sh - -"$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' -#!/bin/sh - -REPOS="$1" -REV="$2" -USER="$3" -PROPNAME="$4" -ACTION="$5" + $ "$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 < #!/bin/sh + > + > REPOS="$1" + > REV="$2" + > USER="$3" + > PROPNAME="$4" + > ACTION="$5" + > + > if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi + > if [ "$ACTION" = "A" -a "$PROPNAME" = "hg:convert-branch" ]; then exit 0; fi + > if [ "$ACTION" = "A" -a "$PROPNAME" = "hg:convert-rev" ]; then exit 0; fi + > + > 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 + Checked out revision 0. + $ cd "$svnpath"-wc + $ echo a > a + $ svn add a + A a + $ svn ci -m'added a' a + Adding a + Transmitting file data . + Committed revision 1. + $ cd .. -if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi -if [ "$ACTION" = "A" -a "$PROPNAME" = "hg:convert-branch" ]; then exit 0; fi -if [ "$ACTION" = "A" -a "$PROPNAME" = "hg:convert-rev" ]; then exit 0; fi - -echo "Changing prohibited revision property" >&2 -exit 1 -EOF -chmod +x "$svnpath"/hooks/pre-revprop-change +initial roundtrip -# SVN wants all paths to start with a slash. Unfortunately, -# Windows ones don't. Handle that. -svnurl="$svnpath" -expr "$svnurl" : "\/" > /dev/null -if [ $? -ne 0 ]; then - svnurl="/$svnurl" -fi -svnurl="file://$svnurl" -svn co "$svnurl" "$svnpath"-wc + $ hg convert -s svn -d hg "$svnpath"-wc "$svnpath"-hg | grep -v initializing + scanning source... + sorting... + converting... + 0 added a + $ hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc + scanning source... + sorting... + converting... -cd "$svnpath"-wc -echo a > a -svn add a -svn ci -m'added a' a +second roundtrip should do nothing -cd .. + $ hg convert -s svn -d hg "$svnpath"-wc "$svnpath"-hg + scanning source... + sorting... + converting... + $ hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc + scanning source... + sorting... + converting... -echo % initial roundtrip -hg convert -s svn -d hg "$svnpath"-wc "$svnpath"-hg | grep -v initializing -hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc +new hg rev -echo % second roundtrip should do nothing -hg convert -s svn -d hg "$svnpath"-wc "$svnpath"-hg -hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc + $ hg clone "$svnpath"-hg "$svnpath"-work + updating to branch default + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ cd "$svnpath"-work + $ echo b > b + $ hg add b + $ hg ci -mb -echo % new hg rev +adding an empty revision + + $ hg qnew -m emtpy empty + $ hg qfinish -a + $ cd .. + +echo hg to svn -hg clone "$svnpath"-hg "$svnpath"-work -cd "$svnpath"-work -echo b > b -hg add b -hg ci -mb -echo '% adding an empty revision' -hg qnew -m emtpy empty -hg qfinish -a -cd .. + $ hg --cwd "$svnpath"-hg pull -q "$svnpath"-work + $ hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc + scanning source... + sorting... + converting... + 1 b + 0 emtpy + +svn back to hg should do nothing -echo % echo hg to svn -hg --cwd "$svnpath"-hg pull -q "$svnpath"-work -hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc + $ hg convert -s svn -d hg "$svnpath"-wc "$svnpath"-hg + scanning source... + sorting... + converting... -echo % svn back to hg should do nothing -hg convert -s svn -d hg "$svnpath"-wc "$svnpath"-hg -echo % hg back to svn should do nothing -hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc +hg back to svn should do nothing + + $ hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc + scanning source... + sorting... + converting...