Mercurial > public > mercurial-scm > hg
view tests/test-convert-hg-svn @ 11109:a2bc2f2d77a9
subrepo: normalize path part of URLs so that pulling subrepos from webdir works
For a "all projects at root" repo layout eg:
/main
/sub
Where subrepos are used such that a clone of main has this layout:
./main/
./main/.hgsub
./main/sub/
And the .hgsub content is:
sub = ../sub
This allows a pull from a hgweb where main and sub are exposed
at the root (or same directory level)
The current code doesn't normalize the path component of a pull
url. this results in trying to pull from
http://server.com/hg/main/../sub
Current hgweb implementation doesn't reduce the path component
so this results in a 404 error though everything is setup logically.
This patch adresses this 404 error on the puller side
normalizing the URLs used for pulling sub repos. For this
example, the URL would be reduced to http://server.com/hg/sub
Fix + test
author | Edouard Gomez <ed.gomez@free.fr> |
---|---|
date | Sat, 01 May 2010 23:05:19 +0200 |
parents | c52057614c72 |
children |
line wrap: on
line source
#!/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" 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 if [ $? -ne 0 ]; then svnurl="/$svnurl" fi svnurl="file://$svnurl" svn co "$svnurl" "$svnpath"-wc cd "$svnpath"-wc echo a > a svn add a svn ci -m'added a' a cd .. 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 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 echo % new hg rev 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 .. echo % echo hg to svn hg --cwd "$svnpath"-hg pull -q "$svnpath"-work hg convert -s hg -d svn "$svnpath"-hg "$svnpath"-wc 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