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'
11 test -n "$TEST_DIRECTORY" || TEST_DIRECTORY
=${0%/*}/..
/..
/t
12 .
"$TEST_DIRECTORY"/test-lib.sh
14 if ! test_have_prereq PYTHON
16 skip_all
='skipping remote-hg tests; python not available'
20 if ! python
-c 'import mercurial'
22 skip_all
='skipping remote-hg tests; mercurial not available'
28 git clone
-q "hg::$1" $2
36 git push
-q "hg::../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
39 (cd $2 && hg
-q update
)
46 git checkout
-q -b tmp
&&
47 git fetch
-q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
48 git checkout
-q @
{-1} &&
49 git branch
-q -D tmp
2>/dev
/null || true
54 hg
-R $1 log
--graph --debug
60 echo "username = A U Thor <author@example.com>"
62 echo "backout = -d \"0 0\""
63 echo "commit = -d \"0 0\""
64 echo "debugrawcommit = -d \"0 0\""
65 echo "tag = -d \"0 0\""
69 git config
--global remote-hg.hg-git-compat true
70 git config
--global remote-hg.track-branches true
72 HGEDITOR
=/usr
/bin
/true
73 GIT_AUTHOR_DATE
="2007-01-01 00:00:00 +0230"
74 GIT_COMMITTER_DATE
="$GIT_AUTHOR_DATE"
75 export HGEDITOR GIT_AUTHOR_DATE GIT_COMMITTER_DATE
80 test_expect_success
'encoding' '
81 test_when_finished "rm -rf gitrepo* hgrepo*" &&
84 git init -q gitrepo &&
89 git commit -m "add älphà" &&
91 GIT_AUTHOR_NAME="tést èncödîng" &&
92 export GIT_AUTHOR_NAME &&
95 git commit -m "add beta" &&
99 git commit -m "add gämmâ" &&
101 : TODO git config i18n.commitencoding latin-1 &&
104 git commit -m "add déltà"
107 hg_clone gitrepo hgrepo &&
108 git_clone hgrepo gitrepo2 &&
109 hg_clone gitrepo2 hgrepo2 &&
111 HGENCODING=utf-8 hg_log hgrepo >expected &&
112 HGENCODING=utf-8 hg_log hgrepo2 >actual &&
114 test_cmp expected actual
117 test_expect_success
'file removal' '
118 test_when_finished "rm -rf gitrepo* hgrepo*" &&
121 git init -q gitrepo &&
125 git commit -m "add alpha" &&
128 git commit -m "add beta"
130 echo blah >foo/bar &&
132 git commit -m "add foo" &&
134 git commit -m "remove alpha" &&
136 git commit -m "remove foo/bar"
139 hg_clone gitrepo hgrepo &&
140 git_clone hgrepo gitrepo2 &&
141 hg_clone gitrepo2 hgrepo2 &&
143 hg_log hgrepo >expected &&
144 hg_log hgrepo2 >actual &&
146 test_cmp expected actual
149 test_expect_success
'git tags' '
150 test_when_finished "rm -rf gitrepo* hgrepo*" &&
153 git init -q gitrepo &&
155 git config receive.denyCurrentBranch ignore &&
158 git commit -m "add alpha" &&
163 git commit -m "add beta" &&
164 git tag -a -m "added tag beta" beta
167 hg_clone gitrepo hgrepo &&
168 git_clone hgrepo gitrepo2 &&
169 hg_clone gitrepo2 hgrepo2 &&
171 hg_log hgrepo >expected &&
172 hg_log hgrepo2 >actual &&
174 test_cmp expected actual
177 test_expect_success
'hg branch' '
178 test_when_finished "rm -rf gitrepo* hgrepo*" &&
181 git init -q gitrepo &&
186 git commit -q -m "add alpha" &&
187 git checkout -q -b not-master
191 hg_clone gitrepo hgrepo &&
196 hg -q commit -m "rename alpha to beta" &&
197 hg branch gamma | grep -v "permanent and global" &&
198 hg -q commit -m "started branch gamma"
201 hg_push hgrepo gitrepo &&
202 hg_clone gitrepo hgrepo2 &&
204 : Back to the common revision &&
205 (cd hgrepo && hg checkout default) &&
207 hg_log hgrepo >expected &&
208 hg_log hgrepo2 >actual &&
210 test_cmp expected actual
213 test_expect_success
'hg tags' '
214 test_when_finished "rm -rf gitrepo* hgrepo*" &&
217 git init -q gitrepo &&
222 git commit -m "add alpha" &&
223 git checkout -q -b not-master
227 hg_clone gitrepo hgrepo &&
234 hg_push hgrepo gitrepo &&
235 hg_clone gitrepo hgrepo2 &&
237 hg_log hgrepo >expected &&
238 hg_log hgrepo2 >actual &&
240 test_cmp expected actual