tests/test-convert-hg-svn
author David Soria Parra <dsp@php.net>
Sun, 07 Dec 2008 08:47:02 +0100
changeset 7485 ecfb683675ed
parent 5809 34c4131abdf9
child 10051 a02d43acbc04
permissions -rwxr-xr-x
Merge bookmarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5554
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     1
#!/bin/sh
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     2
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     3
"$TESTDIR/hghave" svn svn-bindings || exit 80
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     4
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     5
fix_path()
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     6
{
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     7
    tr '\\' /
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     8
}
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     9
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    10
echo "[extensions]" >> $HGRCPATH
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    11
echo "convert = " >> $HGRCPATH
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    12
5809
34c4131abdf9 test-convert-hg-svn: make it more windows friendly
Patrick Mezard <pmezard@gmail.com>
parents: 5554
diff changeset
    13
svnpath=`pwd | fix_path`/svn-repo
5554
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    14
svnadmin create $svnpath
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    15
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    16
cat > $svnpath/hooks/pre-revprop-change <<'EOF'
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    17
#!/bin/sh
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    18
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    19
REPOS="$1"
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    20
REV="$2"
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    21
USER="$3"
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    22
PROPNAME="$4"
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    23
ACTION="$5"
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    24
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    25
if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    26
if [ "$ACTION" = "A" -a "$PROPNAME" = "hg:convert-branch" ]; then exit 0; fi
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    27
if [ "$ACTION" = "A" -a "$PROPNAME" = "hg:convert-rev" ]; then exit 0; fi
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    28
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    29
echo "Changing prohibited revision property" >&2
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    30
exit 1
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    31
EOF
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    32
chmod +x $svnpath/hooks/pre-revprop-change
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    33
5809
34c4131abdf9 test-convert-hg-svn: make it more windows friendly
Patrick Mezard <pmezard@gmail.com>
parents: 5554
diff changeset
    34
# SVN wants all paths to start with a slash. Unfortunately,
34c4131abdf9 test-convert-hg-svn: make it more windows friendly
Patrick Mezard <pmezard@gmail.com>
parents: 5554
diff changeset
    35
# Windows ones don't. Handle that.
34c4131abdf9 test-convert-hg-svn: make it more windows friendly
Patrick Mezard <pmezard@gmail.com>
parents: 5554
diff changeset
    36
svnurl=$svnpath
34c4131abdf9 test-convert-hg-svn: make it more windows friendly
Patrick Mezard <pmezard@gmail.com>
parents: 5554
diff changeset
    37
expr $svnurl : "\/" > /dev/null
34c4131abdf9 test-convert-hg-svn: make it more windows friendly
Patrick Mezard <pmezard@gmail.com>
parents: 5554
diff changeset
    38
if [ $? -ne 0 ]; then
34c4131abdf9 test-convert-hg-svn: make it more windows friendly
Patrick Mezard <pmezard@gmail.com>
parents: 5554
diff changeset
    39
    svnurl='/'$svnurl
34c4131abdf9 test-convert-hg-svn: make it more windows friendly
Patrick Mezard <pmezard@gmail.com>
parents: 5554
diff changeset
    40
fi
34c4131abdf9 test-convert-hg-svn: make it more windows friendly
Patrick Mezard <pmezard@gmail.com>
parents: 5554
diff changeset
    41
svnurl=file://$svnurl
5554
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    42
svn co $svnurl $svnpath-wc
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    43
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    44
cd $svnpath-wc
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    45
echo a > a
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    46
svn add a
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    47
svn ci -m'added a' a
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    48
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    49
cd ..
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    50
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    51
echo % initial roundtrip
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    52
hg convert -s svn -d hg $svnpath-wc $svnpath-hg | grep -v initializing
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    53
hg convert -s hg -d svn $svnpath-hg $svnpath-wc
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    54
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    55
echo % second roundtrip should do nothing
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    56
hg convert -s svn -d hg $svnpath-wc $svnpath-hg
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    57
hg convert -s hg -d svn $svnpath-hg $svnpath-wc
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    58
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    59
echo % new hg rev
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    60
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    61
hg clone $svnpath-hg $svnpath-work
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    62
echo b > $svnpath-work/b
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    63
hg --cwd $svnpath-work add b
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    64
hg --cwd $svnpath-work ci -mb
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    65
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    66
echo % echo hg to svn
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    67
hg --cwd $svnpath-hg pull -q $svnpath-work
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    68
hg convert -s hg -d svn $svnpath-hg $svnpath-wc
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    69
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    70
echo % svn back to hg should do nothing
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    71
hg convert -s svn -d hg $svnpath-wc $svnpath-hg
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    72
echo % hg back to svn should do nothing
2147a734dcf9 convert: tell the source repository when a rev has been converted
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    73
hg convert -s hg -d svn $svnpath-hg $svnpath-wc