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 bidirectionality of remote-hg'
13 if ! test_have_prereq PYTHON
15 skip_all='skipping remote-hg tests; python not available'
19 if ! python -c 'import mercurial'
21 skip_all='skipping remote-hg tests; mercurial not available'
27 git clone -q "hg::$1" $2
35 git push -q "hg::../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
38 (cd $2 && hg -q update)
45 git checkout -q -b tmp &&
46 git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
47 git checkout -q @{-1} &&
48 git branch -q -D tmp 2>/dev/null || true
53 hg -R $1 log --graph --debug
59 echo "username = A U Thor <author@example.com>"
61 echo "backout = -d \"0 0\""
62 echo "commit = -d \"0 0\""
63 echo "debugrawcommit = -d \"0 0\""
64 echo "tag = -d \"0 0\""
68 git config --global remote-hg.hg-git-compat true
69 git config --global remote-hg.track-branches true
71 HGEDITOR=/usr/bin/true
72 GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230"
73 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
74 export HGEDITOR GIT_AUTHOR_DATE GIT_COMMITTER_DATE
79 test_expect_success 'encoding' '
80 test_when_finished "rm -rf gitrepo* hgrepo*" &&
83 git init -q gitrepo &&
88 git commit -m "add älphà" &&
90 GIT_AUTHOR_NAME="tést èncödîng" &&
91 export GIT_AUTHOR_NAME &&
94 git commit -m "add beta" &&
98 git commit -m "add gämmâ" &&
100 : TODO git config i18n.commitencoding latin-1 &&
103 git commit -m "add déltà"
106 hg_clone gitrepo hgrepo &&
107 git_clone hgrepo gitrepo2 &&
108 hg_clone gitrepo2 hgrepo2 &&
110 HGENCODING=utf-8 hg_log hgrepo >expected &&
111 HGENCODING=utf-8 hg_log hgrepo2 >actual &&
113 test_cmp expected actual
116 test_expect_success 'file removal' '
117 test_when_finished "rm -rf gitrepo* hgrepo*" &&
120 git init -q gitrepo &&
124 git commit -m "add alpha" &&
127 git commit -m "add beta"
129 echo blah >foo/bar &&
131 git commit -m "add foo" &&
133 git commit -m "remove alpha" &&
135 git commit -m "remove foo/bar"
138 hg_clone gitrepo hgrepo &&
139 git_clone hgrepo gitrepo2 &&
140 hg_clone gitrepo2 hgrepo2 &&
142 hg_log hgrepo >expected &&
143 hg_log hgrepo2 >actual &&
145 test_cmp expected actual
148 test_expect_success 'git tags' '
149 test_when_finished "rm -rf gitrepo* hgrepo*" &&
152 git init -q gitrepo &&
154 git config receive.denyCurrentBranch ignore &&
157 git commit -m "add alpha" &&
162 git commit -m "add beta" &&
163 git tag -a -m "added tag beta" beta
166 hg_clone gitrepo hgrepo &&
167 git_clone hgrepo gitrepo2 &&
168 hg_clone gitrepo2 hgrepo2 &&
170 hg_log hgrepo >expected &&
171 hg_log hgrepo2 >actual &&
173 test_cmp expected actual
176 test_expect_success 'hg branch' '
177 test_when_finished "rm -rf gitrepo* hgrepo*" &&
180 git init -q gitrepo &&
185 git commit -q -m "add alpha" &&
186 git checkout -q -b not-master
190 hg_clone gitrepo hgrepo &&
195 hg -q commit -m "rename alpha to beta" &&
196 hg branch gamma | grep -v "permanent and global" &&
197 hg -q commit -m "started branch gamma"
200 hg_push hgrepo gitrepo &&
201 hg_clone gitrepo hgrepo2 &&
203 : Back to the common revision &&
204 (cd hgrepo && hg checkout default) &&
206 hg_log hgrepo >expected &&
207 hg_log hgrepo2 >actual &&
209 test_cmp expected actual
212 test_expect_success 'hg tags' '
213 test_when_finished "rm -rf gitrepo* hgrepo*" &&
216 git init -q gitrepo &&
221 git commit -m "add alpha" &&
222 git checkout -q -b not-master
226 hg_clone gitrepo hgrepo &&
233 hg_push hgrepo gitrepo &&
234 hg_clone gitrepo hgrepo2 &&
236 hg_log hgrepo >expected &&
237 hg_log hgrepo2 >actual &&
239 test_cmp expected actual