remote-hg: add test for diverged push
Neither mercurial nor git allows pushing to a remote when it's a non-fast-forward push. We should be able to detect these errors and report them properly, as opposed to throwing an exception stack-trace. 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
1a810864e87b78c08295acca124eb66b8cf2a973
1 file changed
+23
contrib/remote-helpers/test-hg.sh
+23
@@ -318,4 +318,27 @@ test_expect_success 'remote new bookmark' '
318
check_bookmark hgrepo feature-b feature-b
319
'
320
321
+test_expect_failure 'remote push diverged' '
322
+ test_when_finished "rm -rf gitrepo*" &&
323
+
324
+ git clone "hg::hgrepo" gitrepo &&
325
+
326
+ (
327
+ cd hgrepo &&
328
+ hg checkout default &&
329
+ echo bump > content &&
330
+ hg commit -m bump
331
+ ) &&
332
+
333
+ (
334
+ cd gitrepo &&
335
+ echo diverge > content &&
336
+ git commit -a -m diverged &&
337
+ test_expect_code 1 git push 2> error &&
338
+ grep "^ ! \[rejected\] *master -> master (non-fast-forward)$" error
339
+ ) &&
340
+
341
+ check_branch hgrepo default bump
342
+'
343
+
344
test_done