remote-hg: add remote tests

The logic when working with a local repository is totally different from the one where we work with a remote repository; we need to pull and push from it. All this logic is currently not tested at all, so let's introduce a variable to force the remote behavior. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed May 24, 2013 at 21:29 UTC e6e803be79123dff163900c5a55e556cf6d6c9c0
2 files changed +39 -1
contrib/remote-helpers/git-remote-hg
+1 -1
@@ -383,7 +383,7 @@ def get_repo(url, alias):
383
384 extensions.loadall(myui)
385
386 - if hg.islocal(url):
386 + if hg.islocal(url) and not os.environ.get('GIT_REMOTE_HG_TEST_REMOTE'):
387 repo = hg.repository(myui, url)
388 if not os.path.exists(dirname):
389 os.makedirs(dirname)
contrib/remote-helpers/test-hg.sh
+38
@@ -250,4 +250,42 @@ test_expect_success 'remote push from master branch' '
250 check_branch hgrepo default one
251 '
252
253 +GIT_REMOTE_HG_TEST_REMOTE=1
254 +export GIT_REMOTE_HG_TEST_REMOTE
255 +
256 +test_expect_success 'remote cloning' '
257 + test_when_finished "rm -rf gitrepo*" &&
258 +
259 + (
260 + hg init hgrepo &&
261 + cd hgrepo &&
262 + echo zero > content &&
263 + hg add content &&
264 + hg commit -m zero
265 + ) &&
266 +
267 + git clone "hg::hgrepo" gitrepo &&
268 + check gitrepo HEAD zero
269 +'
270 +
271 +test_expect_success 'remote update bookmark' '
272 + test_when_finished "rm -rf gitrepo*" &&
273 +
274 + (
275 + cd hgrepo &&
276 + hg bookmark devel
277 + ) &&
278 +
279 + (
280 + git clone "hg::hgrepo" gitrepo &&
281 + cd gitrepo &&
282 + git checkout --quiet devel &&
283 + echo devel > content &&
284 + git commit -a -m devel &&
285 + git push --quiet
286 + ) &&
287 +
288 + check_bookmark hgrepo devel devel
289 +'
290 +
291 test_done