remote-hg: store converted URL
[git/mjg.git] / contrib / remote-helpers / test-hg.sh
blob5f81dfae6c4a31f11ed766dd467fdd4a542afdf3
1 #!/bin/sh
3 # Copyright (c) 2012 Felipe Contreras
5 # Base commands from hg-git tests:
6 # https://bitbucket.org/durin42/hg-git/src
9 test_description='Test remote-hg'
11 . ./test-lib.sh
13 if ! test_have_prereq PYTHON; then
14 skip_all='skipping remote-hg tests; python not available'
15 test_done
18 if ! "$PYTHON_PATH" -c 'import mercurial'; then
19 skip_all='skipping remote-hg tests; mercurial not available'
20 test_done
23 check () {
24 (cd $1 &&
25 git log --format='%s' -1 &&
26 git symbolic-ref HEAD) > actual &&
27 (echo $2 &&
28 echo "refs/heads/$3") > expected &&
29 test_cmp expected actual
32 setup () {
34 echo "[ui]"
35 echo "username = H G Wells <wells@example.com>"
36 ) >> "$HOME"/.hgrc
39 setup
41 test_expect_success 'cloning' '
42 test_when_finished "rm -rf gitrepo*" &&
45 hg init hgrepo &&
46 cd hgrepo &&
47 echo zero > content &&
48 hg add content &&
49 hg commit -m zero
50 ) &&
52 git clone "hg::$PWD/hgrepo" gitrepo &&
53 check gitrepo zero master
56 test_expect_success 'cloning with branches' '
57 test_when_finished "rm -rf gitrepo*" &&
60 cd hgrepo &&
61 hg branch next &&
62 echo next > content &&
63 hg commit -m next
64 ) &&
66 git clone "hg::$PWD/hgrepo" gitrepo &&
67 check gitrepo next next &&
69 (cd hgrepo && hg checkout default) &&
71 git clone "hg::$PWD/hgrepo" gitrepo2 &&
72 check gitrepo2 zero master
75 test_expect_success 'cloning with bookmarks' '
76 test_when_finished "rm -rf gitrepo*" &&
79 cd hgrepo &&
80 hg bookmark feature-a &&
81 echo feature-a > content &&
82 hg commit -m feature-a
83 ) &&
85 git clone "hg::$PWD/hgrepo" gitrepo &&
86 check gitrepo feature-a feature-a
89 test_expect_success 'cloning with detached head' '
90 test_when_finished "rm -rf gitrepo*" &&
93 cd hgrepo &&
94 hg update -r 0
95 ) &&
97 git clone "hg::$PWD/hgrepo" gitrepo &&
98 check gitrepo zero master
101 test_expect_success 'update bookmark' '
102 test_when_finished "rm -rf gitrepo*" &&
105 cd hgrepo &&
106 hg bookmark devel
107 ) &&
110 git clone "hg::$PWD/hgrepo" gitrepo &&
111 cd gitrepo &&
112 git checkout devel &&
113 echo devel > content &&
114 git commit -a -m devel &&
115 git push
116 ) &&
118 hg -R hgrepo bookmarks | grep "devel\s\+3:"
121 test_done