git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v2 0/5] remote-helpers: test reorganization
@ 2013-10-12  7:04 Felipe Contreras
  2013-10-12  7:04 ` [PATCH v2 5/5] remote-helpers: add exec-path links Felipe Contreras
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Felipe Contreras @ 2013-10-12  7:04 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Now we use PYTHON_PATH properly, and also we are able to do:

  make -C contrib/remote-helpers install

Felipe Contreras (5):
  remote-helpers: generate scripts
  build: fix installation of scripts
  remote-helpers: rename tests
  remote-helpers: allow direct test execution
  remote-helpers: add exec-path links

 Makefile                                 |   10 +-
 contrib/remote-helpers/.gitignore        |    2 +
 contrib/remote-helpers/Makefile          |   27 +-
 contrib/remote-helpers/git-remote-bzr    |  960 -----------------------
 contrib/remote-helpers/git-remote-bzr.py |  960 +++++++++++++++++++++++
 contrib/remote-helpers/git-remote-hg     | 1220 ------------------------------
 contrib/remote-helpers/git-remote-hg.py  | 1220 ++++++++++++++++++++++++++++++
 contrib/remote-helpers/test-bzr.sh       |  361 ---------
 contrib/remote-helpers/test-bzr.t        |  362 +++++++++
 contrib/remote-helpers/test-hg-bidi.sh   |  240 ------
 contrib/remote-helpers/test-hg-bidi.t    |  241 ++++++
 contrib/remote-helpers/test-hg-hg-git.sh |  527 -------------
 contrib/remote-helpers/test-hg-hg-git.t  |  528 +++++++++++++
 contrib/remote-helpers/test-hg.sh        |  692 -----------------
 contrib/remote-helpers/test-hg.t         |  693 +++++++++++++++++
 15 files changed, 4034 insertions(+), 4009 deletions(-)
 create mode 100644 contrib/remote-helpers/.gitignore
 delete mode 100755 contrib/remote-helpers/git-remote-bzr
 create mode 100755 contrib/remote-helpers/git-remote-bzr.py
 delete mode 100755 contrib/remote-helpers/git-remote-hg
 create mode 100755 contrib/remote-helpers/git-remote-hg.py
 delete mode 100755 contrib/remote-helpers/test-bzr.sh
 create mode 100755 contrib/remote-helpers/test-bzr.t
 delete mode 100755 contrib/remote-helpers/test-hg-bidi.sh
 create mode 100755 contrib/remote-helpers/test-hg-bidi.t
 delete mode 100755 contrib/remote-helpers/test-hg-hg-git.sh
 create mode 100755 contrib/remote-helpers/test-hg-hg-git.t
 delete mode 100755 contrib/remote-helpers/test-hg.sh
 create mode 100755 contrib/remote-helpers/test-hg.t

-- 
1.8.4-fc

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 5/5] remote-helpers: add exec-path links
  2013-10-12  7:04 [PATCH v2 0/5] remote-helpers: test reorganization Felipe Contreras
@ 2013-10-12  7:04 ` Felipe Contreras
  2013-10-12  7:04 ` [PATCH v2 4/5] remote-helpers: allow direct test execution Felipe Contreras
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2013-10-12  7:04 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

This way we don't have to modify the PATH ourselves and it's easier to
test without 'make'.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/Makefile | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/contrib/remote-helpers/Makefile b/contrib/remote-helpers/Makefile
index 8799c77..2e14b65 100644
--- a/contrib/remote-helpers/Makefile
+++ b/contrib/remote-helpers/Makefile
@@ -1,15 +1,15 @@
 TESTS := $(wildcard test-*.t)
 SCRIPTS := $(wildcard git-remote-*.py)
+LINKS := $(addprefix ../../,$(patsubst %.py,%,$(SCRIPTS)))
 
 export T := $(addprefix $(CURDIR)/,$(TESTS))
 export MAKE := $(MAKE) -e
-export PATH := $(CURDIR):$(PATH)
 export TEST_LINT := test-lint-executable test-lint-shell-syntax
 export TEST_DIRECTORY := $(CURDIR)/../../t
 
 export SCRIPT_PYTHON := $(addprefix $(CURDIR)/,$(SCRIPTS))
 
-all: $(SCRIPTS)
+all: $(LINKS)
 	$(MAKE) -C ../.. build-python-script
 
 install:
@@ -17,10 +17,14 @@ install:
 
 clean:
 	$(MAKE) -C ../.. clean-python-script
+	$(RM) $(LINKS)
 
 test: all
 	$(MAKE) -C ../../t $@
 
+$(LINKS):
+	ln -sf contrib/remote-helpers/$(notdir $@) ../..
+
 $(TESTS): all
 	$(MAKE) -C ../../t $(CURDIR)/$@
 
-- 
1.8.4-fc

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 4/5] remote-helpers: allow direct test execution
  2013-10-12  7:04 [PATCH v2 0/5] remote-helpers: test reorganization Felipe Contreras
  2013-10-12  7:04 ` [PATCH v2 5/5] remote-helpers: add exec-path links Felipe Contreras
@ 2013-10-12  7:04 ` Felipe Contreras
  2013-10-12  7:04 ` [PATCH v2 3/5] remote-helpers: rename tests Felipe Contreras
  2013-10-12  7:04 ` [PATCH v2 2/5] build: fix installation of scripts Felipe Contreras
  3 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2013-10-12  7:04 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Previously 'make' was the only option, or manually specifying the
'TEST_DIRECTORY'.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/Makefile         | 1 +
 contrib/remote-helpers/test-bzr.t       | 3 ++-
 contrib/remote-helpers/test-hg-bidi.t   | 3 ++-
 contrib/remote-helpers/test-hg-hg-git.t | 3 ++-
 contrib/remote-helpers/test-hg.t        | 3 ++-
 5 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/contrib/remote-helpers/Makefile b/contrib/remote-helpers/Makefile
index 8d5e9be..8799c77 100644
--- a/contrib/remote-helpers/Makefile
+++ b/contrib/remote-helpers/Makefile
@@ -5,6 +5,7 @@ export T := $(addprefix $(CURDIR)/,$(TESTS))
 export MAKE := $(MAKE) -e
 export PATH := $(CURDIR):$(PATH)
 export TEST_LINT := test-lint-executable test-lint-shell-syntax
+export TEST_DIRECTORY := $(CURDIR)/../../t
 
 export SCRIPT_PYTHON := $(addprefix $(CURDIR)/,$(SCRIPTS))
 
diff --git a/contrib/remote-helpers/test-bzr.t b/contrib/remote-helpers/test-bzr.t
index 435b280..7ca4a9c 100755
--- a/contrib/remote-helpers/test-bzr.t
+++ b/contrib/remote-helpers/test-bzr.t
@@ -5,7 +5,8 @@
 
 test_description='Test remote-bzr'
 
-. ./test-lib.sh
+test -z "$TEST_DIRECTORY" && TEST_DIRECTORY="$PWD/../../t"
+. "$TEST_DIRECTORY"/test-lib.sh
 
 if ! test_have_prereq PYTHON; then
 	skip_all='skipping remote-bzr tests; python not available'
diff --git a/contrib/remote-helpers/test-hg-bidi.t b/contrib/remote-helpers/test-hg-bidi.t
index 86a3f10..e978932 100755
--- a/contrib/remote-helpers/test-hg-bidi.t
+++ b/contrib/remote-helpers/test-hg-bidi.t
@@ -8,7 +8,8 @@
 
 test_description='Test bidirectionality of remote-hg'
 
-. ./test-lib.sh
+test -z "$TEST_DIRECTORY" && TEST_DIRECTORY="$PWD/../../t"
+. "$TEST_DIRECTORY"/test-lib.sh
 
 if ! test_have_prereq PYTHON; then
 	skip_all='skipping remote-hg tests; python not available'
diff --git a/contrib/remote-helpers/test-hg-hg-git.t b/contrib/remote-helpers/test-hg-hg-git.t
index 0217860..0caa493 100755
--- a/contrib/remote-helpers/test-hg-hg-git.t
+++ b/contrib/remote-helpers/test-hg-hg-git.t
@@ -8,7 +8,8 @@
 
 test_description='Test remote-hg output compared to hg-git'
 
-. ./test-lib.sh
+test -z "$TEST_DIRECTORY" && TEST_DIRECTORY="$PWD/../../t"
+. "$TEST_DIRECTORY"/test-lib.sh
 
 if ! test_have_prereq PYTHON; then
 	skip_all='skipping remote-hg tests; python not available'
diff --git a/contrib/remote-helpers/test-hg.t b/contrib/remote-helpers/test-hg.t
index 30f4ff6..9b6dd95 100755
--- a/contrib/remote-helpers/test-hg.t
+++ b/contrib/remote-helpers/test-hg.t
@@ -8,7 +8,8 @@
 
 test_description='Test remote-hg'
 
-. ./test-lib.sh
+test -z "$TEST_DIRECTORY" && TEST_DIRECTORY="$PWD/../../t"
+. "$TEST_DIRECTORY"/test-lib.sh
 
 if ! test_have_prereq PYTHON; then
 	skip_all='skipping remote-hg tests; python not available'
-- 
1.8.4-fc

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 3/5] remote-helpers: rename tests
  2013-10-12  7:04 [PATCH v2 0/5] remote-helpers: test reorganization Felipe Contreras
  2013-10-12  7:04 ` [PATCH v2 5/5] remote-helpers: add exec-path links Felipe Contreras
  2013-10-12  7:04 ` [PATCH v2 4/5] remote-helpers: allow direct test execution Felipe Contreras
@ 2013-10-12  7:04 ` Felipe Contreras
  2013-10-12  7:04 ` [PATCH v2 2/5] build: fix installation of scripts Felipe Contreras
  3 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2013-10-12  7:04 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

The .t extension is more standard for sharness tests.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/Makefile          |   2 +-
 contrib/remote-helpers/test-bzr.sh       | 361 ----------------
 contrib/remote-helpers/test-bzr.t        | 361 ++++++++++++++++
 contrib/remote-helpers/test-hg-bidi.sh   | 240 -----------
 contrib/remote-helpers/test-hg-bidi.t    | 240 +++++++++++
 contrib/remote-helpers/test-hg-hg-git.sh | 527 -----------------------
 contrib/remote-helpers/test-hg-hg-git.t  | 527 +++++++++++++++++++++++
 contrib/remote-helpers/test-hg.sh        | 692 -------------------------------
 contrib/remote-helpers/test-hg.t         | 692 +++++++++++++++++++++++++++++++
 9 files changed, 1821 insertions(+), 1821 deletions(-)
 delete mode 100755 contrib/remote-helpers/test-bzr.sh
 create mode 100755 contrib/remote-helpers/test-bzr.t
 delete mode 100755 contrib/remote-helpers/test-hg-bidi.sh
 create mode 100755 contrib/remote-helpers/test-hg-bidi.t
 delete mode 100755 contrib/remote-helpers/test-hg-hg-git.sh
 create mode 100755 contrib/remote-helpers/test-hg-hg-git.t
 delete mode 100755 contrib/remote-helpers/test-hg.sh
 create mode 100755 contrib/remote-helpers/test-hg.t

diff --git a/contrib/remote-helpers/Makefile b/contrib/remote-helpers/Makefile
index 973c578..8d5e9be 100644
--- a/contrib/remote-helpers/Makefile
+++ b/contrib/remote-helpers/Makefile
@@ -1,4 +1,4 @@
-TESTS := $(wildcard test*.sh)
+TESTS := $(wildcard test-*.t)
 SCRIPTS := $(wildcard git-remote-*.py)
 
 export T := $(addprefix $(CURDIR)/,$(TESTS))
diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh
deleted file mode 100755
index 435b280..0000000
--- a/contrib/remote-helpers/test-bzr.sh
+++ /dev/null
@@ -1,361 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2012 Felipe Contreras
-#
-
-test_description='Test remote-bzr'
-
-. ./test-lib.sh
-
-if ! test_have_prereq PYTHON; then
-	skip_all='skipping remote-bzr tests; python not available'
-	test_done
-fi
-
-if ! "$PYTHON_PATH" -c 'import bzrlib'; then
-	skip_all='skipping remote-bzr tests; bzr not available'
-	test_done
-fi
-
-check () {
-	echo $3 > expected &&
-	git --git-dir=$1/.git log --format='%s' -1 $2 > actual
-	test_cmp expected actual
-}
-
-bzr whoami "A U Thor <author@example.com>"
-
-test_expect_success 'cloning' '
-	(
-	bzr init bzrrepo &&
-	cd bzrrepo &&
-	echo one > content &&
-	bzr add content &&
-	bzr commit -m one
-	) &&
-
-	git clone "bzr::bzrrepo" gitrepo &&
-	check gitrepo HEAD one
-'
-
-test_expect_success 'pulling' '
-	(
-	cd bzrrepo &&
-	echo two > content &&
-	bzr commit -m two
-	) &&
-
-	(cd gitrepo && git pull) &&
-
-	check gitrepo HEAD two
-'
-
-test_expect_success 'pushing' '
-	(
-	cd gitrepo &&
-	echo three > content &&
-	git commit -a -m three &&
-	git push
-	) &&
-
-	echo three > expected &&
-	cat bzrrepo/content > actual &&
-	test_cmp expected actual
-'
-
-test_expect_success 'roundtrip' '
-	(
-	cd gitrepo &&
-	git pull &&
-	git log --format="%s" -1 origin/master > actual
-	) &&
-	echo three > expected &&
-	test_cmp expected actual &&
-
-	(cd gitrepo && git push && git pull) &&
-
-	(
-	cd bzrrepo &&
-	echo four > content &&
-	bzr commit -m four
-	) &&
-
-	(cd gitrepo && git pull && git push) &&
-
-	check gitrepo HEAD four &&
-
-	(
-	cd gitrepo &&
-	echo five > content &&
-	git commit -a -m five &&
-	git push && git pull
-	) &&
-
-	(cd bzrrepo && bzr revert) &&
-
-	echo five > expected &&
-	cat bzrrepo/content > actual &&
-	test_cmp expected actual
-'
-
-cat > expected <<EOF
-100644 blob 54f9d6da5c91d556e6b54340b1327573073030af	content
-100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb	executable
-120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea	link
-EOF
-
-test_expect_success 'special modes' '
-	(
-	cd bzrrepo &&
-	echo exec > executable
-	chmod +x executable &&
-	bzr add executable
-	bzr commit -m exec &&
-	ln -s content link
-	bzr add link
-	bzr commit -m link &&
-	mkdir dir &&
-	bzr add dir &&
-	bzr commit -m dir
-	) &&
-
-	(
-	cd gitrepo &&
-	git pull
-	git ls-tree HEAD > ../actual
-	) &&
-
-	test_cmp expected actual &&
-
-	(
-	cd gitrepo &&
-	git cat-file -p HEAD:link > ../actual
-	) &&
-
-	printf content > expected &&
-	test_cmp expected actual
-'
-
-cat > expected <<EOF
-100644 blob 54f9d6da5c91d556e6b54340b1327573073030af	content
-100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb	executable
-120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea	link
-040000 tree 35c0caa46693cef62247ac89a680f0c5ce32b37b	movedir-new
-EOF
-
-test_expect_success 'moving directory' '
-	(
-	cd bzrrepo &&
-	mkdir movedir &&
-	echo one > movedir/one &&
-	echo two > movedir/two &&
-	bzr add movedir &&
-	bzr commit -m movedir &&
-	bzr mv movedir movedir-new &&
-	bzr commit -m movedir-new
-	) &&
-
-	(
-	cd gitrepo &&
-	git pull &&
-	git ls-tree HEAD > ../actual
-	) &&
-
-	test_cmp expected actual
-'
-
-test_expect_success 'different authors' '
-	(
-	cd bzrrepo &&
-	echo john >> content &&
-	bzr commit -m john \
-	  --author "Jane Rey <jrey@example.com>" \
-	  --author "John Doe <jdoe@example.com>"
-	) &&
-
-	(
-	cd gitrepo &&
-	git pull &&
-	git show --format="%an <%ae>, %cn <%ce>" --quiet > ../actual
-	) &&
-
-	echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" > expected &&
-	test_cmp expected actual
-'
-
-# cleanup previous stuff
-rm -rf bzrrepo gitrepo
-
-test_expect_success 'fetch utf-8 filenames' '
-	test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
-
-	LC_ALL=en_US.UTF-8
-	export LC_ALL
-
-	(
-	bzr init bzrrepo &&
-	cd bzrrepo &&
-
-	echo test >> "ærø" &&
-	bzr add "ærø" &&
-	echo test >> "ø~?" &&
-	bzr add "ø~?" &&
-	bzr commit -m add-utf-8 &&
-	echo test >> "ærø" &&
-	bzr commit -m test-utf-8 &&
-	bzr rm "ø~?" &&
-	bzr mv "ærø" "ø~?" &&
-	bzr commit -m bzr-mv-utf-8
-	) &&
-
-	(
-	git clone "bzr::bzrrepo" gitrepo &&
-	cd gitrepo &&
-	git -c core.quotepath=false ls-files > ../actual
-	) &&
-	echo "ø~?" > expected &&
-	test_cmp expected actual
-'
-
-test_expect_success 'push utf-8 filenames' '
-	test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
-
-	mkdir -p tmp && cd tmp &&
-
-	LC_ALL=en_US.UTF-8
-	export LC_ALL
-
-	(
-	bzr init bzrrepo &&
-	cd bzrrepo &&
-
-	echo one >> content &&
-	bzr add content &&
-	bzr commit -m one
-	) &&
-
-	(
-	git clone "bzr::bzrrepo" gitrepo &&
-	cd gitrepo &&
-
-	echo test >> "ærø" &&
-	git add "ærø" &&
-	git commit -m utf-8 &&
-
-	git push
-	) &&
-
-	(cd bzrrepo && bzr ls > ../actual) &&
-	printf "content\nærø\n" > expected &&
-	test_cmp expected actual
-'
-
-test_expect_success 'pushing a merge' '
-	test_when_finished "rm -rf bzrrepo gitrepo" &&
-
-	(
-	bzr init bzrrepo &&
-	cd bzrrepo &&
-	echo one > content &&
-	bzr add content &&
-	bzr commit -m one
-	) &&
-
-	git clone "bzr::bzrrepo" gitrepo &&
-
-	(
-	cd bzrrepo &&
-	echo two > content &&
-	bzr commit -m two
-	) &&
-
-	(
-	cd gitrepo &&
-	echo three > content &&
-	git commit -a -m three &&
-	git fetch &&
-	git merge origin/master || true &&
-	echo three > content &&
-	git commit -a --no-edit &&
-	git push
-	) &&
-
-	echo three > expected &&
-	cat bzrrepo/content > actual &&
-	test_cmp expected actual
-'
-
-cat > expected <<EOF
-origin/HEAD
-origin/branch
-origin/trunk
-EOF
-
-test_expect_success 'proper bzr repo' '
-	test_when_finished "rm -rf bzrrepo gitrepo" &&
-
-	bzr init-repo bzrrepo &&
-
-	(
-	bzr init bzrrepo/trunk &&
-	cd bzrrepo/trunk &&
-	echo one >> content &&
-	bzr add content &&
-	bzr commit -m one
-	) &&
-
-	(
-	bzr branch bzrrepo/trunk bzrrepo/branch &&
-	cd bzrrepo/branch &&
-	echo two >> content &&
-	bzr commit -m one
-	) &&
-
-	(
-	git clone "bzr::bzrrepo" gitrepo &&
-	cd gitrepo &&
-	git for-each-ref --format "%(refname:short)" refs/remotes/origin > ../actual
-	) &&
-
-	test_cmp expected actual
-'
-
-test_expect_success 'strip' '
-	test_when_finished "rm -rf bzrrepo gitrepo" &&
-
-	(
-	bzr init bzrrepo &&
-	cd bzrrepo &&
-
-	echo one >> content &&
-	bzr add content &&
-	bzr commit -m one &&
-
-	echo two >> content &&
-	bzr commit -m two
-	) &&
-
-	git clone "bzr::bzrrepo" gitrepo &&
-
-	(
-	cd bzrrepo &&
-	bzr uncommit --force &&
-
-	echo three >> content &&
-	bzr commit -m three &&
-
-	echo four >> content &&
-	bzr commit -m four &&
-	bzr log --line | sed -e "s/^[0-9][0-9]*: //" > ../expected
-	) &&
-
-	(
-	cd gitrepo &&
-	git fetch &&
-	git log --format="%an %ad %s" --date=short origin/master > ../actual
-	) &&
-
-	test_cmp expected actual
-'
-
-test_done
diff --git a/contrib/remote-helpers/test-bzr.t b/contrib/remote-helpers/test-bzr.t
new file mode 100755
index 0000000..435b280
--- /dev/null
+++ b/contrib/remote-helpers/test-bzr.t
@@ -0,0 +1,361 @@
+#!/bin/sh
+#
+# Copyright (c) 2012 Felipe Contreras
+#
+
+test_description='Test remote-bzr'
+
+. ./test-lib.sh
+
+if ! test_have_prereq PYTHON; then
+	skip_all='skipping remote-bzr tests; python not available'
+	test_done
+fi
+
+if ! "$PYTHON_PATH" -c 'import bzrlib'; then
+	skip_all='skipping remote-bzr tests; bzr not available'
+	test_done
+fi
+
+check () {
+	echo $3 > expected &&
+	git --git-dir=$1/.git log --format='%s' -1 $2 > actual
+	test_cmp expected actual
+}
+
+bzr whoami "A U Thor <author@example.com>"
+
+test_expect_success 'cloning' '
+	(
+	bzr init bzrrepo &&
+	cd bzrrepo &&
+	echo one > content &&
+	bzr add content &&
+	bzr commit -m one
+	) &&
+
+	git clone "bzr::bzrrepo" gitrepo &&
+	check gitrepo HEAD one
+'
+
+test_expect_success 'pulling' '
+	(
+	cd bzrrepo &&
+	echo two > content &&
+	bzr commit -m two
+	) &&
+
+	(cd gitrepo && git pull) &&
+
+	check gitrepo HEAD two
+'
+
+test_expect_success 'pushing' '
+	(
+	cd gitrepo &&
+	echo three > content &&
+	git commit -a -m three &&
+	git push
+	) &&
+
+	echo three > expected &&
+	cat bzrrepo/content > actual &&
+	test_cmp expected actual
+'
+
+test_expect_success 'roundtrip' '
+	(
+	cd gitrepo &&
+	git pull &&
+	git log --format="%s" -1 origin/master > actual
+	) &&
+	echo three > expected &&
+	test_cmp expected actual &&
+
+	(cd gitrepo && git push && git pull) &&
+
+	(
+	cd bzrrepo &&
+	echo four > content &&
+	bzr commit -m four
+	) &&
+
+	(cd gitrepo && git pull && git push) &&
+
+	check gitrepo HEAD four &&
+
+	(
+	cd gitrepo &&
+	echo five > content &&
+	git commit -a -m five &&
+	git push && git pull
+	) &&
+
+	(cd bzrrepo && bzr revert) &&
+
+	echo five > expected &&
+	cat bzrrepo/content > actual &&
+	test_cmp expected actual
+'
+
+cat > expected <<EOF
+100644 blob 54f9d6da5c91d556e6b54340b1327573073030af	content
+100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb	executable
+120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea	link
+EOF
+
+test_expect_success 'special modes' '
+	(
+	cd bzrrepo &&
+	echo exec > executable
+	chmod +x executable &&
+	bzr add executable
+	bzr commit -m exec &&
+	ln -s content link
+	bzr add link
+	bzr commit -m link &&
+	mkdir dir &&
+	bzr add dir &&
+	bzr commit -m dir
+	) &&
+
+	(
+	cd gitrepo &&
+	git pull
+	git ls-tree HEAD > ../actual
+	) &&
+
+	test_cmp expected actual &&
+
+	(
+	cd gitrepo &&
+	git cat-file -p HEAD:link > ../actual
+	) &&
+
+	printf content > expected &&
+	test_cmp expected actual
+'
+
+cat > expected <<EOF
+100644 blob 54f9d6da5c91d556e6b54340b1327573073030af	content
+100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb	executable
+120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea	link
+040000 tree 35c0caa46693cef62247ac89a680f0c5ce32b37b	movedir-new
+EOF
+
+test_expect_success 'moving directory' '
+	(
+	cd bzrrepo &&
+	mkdir movedir &&
+	echo one > movedir/one &&
+	echo two > movedir/two &&
+	bzr add movedir &&
+	bzr commit -m movedir &&
+	bzr mv movedir movedir-new &&
+	bzr commit -m movedir-new
+	) &&
+
+	(
+	cd gitrepo &&
+	git pull &&
+	git ls-tree HEAD > ../actual
+	) &&
+
+	test_cmp expected actual
+'
+
+test_expect_success 'different authors' '
+	(
+	cd bzrrepo &&
+	echo john >> content &&
+	bzr commit -m john \
+	  --author "Jane Rey <jrey@example.com>" \
+	  --author "John Doe <jdoe@example.com>"
+	) &&
+
+	(
+	cd gitrepo &&
+	git pull &&
+	git show --format="%an <%ae>, %cn <%ce>" --quiet > ../actual
+	) &&
+
+	echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" > expected &&
+	test_cmp expected actual
+'
+
+# cleanup previous stuff
+rm -rf bzrrepo gitrepo
+
+test_expect_success 'fetch utf-8 filenames' '
+	test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
+
+	LC_ALL=en_US.UTF-8
+	export LC_ALL
+
+	(
+	bzr init bzrrepo &&
+	cd bzrrepo &&
+
+	echo test >> "ærø" &&
+	bzr add "ærø" &&
+	echo test >> "ø~?" &&
+	bzr add "ø~?" &&
+	bzr commit -m add-utf-8 &&
+	echo test >> "ærø" &&
+	bzr commit -m test-utf-8 &&
+	bzr rm "ø~?" &&
+	bzr mv "ærø" "ø~?" &&
+	bzr commit -m bzr-mv-utf-8
+	) &&
+
+	(
+	git clone "bzr::bzrrepo" gitrepo &&
+	cd gitrepo &&
+	git -c core.quotepath=false ls-files > ../actual
+	) &&
+	echo "ø~?" > expected &&
+	test_cmp expected actual
+'
+
+test_expect_success 'push utf-8 filenames' '
+	test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
+
+	mkdir -p tmp && cd tmp &&
+
+	LC_ALL=en_US.UTF-8
+	export LC_ALL
+
+	(
+	bzr init bzrrepo &&
+	cd bzrrepo &&
+
+	echo one >> content &&
+	bzr add content &&
+	bzr commit -m one
+	) &&
+
+	(
+	git clone "bzr::bzrrepo" gitrepo &&
+	cd gitrepo &&
+
+	echo test >> "ærø" &&
+	git add "ærø" &&
+	git commit -m utf-8 &&
+
+	git push
+	) &&
+
+	(cd bzrrepo && bzr ls > ../actual) &&
+	printf "content\nærø\n" > expected &&
+	test_cmp expected actual
+'
+
+test_expect_success 'pushing a merge' '
+	test_when_finished "rm -rf bzrrepo gitrepo" &&
+
+	(
+	bzr init bzrrepo &&
+	cd bzrrepo &&
+	echo one > content &&
+	bzr add content &&
+	bzr commit -m one
+	) &&
+
+	git clone "bzr::bzrrepo" gitrepo &&
+
+	(
+	cd bzrrepo &&
+	echo two > content &&
+	bzr commit -m two
+	) &&
+
+	(
+	cd gitrepo &&
+	echo three > content &&
+	git commit -a -m three &&
+	git fetch &&
+	git merge origin/master || true &&
+	echo three > content &&
+	git commit -a --no-edit &&
+	git push
+	) &&
+
+	echo three > expected &&
+	cat bzrrepo/content > actual &&
+	test_cmp expected actual
+'
+
+cat > expected <<EOF
+origin/HEAD
+origin/branch
+origin/trunk
+EOF
+
+test_expect_success 'proper bzr repo' '
+	test_when_finished "rm -rf bzrrepo gitrepo" &&
+
+	bzr init-repo bzrrepo &&
+
+	(
+	bzr init bzrrepo/trunk &&
+	cd bzrrepo/trunk &&
+	echo one >> content &&
+	bzr add content &&
+	bzr commit -m one
+	) &&
+
+	(
+	bzr branch bzrrepo/trunk bzrrepo/branch &&
+	cd bzrrepo/branch &&
+	echo two >> content &&
+	bzr commit -m one
+	) &&
+
+	(
+	git clone "bzr::bzrrepo" gitrepo &&
+	cd gitrepo &&
+	git for-each-ref --format "%(refname:short)" refs/remotes/origin > ../actual
+	) &&
+
+	test_cmp expected actual
+'
+
+test_expect_success 'strip' '
+	test_when_finished "rm -rf bzrrepo gitrepo" &&
+
+	(
+	bzr init bzrrepo &&
+	cd bzrrepo &&
+
+	echo one >> content &&
+	bzr add content &&
+	bzr commit -m one &&
+
+	echo two >> content &&
+	bzr commit -m two
+	) &&
+
+	git clone "bzr::bzrrepo" gitrepo &&
+
+	(
+	cd bzrrepo &&
+	bzr uncommit --force &&
+
+	echo three >> content &&
+	bzr commit -m three &&
+
+	echo four >> content &&
+	bzr commit -m four &&
+	bzr log --line | sed -e "s/^[0-9][0-9]*: //" > ../expected
+	) &&
+
+	(
+	cd gitrepo &&
+	git fetch &&
+	git log --format="%an %ad %s" --date=short origin/master > ../actual
+	) &&
+
+	test_cmp expected actual
+'
+
+test_done
diff --git a/contrib/remote-helpers/test-hg-bidi.sh b/contrib/remote-helpers/test-hg-bidi.sh
deleted file mode 100755
index 86a3f10..0000000
--- a/contrib/remote-helpers/test-hg-bidi.sh
+++ /dev/null
@@ -1,240 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2012 Felipe Contreras
-#
-# Base commands from hg-git tests:
-# https://bitbucket.org/durin42/hg-git/src
-#
-
-test_description='Test bidirectionality of remote-hg'
-
-. ./test-lib.sh
-
-if ! test_have_prereq PYTHON; then
-	skip_all='skipping remote-hg tests; python not available'
-	test_done
-fi
-
-if ! "$PYTHON_PATH" -c 'import mercurial'; then
-	skip_all='skipping remote-hg tests; mercurial not available'
-	test_done
-fi
-
-# clone to a git repo
-git_clone () {
-	git clone -q "hg::$1" $2
-}
-
-# clone to an hg repo
-hg_clone () {
-	(
-	hg init $2 &&
-	cd $1 &&
-	git push -q "hg::../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
-	) &&
-
-	(cd $2 && hg -q update)
-}
-
-# push an hg repo
-hg_push () {
-	(
-	cd $2
-	git checkout -q -b tmp &&
-	git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
-	git checkout -q @{-1} &&
-	git branch -q -D tmp 2> /dev/null || true
-	)
-}
-
-hg_log () {
-	hg -R $1 log --graph --debug
-}
-
-setup () {
-	(
-	echo "[ui]"
-	echo "username = A U Thor <author@example.com>"
-	echo "[defaults]"
-	echo "backout = -d \"0 0\""
-	echo "commit = -d \"0 0\""
-	echo "debugrawcommit = -d \"0 0\""
-	echo "tag = -d \"0 0\""
-	echo "[extensions]"
-	echo "graphlog ="
-	) >> "$HOME"/.hgrc &&
-	git config --global remote-hg.hg-git-compat true
-	git config --global remote-hg.track-branches true
-
-	HGEDITOR=/usr/bin/true
-	GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230"
-	GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-	export HGEDITOR GIT_AUTHOR_DATE GIT_COMMITTER_DATE
-}
-
-setup
-
-test_expect_success 'encoding' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	(
-	git init -q gitrepo &&
-	cd gitrepo &&
-
-	echo alpha > alpha &&
-	git add alpha &&
-	git commit -m "add älphà" &&
-
-	GIT_AUTHOR_NAME="tést èncödîng" &&
-	export GIT_AUTHOR_NAME &&
-	echo beta > beta &&
-	git add beta &&
-	git commit -m "add beta" &&
-
-	echo gamma > gamma &&
-	git add gamma &&
-	git commit -m "add gämmâ" &&
-
-	: TODO git config i18n.commitencoding latin-1 &&
-	echo delta > delta &&
-	git add delta &&
-	git commit -m "add déltà"
-	) &&
-
-	hg_clone gitrepo hgrepo &&
-	git_clone hgrepo gitrepo2 &&
-	hg_clone gitrepo2 hgrepo2 &&
-
-	HGENCODING=utf-8 hg_log hgrepo > expected &&
-	HGENCODING=utf-8 hg_log hgrepo2 > actual &&
-
-	test_cmp expected actual
-'
-
-test_expect_success 'file removal' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	(
-	git init -q gitrepo &&
-	cd gitrepo &&
-	echo alpha > alpha &&
-	git add alpha &&
-	git commit -m "add alpha" &&
-	echo beta > beta &&
-	git add beta &&
-	git commit -m "add beta"
-	mkdir foo &&
-	echo blah > foo/bar &&
-	git add foo &&
-	git commit -m "add foo" &&
-	git rm alpha &&
-	git commit -m "remove alpha" &&
-	git rm foo/bar &&
-	git commit -m "remove foo/bar"
-	) &&
-
-	hg_clone gitrepo hgrepo &&
-	git_clone hgrepo gitrepo2 &&
-	hg_clone gitrepo2 hgrepo2 &&
-
-	hg_log hgrepo > expected &&
-	hg_log hgrepo2 > actual &&
-
-	test_cmp expected actual
-'
-
-test_expect_success 'git tags' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	(
-	git init -q gitrepo &&
-	cd gitrepo &&
-	git config receive.denyCurrentBranch ignore &&
-	echo alpha > alpha &&
-	git add alpha &&
-	git commit -m "add alpha" &&
-	git tag alpha &&
-
-	echo beta > beta &&
-	git add beta &&
-	git commit -m "add beta" &&
-	git tag -a -m "added tag beta" beta
-	) &&
-
-	hg_clone gitrepo hgrepo &&
-	git_clone hgrepo gitrepo2 &&
-	hg_clone gitrepo2 hgrepo2 &&
-
-	hg_log hgrepo > expected &&
-	hg_log hgrepo2 > actual &&
-
-	test_cmp expected actual
-'
-
-test_expect_success 'hg branch' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	(
-	git init -q gitrepo &&
-	cd gitrepo &&
-
-	echo alpha > alpha &&
-	git add alpha &&
-	git commit -q -m "add alpha" &&
-	git checkout -q -b not-master
-	) &&
-
-	(
-	hg_clone gitrepo hgrepo &&
-
-	cd hgrepo &&
-	hg -q co default &&
-	hg mv alpha beta &&
-	hg -q commit -m "rename alpha to beta" &&
-	hg branch gamma | grep -v "permanent and global" &&
-	hg -q commit -m "started branch gamma"
-	) &&
-
-	hg_push hgrepo gitrepo &&
-	hg_clone gitrepo hgrepo2 &&
-
-	: Back to the common revision &&
-	(cd hgrepo && hg checkout default) &&
-
-	hg_log hgrepo > expected &&
-	hg_log hgrepo2 > actual &&
-
-	test_cmp expected actual
-'
-
-test_expect_success 'hg tags' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	(
-	git init -q gitrepo &&
-	cd gitrepo &&
-
-	echo alpha > alpha &&
-	git add alpha &&
-	git commit -m "add alpha" &&
-	git checkout -q -b not-master
-	) &&
-
-	(
-	hg_clone gitrepo hgrepo &&
-
-	cd hgrepo &&
-	hg co default &&
-	hg tag alpha
-	) &&
-
-	hg_push hgrepo gitrepo &&
-	hg_clone gitrepo hgrepo2 &&
-
-	hg_log hgrepo > expected &&
-	hg_log hgrepo2 > actual &&
-
-	test_cmp expected actual
-'
-
-test_done
diff --git a/contrib/remote-helpers/test-hg-bidi.t b/contrib/remote-helpers/test-hg-bidi.t
new file mode 100755
index 0000000..86a3f10
--- /dev/null
+++ b/contrib/remote-helpers/test-hg-bidi.t
@@ -0,0 +1,240 @@
+#!/bin/sh
+#
+# Copyright (c) 2012 Felipe Contreras
+#
+# Base commands from hg-git tests:
+# https://bitbucket.org/durin42/hg-git/src
+#
+
+test_description='Test bidirectionality of remote-hg'
+
+. ./test-lib.sh
+
+if ! test_have_prereq PYTHON; then
+	skip_all='skipping remote-hg tests; python not available'
+	test_done
+fi
+
+if ! "$PYTHON_PATH" -c 'import mercurial'; then
+	skip_all='skipping remote-hg tests; mercurial not available'
+	test_done
+fi
+
+# clone to a git repo
+git_clone () {
+	git clone -q "hg::$1" $2
+}
+
+# clone to an hg repo
+hg_clone () {
+	(
+	hg init $2 &&
+	cd $1 &&
+	git push -q "hg::../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
+	) &&
+
+	(cd $2 && hg -q update)
+}
+
+# push an hg repo
+hg_push () {
+	(
+	cd $2
+	git checkout -q -b tmp &&
+	git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
+	git checkout -q @{-1} &&
+	git branch -q -D tmp 2> /dev/null || true
+	)
+}
+
+hg_log () {
+	hg -R $1 log --graph --debug
+}
+
+setup () {
+	(
+	echo "[ui]"
+	echo "username = A U Thor <author@example.com>"
+	echo "[defaults]"
+	echo "backout = -d \"0 0\""
+	echo "commit = -d \"0 0\""
+	echo "debugrawcommit = -d \"0 0\""
+	echo "tag = -d \"0 0\""
+	echo "[extensions]"
+	echo "graphlog ="
+	) >> "$HOME"/.hgrc &&
+	git config --global remote-hg.hg-git-compat true
+	git config --global remote-hg.track-branches true
+
+	HGEDITOR=/usr/bin/true
+	GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230"
+	GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
+	export HGEDITOR GIT_AUTHOR_DATE GIT_COMMITTER_DATE
+}
+
+setup
+
+test_expect_success 'encoding' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	(
+	git init -q gitrepo &&
+	cd gitrepo &&
+
+	echo alpha > alpha &&
+	git add alpha &&
+	git commit -m "add älphà" &&
+
+	GIT_AUTHOR_NAME="tést èncödîng" &&
+	export GIT_AUTHOR_NAME &&
+	echo beta > beta &&
+	git add beta &&
+	git commit -m "add beta" &&
+
+	echo gamma > gamma &&
+	git add gamma &&
+	git commit -m "add gämmâ" &&
+
+	: TODO git config i18n.commitencoding latin-1 &&
+	echo delta > delta &&
+	git add delta &&
+	git commit -m "add déltà"
+	) &&
+
+	hg_clone gitrepo hgrepo &&
+	git_clone hgrepo gitrepo2 &&
+	hg_clone gitrepo2 hgrepo2 &&
+
+	HGENCODING=utf-8 hg_log hgrepo > expected &&
+	HGENCODING=utf-8 hg_log hgrepo2 > actual &&
+
+	test_cmp expected actual
+'
+
+test_expect_success 'file removal' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	(
+	git init -q gitrepo &&
+	cd gitrepo &&
+	echo alpha > alpha &&
+	git add alpha &&
+	git commit -m "add alpha" &&
+	echo beta > beta &&
+	git add beta &&
+	git commit -m "add beta"
+	mkdir foo &&
+	echo blah > foo/bar &&
+	git add foo &&
+	git commit -m "add foo" &&
+	git rm alpha &&
+	git commit -m "remove alpha" &&
+	git rm foo/bar &&
+	git commit -m "remove foo/bar"
+	) &&
+
+	hg_clone gitrepo hgrepo &&
+	git_clone hgrepo gitrepo2 &&
+	hg_clone gitrepo2 hgrepo2 &&
+
+	hg_log hgrepo > expected &&
+	hg_log hgrepo2 > actual &&
+
+	test_cmp expected actual
+'
+
+test_expect_success 'git tags' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	(
+	git init -q gitrepo &&
+	cd gitrepo &&
+	git config receive.denyCurrentBranch ignore &&
+	echo alpha > alpha &&
+	git add alpha &&
+	git commit -m "add alpha" &&
+	git tag alpha &&
+
+	echo beta > beta &&
+	git add beta &&
+	git commit -m "add beta" &&
+	git tag -a -m "added tag beta" beta
+	) &&
+
+	hg_clone gitrepo hgrepo &&
+	git_clone hgrepo gitrepo2 &&
+	hg_clone gitrepo2 hgrepo2 &&
+
+	hg_log hgrepo > expected &&
+	hg_log hgrepo2 > actual &&
+
+	test_cmp expected actual
+'
+
+test_expect_success 'hg branch' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	(
+	git init -q gitrepo &&
+	cd gitrepo &&
+
+	echo alpha > alpha &&
+	git add alpha &&
+	git commit -q -m "add alpha" &&
+	git checkout -q -b not-master
+	) &&
+
+	(
+	hg_clone gitrepo hgrepo &&
+
+	cd hgrepo &&
+	hg -q co default &&
+	hg mv alpha beta &&
+	hg -q commit -m "rename alpha to beta" &&
+	hg branch gamma | grep -v "permanent and global" &&
+	hg -q commit -m "started branch gamma"
+	) &&
+
+	hg_push hgrepo gitrepo &&
+	hg_clone gitrepo hgrepo2 &&
+
+	: Back to the common revision &&
+	(cd hgrepo && hg checkout default) &&
+
+	hg_log hgrepo > expected &&
+	hg_log hgrepo2 > actual &&
+
+	test_cmp expected actual
+'
+
+test_expect_success 'hg tags' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	(
+	git init -q gitrepo &&
+	cd gitrepo &&
+
+	echo alpha > alpha &&
+	git add alpha &&
+	git commit -m "add alpha" &&
+	git checkout -q -b not-master
+	) &&
+
+	(
+	hg_clone gitrepo hgrepo &&
+
+	cd hgrepo &&
+	hg co default &&
+	hg tag alpha
+	) &&
+
+	hg_push hgrepo gitrepo &&
+	hg_clone gitrepo hgrepo2 &&
+
+	hg_log hgrepo > expected &&
+	hg_log hgrepo2 > actual &&
+
+	test_cmp expected actual
+'
+
+test_done
diff --git a/contrib/remote-helpers/test-hg-hg-git.sh b/contrib/remote-helpers/test-hg-hg-git.sh
deleted file mode 100755
index 0217860..0000000
--- a/contrib/remote-helpers/test-hg-hg-git.sh
+++ /dev/null
@@ -1,527 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2012 Felipe Contreras
-#
-# Base commands from hg-git tests:
-# https://bitbucket.org/durin42/hg-git/src
-#
-
-test_description='Test remote-hg output compared to hg-git'
-
-. ./test-lib.sh
-
-if ! test_have_prereq PYTHON; then
-	skip_all='skipping remote-hg tests; python not available'
-	test_done
-fi
-
-if ! "$PYTHON_PATH" -c 'import mercurial'; then
-	skip_all='skipping remote-hg tests; mercurial not available'
-	test_done
-fi
-
-if ! "$PYTHON_PATH" -c 'import hggit'; then
-	skip_all='skipping remote-hg tests; hg-git not available'
-	test_done
-fi
-
-# clone to a git repo with git
-git_clone_git () {
-	git clone -q "hg::$1" $2 &&
-	(cd $2 && git checkout master && git branch -D default)
-}
-
-# clone to an hg repo with git
-hg_clone_git () {
-	(
-	hg init $2 &&
-	hg -R $2 bookmark -i master &&
-	cd $1 &&
-	git push -q "hg::../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
-	) &&
-
-	(cd $2 && hg -q update)
-}
-
-# clone to a git repo with hg
-git_clone_hg () {
-	(
-	git init -q $2 &&
-	cd $1 &&
-	hg bookmark -i -f -r tip master &&
-	hg -q push -r master ../$2 || true
-	)
-}
-
-# clone to an hg repo with hg
-hg_clone_hg () {
-	hg -q clone $1 $2
-}
-
-# push an hg repo with git
-hg_push_git () {
-	(
-	cd $2
-	git checkout -q -b tmp &&
-	git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
-	git branch -D default &&
-	git checkout -q @{-1} &&
-	git branch -q -D tmp 2> /dev/null || true
-	)
-}
-
-# push an hg git repo with hg
-hg_push_hg () {
-	(
-	cd $1 &&
-	hg -q push ../$2 || true
-	)
-}
-
-hg_log () {
-	hg -R $1 log --graph --debug >log &&
-	grep -v 'tag: *default/' log
-}
-
-git_log () {
-	git --git-dir=$1/.git fast-export --branches
-}
-
-setup () {
-	(
-	echo "[ui]"
-	echo "username = A U Thor <author@example.com>"
-	echo "[defaults]"
-	echo "backout = -d \"0 0\""
-	echo "commit = -d \"0 0\""
-	echo "debugrawcommit = -d \"0 0\""
-	echo "tag = -d \"0 0\""
-	echo "[extensions]"
-	echo "hgext.bookmarks ="
-	echo "hggit ="
-	echo "graphlog ="
-	) >> "$HOME"/.hgrc &&
-	git config --global receive.denycurrentbranch warn
-	git config --global remote-hg.hg-git-compat true
-	git config --global remote-hg.track-branches false
-
-	HGEDITOR=true
-	HGMERGE=true
-
-	GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230"
-	GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-	export HGEDITOR HGMERGE GIT_AUTHOR_DATE GIT_COMMITTER_DATE
-}
-
-setup
-
-test_expect_success 'executable bit' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	(
-	git init -q gitrepo &&
-	cd gitrepo &&
-	echo alpha > alpha &&
-	chmod 0644 alpha &&
-	git add alpha &&
-	git commit -m "add alpha" &&
-	chmod 0755 alpha &&
-	git add alpha &&
-	git commit -m "set executable bit" &&
-	chmod 0644 alpha &&
-	git add alpha &&
-	git commit -m "clear executable bit"
-	) &&
-
-	for x in hg git; do
-		(
-		hg_clone_$x gitrepo hgrepo-$x &&
-		cd hgrepo-$x &&
-		hg_log . &&
-		hg manifest -r 1 -v &&
-		hg manifest -v
-		) > output-$x &&
-
-		git_clone_$x hgrepo-$x gitrepo2-$x &&
-		git_log gitrepo2-$x > log-$x
-	done &&
-
-	test_cmp output-hg output-git &&
-	test_cmp log-hg log-git
-'
-
-test_expect_success 'symlink' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	(
-	git init -q gitrepo &&
-	cd gitrepo &&
-	echo alpha > alpha &&
-	git add alpha &&
-	git commit -m "add alpha" &&
-	ln -s alpha beta &&
-	git add beta &&
-	git commit -m "add beta"
-	) &&
-
-	for x in hg git; do
-		(
-		hg_clone_$x gitrepo hgrepo-$x &&
-		cd hgrepo-$x &&
-		hg_log . &&
-		hg manifest -v
-		) > output-$x &&
-
-		git_clone_$x hgrepo-$x gitrepo2-$x &&
-		git_log gitrepo2-$x > log-$x
-	done &&
-
-	test_cmp output-hg output-git &&
-	test_cmp log-hg log-git
-'
-
-test_expect_success 'merge conflict 1' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	(
-	hg init hgrepo1 &&
-	cd hgrepo1 &&
-	echo A > afile &&
-	hg add afile &&
-	hg ci -m "origin" &&
-
-	echo B > afile &&
-	hg ci -m "A->B" &&
-
-	hg up -r0 &&
-	echo C > afile &&
-	hg ci -m "A->C" &&
-
-	hg merge -r1 &&
-	echo C > afile &&
-	hg resolve -m afile &&
-	hg ci -m "merge to C"
-	) &&
-
-	for x in hg git; do
-		git_clone_$x hgrepo1 gitrepo-$x &&
-		hg_clone_$x gitrepo-$x hgrepo2-$x &&
-		hg_log hgrepo2-$x > hg-log-$x &&
-		git_log gitrepo-$x > git-log-$x
-	done &&
-
-	test_cmp hg-log-hg hg-log-git &&
-	test_cmp git-log-hg git-log-git
-'
-
-test_expect_success 'merge conflict 2' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	(
-	hg init hgrepo1 &&
-	cd hgrepo1 &&
-	echo A > afile &&
-	hg add afile &&
-	hg ci -m "origin" &&
-
-	echo B > afile &&
-	hg ci -m "A->B" &&
-
-	hg up -r0 &&
-	echo C > afile &&
-	hg ci -m "A->C" &&
-
-	hg merge -r1 || true &&
-	echo B > afile &&
-	hg resolve -m afile &&
-	hg ci -m "merge to B"
-	) &&
-
-	for x in hg git; do
-		git_clone_$x hgrepo1 gitrepo-$x &&
-		hg_clone_$x gitrepo-$x hgrepo2-$x &&
-		hg_log hgrepo2-$x > hg-log-$x &&
-		git_log gitrepo-$x > git-log-$x
-	done &&
-
-	test_cmp hg-log-hg hg-log-git &&
-	test_cmp git-log-hg git-log-git
-'
-
-test_expect_success 'converged merge' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	(
-	hg init hgrepo1 &&
-	cd hgrepo1 &&
-	echo A > afile &&
-	hg add afile &&
-	hg ci -m "origin" &&
-
-	echo B > afile &&
-	hg ci -m "A->B" &&
-
-	echo C > afile &&
-	hg ci -m "B->C" &&
-
-	hg up -r0 &&
-	echo C > afile &&
-	hg ci -m "A->C" &&
-
-	hg merge -r2 || true &&
-	hg ci -m "merge"
-	) &&
-
-	for x in hg git; do
-		git_clone_$x hgrepo1 gitrepo-$x &&
-		hg_clone_$x gitrepo-$x hgrepo2-$x &&
-		hg_log hgrepo2-$x > hg-log-$x &&
-		git_log gitrepo-$x > git-log-$x
-	done &&
-
-	test_cmp hg-log-hg hg-log-git &&
-	test_cmp git-log-hg git-log-git
-'
-
-test_expect_success 'encoding' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	(
-	git init -q gitrepo &&
-	cd gitrepo &&
-
-	echo alpha > alpha &&
-	git add alpha &&
-	git commit -m "add älphà" &&
-
-	GIT_AUTHOR_NAME="tést èncödîng" &&
-	export GIT_AUTHOR_NAME &&
-	echo beta > beta &&
-	git add beta &&
-	git commit -m "add beta" &&
-
-	echo gamma > gamma &&
-	git add gamma &&
-	git commit -m "add gämmâ" &&
-
-	: TODO git config i18n.commitencoding latin-1 &&
-	echo delta > delta &&
-	git add delta &&
-	git commit -m "add déltà"
-	) &&
-
-	for x in hg git; do
-		hg_clone_$x gitrepo hgrepo-$x &&
-		git_clone_$x hgrepo-$x gitrepo2-$x &&
-
-		HGENCODING=utf-8 hg_log hgrepo-$x > hg-log-$x &&
-		git_log gitrepo2-$x > git-log-$x
-	done &&
-
-	test_cmp hg-log-hg hg-log-git &&
-	test_cmp git-log-hg git-log-git
-'
-
-test_expect_success 'file removal' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	(
-	git init -q gitrepo &&
-	cd gitrepo &&
-	echo alpha > alpha &&
-	git add alpha &&
-	git commit -m "add alpha" &&
-	echo beta > beta &&
-	git add beta &&
-	git commit -m "add beta"
-	mkdir foo &&
-	echo blah > foo/bar &&
-	git add foo &&
-	git commit -m "add foo" &&
-	git rm alpha &&
-	git commit -m "remove alpha" &&
-	git rm foo/bar &&
-	git commit -m "remove foo/bar"
-	) &&
-
-	for x in hg git; do
-		(
-		hg_clone_$x gitrepo hgrepo-$x &&
-		cd hgrepo-$x &&
-		hg_log . &&
-		hg manifest -r 3 &&
-		hg manifest
-		) > output-$x &&
-
-		git_clone_$x hgrepo-$x gitrepo2-$x &&
-		git_log gitrepo2-$x > log-$x
-	done &&
-
-	test_cmp output-hg output-git &&
-	test_cmp log-hg log-git
-'
-
-test_expect_success 'git tags' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	(
-	git init -q gitrepo &&
-	cd gitrepo &&
-	git config receive.denyCurrentBranch ignore &&
-	echo alpha > alpha &&
-	git add alpha &&
-	git commit -m "add alpha" &&
-	git tag alpha &&
-
-	echo beta > beta &&
-	git add beta &&
-	git commit -m "add beta" &&
-	git tag -a -m "added tag beta" beta
-	) &&
-
-	for x in hg git; do
-		hg_clone_$x gitrepo hgrepo-$x &&
-		hg_log hgrepo-$x > log-$x
-	done &&
-
-	test_cmp log-hg log-git
-'
-
-test_expect_success 'hg author' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	for x in hg git; do
-		(
-		git init -q gitrepo-$x &&
-		cd gitrepo-$x &&
-
-		echo alpha > alpha &&
-		git add alpha &&
-		git commit -m "add alpha" &&
-		git checkout -q -b not-master
-		) &&
-
-		(
-		hg_clone_$x gitrepo-$x hgrepo-$x &&
-		cd hgrepo-$x &&
-
-		hg co master &&
-		echo beta > beta &&
-		hg add beta &&
-		hg commit -u "test" -m "add beta" &&
-
-		echo gamma >> beta &&
-		hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
-
-		echo gamma > gamma &&
-		hg add gamma &&
-		hg commit -u "<test@example.com>" -m "add gamma" &&
-
-		echo delta > delta &&
-		hg add delta &&
-		hg commit -u "name<test@example.com>" -m "add delta" &&
-
-		echo epsilon > epsilon &&
-		hg add epsilon &&
-		hg commit -u "name <test@example.com" -m "add epsilon" &&
-
-		echo zeta > zeta &&
-		hg add zeta &&
-		hg commit -u " test " -m "add zeta" &&
-
-		echo eta > eta &&
-		hg add eta &&
-		hg commit -u "test < test@example.com >" -m "add eta" &&
-
-		echo theta > theta &&
-		hg add theta &&
-		hg commit -u "test >test@example.com>" -m "add theta" &&
-
-		echo iota > iota &&
-		hg add iota &&
-		hg commit -u "test <test <at> example <dot> com>" -m "add iota"
-		) &&
-
-		hg_push_$x hgrepo-$x gitrepo-$x &&
-		hg_clone_$x gitrepo-$x hgrepo2-$x &&
-
-		hg_log hgrepo2-$x > hg-log-$x &&
-		git_log gitrepo-$x > git-log-$x
-	done &&
-
-	test_cmp hg-log-hg hg-log-git &&
-	test_cmp git-log-hg git-log-git
-'
-
-test_expect_success 'hg branch' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	for x in hg git; do
-		(
-		git init -q gitrepo-$x &&
-		cd gitrepo-$x &&
-
-		echo alpha > alpha &&
-		git add alpha &&
-		git commit -q -m "add alpha" &&
-		git checkout -q -b not-master
-		) &&
-
-		(
-		hg_clone_$x gitrepo-$x hgrepo-$x &&
-
-		cd hgrepo-$x &&
-		hg -q co master &&
-		hg mv alpha beta &&
-		hg -q commit -m "rename alpha to beta" &&
-		hg branch gamma | grep -v "permanent and global" &&
-		hg -q commit -m "started branch gamma"
-		) &&
-
-		hg_push_$x hgrepo-$x gitrepo-$x &&
-		hg_clone_$x gitrepo-$x hgrepo2-$x &&
-
-		hg_log hgrepo2-$x > hg-log-$x &&
-		git_log gitrepo-$x > git-log-$x
-	done &&
-
-	test_cmp hg-log-hg hg-log-git &&
-	test_cmp git-log-hg git-log-git
-'
-
-test_expect_success 'hg tags' '
-	test_when_finished "rm -rf gitrepo* hgrepo*" &&
-
-	for x in hg git; do
-		(
-		git init -q gitrepo-$x &&
-		cd gitrepo-$x &&
-
-		echo alpha > alpha &&
-		git add alpha &&
-		git commit -m "add alpha" &&
-		git checkout -q -b not-master
-		) &&
-
-		(
-		hg_clone_$x gitrepo-$x hgrepo-$x &&
-
-		cd hgrepo-$x &&
-		hg co master &&
-		hg tag alpha
-		) &&
-
-		hg_push_$x hgrepo-$x gitrepo-$x &&
-		hg_clone_$x gitrepo-$x hgrepo2-$x &&
-
-		(
-		git --git-dir=gitrepo-$x/.git tag -l &&
-		hg_log hgrepo2-$x &&
-		cat hgrepo2-$x/.hgtags
-		) > output-$x
-	done &&
-
-	test_cmp output-hg output-git
-'
-
-test_done
diff --git a/contrib/remote-helpers/test-hg-hg-git.t b/contrib/remote-helpers/test-hg-hg-git.t
new file mode 100755
index 0000000..0217860
--- /dev/null
+++ b/contrib/remote-helpers/test-hg-hg-git.t
@@ -0,0 +1,527 @@
+#!/bin/sh
+#
+# Copyright (c) 2012 Felipe Contreras
+#
+# Base commands from hg-git tests:
+# https://bitbucket.org/durin42/hg-git/src
+#
+
+test_description='Test remote-hg output compared to hg-git'
+
+. ./test-lib.sh
+
+if ! test_have_prereq PYTHON; then
+	skip_all='skipping remote-hg tests; python not available'
+	test_done
+fi
+
+if ! "$PYTHON_PATH" -c 'import mercurial'; then
+	skip_all='skipping remote-hg tests; mercurial not available'
+	test_done
+fi
+
+if ! "$PYTHON_PATH" -c 'import hggit'; then
+	skip_all='skipping remote-hg tests; hg-git not available'
+	test_done
+fi
+
+# clone to a git repo with git
+git_clone_git () {
+	git clone -q "hg::$1" $2 &&
+	(cd $2 && git checkout master && git branch -D default)
+}
+
+# clone to an hg repo with git
+hg_clone_git () {
+	(
+	hg init $2 &&
+	hg -R $2 bookmark -i master &&
+	cd $1 &&
+	git push -q "hg::../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
+	) &&
+
+	(cd $2 && hg -q update)
+}
+
+# clone to a git repo with hg
+git_clone_hg () {
+	(
+	git init -q $2 &&
+	cd $1 &&
+	hg bookmark -i -f -r tip master &&
+	hg -q push -r master ../$2 || true
+	)
+}
+
+# clone to an hg repo with hg
+hg_clone_hg () {
+	hg -q clone $1 $2
+}
+
+# push an hg repo with git
+hg_push_git () {
+	(
+	cd $2
+	git checkout -q -b tmp &&
+	git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
+	git branch -D default &&
+	git checkout -q @{-1} &&
+	git branch -q -D tmp 2> /dev/null || true
+	)
+}
+
+# push an hg git repo with hg
+hg_push_hg () {
+	(
+	cd $1 &&
+	hg -q push ../$2 || true
+	)
+}
+
+hg_log () {
+	hg -R $1 log --graph --debug >log &&
+	grep -v 'tag: *default/' log
+}
+
+git_log () {
+	git --git-dir=$1/.git fast-export --branches
+}
+
+setup () {
+	(
+	echo "[ui]"
+	echo "username = A U Thor <author@example.com>"
+	echo "[defaults]"
+	echo "backout = -d \"0 0\""
+	echo "commit = -d \"0 0\""
+	echo "debugrawcommit = -d \"0 0\""
+	echo "tag = -d \"0 0\""
+	echo "[extensions]"
+	echo "hgext.bookmarks ="
+	echo "hggit ="
+	echo "graphlog ="
+	) >> "$HOME"/.hgrc &&
+	git config --global receive.denycurrentbranch warn
+	git config --global remote-hg.hg-git-compat true
+	git config --global remote-hg.track-branches false
+
+	HGEDITOR=true
+	HGMERGE=true
+
+	GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230"
+	GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
+	export HGEDITOR HGMERGE GIT_AUTHOR_DATE GIT_COMMITTER_DATE
+}
+
+setup
+
+test_expect_success 'executable bit' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	(
+	git init -q gitrepo &&
+	cd gitrepo &&
+	echo alpha > alpha &&
+	chmod 0644 alpha &&
+	git add alpha &&
+	git commit -m "add alpha" &&
+	chmod 0755 alpha &&
+	git add alpha &&
+	git commit -m "set executable bit" &&
+	chmod 0644 alpha &&
+	git add alpha &&
+	git commit -m "clear executable bit"
+	) &&
+
+	for x in hg git; do
+		(
+		hg_clone_$x gitrepo hgrepo-$x &&
+		cd hgrepo-$x &&
+		hg_log . &&
+		hg manifest -r 1 -v &&
+		hg manifest -v
+		) > output-$x &&
+
+		git_clone_$x hgrepo-$x gitrepo2-$x &&
+		git_log gitrepo2-$x > log-$x
+	done &&
+
+	test_cmp output-hg output-git &&
+	test_cmp log-hg log-git
+'
+
+test_expect_success 'symlink' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	(
+	git init -q gitrepo &&
+	cd gitrepo &&
+	echo alpha > alpha &&
+	git add alpha &&
+	git commit -m "add alpha" &&
+	ln -s alpha beta &&
+	git add beta &&
+	git commit -m "add beta"
+	) &&
+
+	for x in hg git; do
+		(
+		hg_clone_$x gitrepo hgrepo-$x &&
+		cd hgrepo-$x &&
+		hg_log . &&
+		hg manifest -v
+		) > output-$x &&
+
+		git_clone_$x hgrepo-$x gitrepo2-$x &&
+		git_log gitrepo2-$x > log-$x
+	done &&
+
+	test_cmp output-hg output-git &&
+	test_cmp log-hg log-git
+'
+
+test_expect_success 'merge conflict 1' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	(
+	hg init hgrepo1 &&
+	cd hgrepo1 &&
+	echo A > afile &&
+	hg add afile &&
+	hg ci -m "origin" &&
+
+	echo B > afile &&
+	hg ci -m "A->B" &&
+
+	hg up -r0 &&
+	echo C > afile &&
+	hg ci -m "A->C" &&
+
+	hg merge -r1 &&
+	echo C > afile &&
+	hg resolve -m afile &&
+	hg ci -m "merge to C"
+	) &&
+
+	for x in hg git; do
+		git_clone_$x hgrepo1 gitrepo-$x &&
+		hg_clone_$x gitrepo-$x hgrepo2-$x &&
+		hg_log hgrepo2-$x > hg-log-$x &&
+		git_log gitrepo-$x > git-log-$x
+	done &&
+
+	test_cmp hg-log-hg hg-log-git &&
+	test_cmp git-log-hg git-log-git
+'
+
+test_expect_success 'merge conflict 2' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	(
+	hg init hgrepo1 &&
+	cd hgrepo1 &&
+	echo A > afile &&
+	hg add afile &&
+	hg ci -m "origin" &&
+
+	echo B > afile &&
+	hg ci -m "A->B" &&
+
+	hg up -r0 &&
+	echo C > afile &&
+	hg ci -m "A->C" &&
+
+	hg merge -r1 || true &&
+	echo B > afile &&
+	hg resolve -m afile &&
+	hg ci -m "merge to B"
+	) &&
+
+	for x in hg git; do
+		git_clone_$x hgrepo1 gitrepo-$x &&
+		hg_clone_$x gitrepo-$x hgrepo2-$x &&
+		hg_log hgrepo2-$x > hg-log-$x &&
+		git_log gitrepo-$x > git-log-$x
+	done &&
+
+	test_cmp hg-log-hg hg-log-git &&
+	test_cmp git-log-hg git-log-git
+'
+
+test_expect_success 'converged merge' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	(
+	hg init hgrepo1 &&
+	cd hgrepo1 &&
+	echo A > afile &&
+	hg add afile &&
+	hg ci -m "origin" &&
+
+	echo B > afile &&
+	hg ci -m "A->B" &&
+
+	echo C > afile &&
+	hg ci -m "B->C" &&
+
+	hg up -r0 &&
+	echo C > afile &&
+	hg ci -m "A->C" &&
+
+	hg merge -r2 || true &&
+	hg ci -m "merge"
+	) &&
+
+	for x in hg git; do
+		git_clone_$x hgrepo1 gitrepo-$x &&
+		hg_clone_$x gitrepo-$x hgrepo2-$x &&
+		hg_log hgrepo2-$x > hg-log-$x &&
+		git_log gitrepo-$x > git-log-$x
+	done &&
+
+	test_cmp hg-log-hg hg-log-git &&
+	test_cmp git-log-hg git-log-git
+'
+
+test_expect_success 'encoding' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	(
+	git init -q gitrepo &&
+	cd gitrepo &&
+
+	echo alpha > alpha &&
+	git add alpha &&
+	git commit -m "add älphà" &&
+
+	GIT_AUTHOR_NAME="tést èncödîng" &&
+	export GIT_AUTHOR_NAME &&
+	echo beta > beta &&
+	git add beta &&
+	git commit -m "add beta" &&
+
+	echo gamma > gamma &&
+	git add gamma &&
+	git commit -m "add gämmâ" &&
+
+	: TODO git config i18n.commitencoding latin-1 &&
+	echo delta > delta &&
+	git add delta &&
+	git commit -m "add déltà"
+	) &&
+
+	for x in hg git; do
+		hg_clone_$x gitrepo hgrepo-$x &&
+		git_clone_$x hgrepo-$x gitrepo2-$x &&
+
+		HGENCODING=utf-8 hg_log hgrepo-$x > hg-log-$x &&
+		git_log gitrepo2-$x > git-log-$x
+	done &&
+
+	test_cmp hg-log-hg hg-log-git &&
+	test_cmp git-log-hg git-log-git
+'
+
+test_expect_success 'file removal' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	(
+	git init -q gitrepo &&
+	cd gitrepo &&
+	echo alpha > alpha &&
+	git add alpha &&
+	git commit -m "add alpha" &&
+	echo beta > beta &&
+	git add beta &&
+	git commit -m "add beta"
+	mkdir foo &&
+	echo blah > foo/bar &&
+	git add foo &&
+	git commit -m "add foo" &&
+	git rm alpha &&
+	git commit -m "remove alpha" &&
+	git rm foo/bar &&
+	git commit -m "remove foo/bar"
+	) &&
+
+	for x in hg git; do
+		(
+		hg_clone_$x gitrepo hgrepo-$x &&
+		cd hgrepo-$x &&
+		hg_log . &&
+		hg manifest -r 3 &&
+		hg manifest
+		) > output-$x &&
+
+		git_clone_$x hgrepo-$x gitrepo2-$x &&
+		git_log gitrepo2-$x > log-$x
+	done &&
+
+	test_cmp output-hg output-git &&
+	test_cmp log-hg log-git
+'
+
+test_expect_success 'git tags' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	(
+	git init -q gitrepo &&
+	cd gitrepo &&
+	git config receive.denyCurrentBranch ignore &&
+	echo alpha > alpha &&
+	git add alpha &&
+	git commit -m "add alpha" &&
+	git tag alpha &&
+
+	echo beta > beta &&
+	git add beta &&
+	git commit -m "add beta" &&
+	git tag -a -m "added tag beta" beta
+	) &&
+
+	for x in hg git; do
+		hg_clone_$x gitrepo hgrepo-$x &&
+		hg_log hgrepo-$x > log-$x
+	done &&
+
+	test_cmp log-hg log-git
+'
+
+test_expect_success 'hg author' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	for x in hg git; do
+		(
+		git init -q gitrepo-$x &&
+		cd gitrepo-$x &&
+
+		echo alpha > alpha &&
+		git add alpha &&
+		git commit -m "add alpha" &&
+		git checkout -q -b not-master
+		) &&
+
+		(
+		hg_clone_$x gitrepo-$x hgrepo-$x &&
+		cd hgrepo-$x &&
+
+		hg co master &&
+		echo beta > beta &&
+		hg add beta &&
+		hg commit -u "test" -m "add beta" &&
+
+		echo gamma >> beta &&
+		hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
+
+		echo gamma > gamma &&
+		hg add gamma &&
+		hg commit -u "<test@example.com>" -m "add gamma" &&
+
+		echo delta > delta &&
+		hg add delta &&
+		hg commit -u "name<test@example.com>" -m "add delta" &&
+
+		echo epsilon > epsilon &&
+		hg add epsilon &&
+		hg commit -u "name <test@example.com" -m "add epsilon" &&
+
+		echo zeta > zeta &&
+		hg add zeta &&
+		hg commit -u " test " -m "add zeta" &&
+
+		echo eta > eta &&
+		hg add eta &&
+		hg commit -u "test < test@example.com >" -m "add eta" &&
+
+		echo theta > theta &&
+		hg add theta &&
+		hg commit -u "test >test@example.com>" -m "add theta" &&
+
+		echo iota > iota &&
+		hg add iota &&
+		hg commit -u "test <test <at> example <dot> com>" -m "add iota"
+		) &&
+
+		hg_push_$x hgrepo-$x gitrepo-$x &&
+		hg_clone_$x gitrepo-$x hgrepo2-$x &&
+
+		hg_log hgrepo2-$x > hg-log-$x &&
+		git_log gitrepo-$x > git-log-$x
+	done &&
+
+	test_cmp hg-log-hg hg-log-git &&
+	test_cmp git-log-hg git-log-git
+'
+
+test_expect_success 'hg branch' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	for x in hg git; do
+		(
+		git init -q gitrepo-$x &&
+		cd gitrepo-$x &&
+
+		echo alpha > alpha &&
+		git add alpha &&
+		git commit -q -m "add alpha" &&
+		git checkout -q -b not-master
+		) &&
+
+		(
+		hg_clone_$x gitrepo-$x hgrepo-$x &&
+
+		cd hgrepo-$x &&
+		hg -q co master &&
+		hg mv alpha beta &&
+		hg -q commit -m "rename alpha to beta" &&
+		hg branch gamma | grep -v "permanent and global" &&
+		hg -q commit -m "started branch gamma"
+		) &&
+
+		hg_push_$x hgrepo-$x gitrepo-$x &&
+		hg_clone_$x gitrepo-$x hgrepo2-$x &&
+
+		hg_log hgrepo2-$x > hg-log-$x &&
+		git_log gitrepo-$x > git-log-$x
+	done &&
+
+	test_cmp hg-log-hg hg-log-git &&
+	test_cmp git-log-hg git-log-git
+'
+
+test_expect_success 'hg tags' '
+	test_when_finished "rm -rf gitrepo* hgrepo*" &&
+
+	for x in hg git; do
+		(
+		git init -q gitrepo-$x &&
+		cd gitrepo-$x &&
+
+		echo alpha > alpha &&
+		git add alpha &&
+		git commit -m "add alpha" &&
+		git checkout -q -b not-master
+		) &&
+
+		(
+		hg_clone_$x gitrepo-$x hgrepo-$x &&
+
+		cd hgrepo-$x &&
+		hg co master &&
+		hg tag alpha
+		) &&
+
+		hg_push_$x hgrepo-$x gitrepo-$x &&
+		hg_clone_$x gitrepo-$x hgrepo2-$x &&
+
+		(
+		git --git-dir=gitrepo-$x/.git tag -l &&
+		hg_log hgrepo2-$x &&
+		cat hgrepo2-$x/.hgtags
+		) > output-$x
+	done &&
+
+	test_cmp output-hg output-git
+'
+
+test_done
diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh
deleted file mode 100755
index 30f4ff6..0000000
--- a/contrib/remote-helpers/test-hg.sh
+++ /dev/null
@@ -1,692 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2012 Felipe Contreras
-#
-# Base commands from hg-git tests:
-# https://bitbucket.org/durin42/hg-git/src
-#
-
-test_description='Test remote-hg'
-
-. ./test-lib.sh
-
-if ! test_have_prereq PYTHON; then
-	skip_all='skipping remote-hg tests; python not available'
-	test_done
-fi
-
-if ! "$PYTHON_PATH" -c 'import mercurial'; then
-	skip_all='skipping remote-hg tests; mercurial not available'
-	test_done
-fi
-
-check () {
-	echo $3 > expected &&
-	git --git-dir=$1/.git log --format='%s' -1 $2 > actual
-	test_cmp expected actual
-}
-
-check_branch () {
-	if [ -n "$3" ]; then
-		echo $3 > expected &&
-		hg -R $1 log -r $2 --template '{desc}\n' > actual &&
-		test_cmp expected actual
-	else
-		hg -R $1 branches > out &&
-		! grep $2 out
-	fi
-}
-
-check_bookmark () {
-	if [ -n "$3" ]; then
-		echo $3 > expected &&
-		hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' > actual &&
-		test_cmp expected actual
-	else
-		hg -R $1 bookmarks > out &&
-		! grep $2 out
-	fi
-}
-
-check_push () {
-	local expected_ret=$1 ret=0 ref_ret=0 IFS=':'
-
-	shift
-	git push origin "$@" 2> error
-	ret=$?
-	cat error
-
-	while read branch kind
-	do
-		case "$kind" in
-		'new')
-			grep "^ \* \[new branch\] *${branch} -> ${branch}$" error || ref_ret=1
-			;;
-		'non-fast-forward')
-			grep "^ ! \[rejected\] *${branch} -> ${branch} (non-fast-forward)$" error || ref_ret=1
-			;;
-		'fetch-first')
-			grep "^ ! \[rejected\] *${branch} -> ${branch} (fetch first)$" error || ref_ret=1
-			;;
-		'forced-update')
-			grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *${branch} -> ${branch} (forced update)$" error || ref_ret=1
-			;;
-		'')
-			grep "^   [a-f0-9]*\.\.[a-f0-9]* *${branch} -> ${branch}$" error || ref_ret=1
-			;;
-		esac
-		let 'ref_ret' && echo "match for '$branch' failed" && break
-	done
-
-	if let 'expected_ret != ret || ref_ret'
-	then
-		return 1
-	fi
-
-	return 0
-}
-
-setup () {
-	(
-	echo "[ui]"
-	echo "username = H G Wells <wells@example.com>"
-	echo "[extensions]"
-	echo "mq ="
-	) >> "$HOME"/.hgrc &&
-
-	GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230" &&
-	GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" &&
-	export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
-}
-
-setup
-
-test_expect_success 'cloning' '
-	test_when_finished "rm -rf gitrepo*" &&
-
-	(
-	hg init hgrepo &&
-	cd hgrepo &&
-	echo zero > content &&
-	hg add content &&
-	hg commit -m zero
-	) &&
-
-	git clone "hg::hgrepo" gitrepo &&
-	check gitrepo HEAD zero
-'
-
-test_expect_success 'cloning with branches' '
-	test_when_finished "rm -rf gitrepo*" &&
-
-	(
-	cd hgrepo &&
-	hg branch next &&
-	echo next > content &&
-	hg commit -m next
-	) &&
-
-	git clone "hg::hgrepo" gitrepo &&
-	check gitrepo origin/branches/next next
-'
-
-test_expect_success 'cloning with bookmarks' '
-	test_when_finished "rm -rf gitrepo*" &&
-
-	(
-	cd hgrepo &&
-	hg checkout default &&
-	hg bookmark feature-a &&
-	echo feature-a > content &&
-	hg commit -m feature-a
-	) &&
-
-	git clone "hg::hgrepo" gitrepo &&
-	check gitrepo origin/feature-a feature-a
-'
-
-test_expect_success 'update bookmark' '
-	test_when_finished "rm -rf gitrepo*" &&
-
-	(
-	cd hgrepo &&
-	hg bookmark devel
-	) &&
-
-	(
-	git clone "hg::hgrepo" gitrepo &&
-	cd gitrepo &&
-	git checkout --quiet devel &&
-	echo devel > content &&
-	git commit -a -m devel &&
-	git push --quiet
-	) &&
-
-	check_bookmark hgrepo devel devel
-'
-
-test_expect_success 'new bookmark' '
-	test_when_finished "rm -rf gitrepo*" &&
-
-	(
-	git clone "hg::hgrepo" gitrepo &&
-	cd gitrepo &&
-	git checkout --quiet -b feature-b &&
-	echo feature-b > content &&
-	git commit -a -m feature-b &&
-	git push --quiet origin feature-b
-	) &&
-
-	check_bookmark hgrepo feature-b feature-b
-'
-
-# cleanup previous stuff
-rm -rf hgrepo
-
-author_test () {
-	echo $1 >> content &&
-	hg commit -u "$2" -m "add $1" &&
-	echo "$3" >> ../expected
-}
-
-test_expect_success 'authors' '
-	test_when_finished "rm -rf hgrepo gitrepo" &&
-
-	(
-	hg init hgrepo &&
-	cd hgrepo &&
-
-	touch content &&
-	hg add content &&
-
-	> ../expected &&
-	author_test alpha "" "H G Wells <wells@example.com>" &&
-	author_test beta "test" "test <unknown>" &&
-	author_test beta "test <test@example.com> (comment)" "test <test@example.com>" &&
-	author_test gamma "<test@example.com>" "Unknown <test@example.com>" &&
-	author_test delta "name<test@example.com>" "name <test@example.com>" &&
-	author_test epsilon "name <test@example.com" "name <test@example.com>" &&
-	author_test zeta " test " "test <unknown>" &&
-	author_test eta "test < test@example.com >" "test <test@example.com>" &&
-	author_test theta "test >test@example.com>" "test <test@example.com>" &&
-	author_test iota "test < test <at> example <dot> com>" "test <unknown>" &&
-	author_test kappa "test@example.com" "Unknown <test@example.com>"
-	) &&
-
-	git clone "hg::hgrepo" gitrepo &&
-	git --git-dir=gitrepo/.git log --reverse --format="%an <%ae>" > actual &&
-
-	test_cmp expected actual
-'
-
-test_expect_success 'strip' '
-	test_when_finished "rm -rf hgrepo gitrepo" &&
-
-	(
-	hg init hgrepo &&
-	cd hgrepo &&
-
-	echo one >> content &&
-	hg add content &&
-	hg commit -m one &&
-
-	echo two >> content &&
-	hg commit -m two
-	) &&
-
-	git clone "hg::hgrepo" gitrepo &&
-
-	(
-	cd hgrepo &&
-	hg strip 1 &&
-
-	echo three >> content &&
-	hg commit -m three &&
-
-	echo four >> content &&
-	hg commit -m four
-	) &&
-
-	(
-	cd gitrepo &&
-	git fetch &&
-	git log --format="%s" origin/master > ../actual
-	) &&
-
-	hg -R hgrepo log --template "{desc}\n" > expected &&
-	test_cmp actual expected
-'
-
-test_expect_success 'remote push with master bookmark' '
-	test_when_finished "rm -rf hgrepo gitrepo*" &&
-
-	(
-	hg init hgrepo &&
-	cd hgrepo &&
-	echo zero > content &&
-	hg add content &&
-	hg commit -m zero &&
-	hg bookmark master &&
-	echo one > content &&
-	hg commit -m one
-	) &&
-
-	(
-	git clone "hg::hgrepo" gitrepo &&
-	cd gitrepo &&
-	echo two > content &&
-	git commit -a -m two &&
-	git push
-	) &&
-
-	check_branch hgrepo default two
-'
-
-cat > expected <<EOF
-changeset:   0:6e2126489d3d
-tag:         tip
-user:        A U Thor <author@example.com>
-date:        Mon Jan 01 00:00:00 2007 +0230
-summary:     one
-
-EOF
-
-test_expect_success 'remote push from master branch' '
-	test_when_finished "rm -rf hgrepo gitrepo*" &&
-
-	hg init hgrepo &&
-
-	(
-	git init gitrepo &&
-	cd gitrepo &&
-	git remote add origin "hg::../hgrepo" &&
-	echo one > content &&
-	git add content &&
-	git commit -a -m one &&
-	git push origin master
-	) &&
-
-	hg -R hgrepo log > actual &&
-	cat actual &&
-	test_cmp expected actual &&
-
-	check_branch hgrepo default one
-'
-
-GIT_REMOTE_HG_TEST_REMOTE=1
-export GIT_REMOTE_HG_TEST_REMOTE
-
-test_expect_success 'remote cloning' '
-	test_when_finished "rm -rf gitrepo*" &&
-
-	(
-	hg init hgrepo &&
-	cd hgrepo &&
-	echo zero > content &&
-	hg add content &&
-	hg commit -m zero
-	) &&
-
-	git clone "hg::hgrepo" gitrepo &&
-	check gitrepo HEAD zero
-'
-
-test_expect_success 'remote update bookmark' '
-	test_when_finished "rm -rf gitrepo*" &&
-
-	(
-	cd hgrepo &&
-	hg bookmark devel
-	) &&
-
-	(
-	git clone "hg::hgrepo" gitrepo &&
-	cd gitrepo &&
-	git checkout --quiet devel &&
-	echo devel > content &&
-	git commit -a -m devel &&
-	git push --quiet
-	) &&
-
-	check_bookmark hgrepo devel devel
-'
-
-test_expect_success 'remote new bookmark' '
-	test_when_finished "rm -rf gitrepo*" &&
-
-	(
-	git clone "hg::hgrepo" gitrepo &&
-	cd gitrepo &&
-	git checkout --quiet -b feature-b &&
-	echo feature-b > content &&
-	git commit -a -m feature-b &&
-	git push --quiet origin feature-b
-	) &&
-
-	check_bookmark hgrepo feature-b feature-b
-'
-
-test_expect_success 'remote push diverged' '
-	test_when_finished "rm -rf gitrepo*" &&
-
-	git clone "hg::hgrepo" gitrepo &&
-
-	(
-	cd hgrepo &&
-	hg checkout default &&
-	echo bump > content &&
-	hg commit -m bump
-	) &&
-
-	(
-	cd gitrepo &&
-	echo diverge > content &&
-	git commit -a -m diverged &&
-	check_push 1 <<-EOF
-	master:non-fast-forward
-	EOF
-	) &&
-
-	check_branch hgrepo default bump
-'
-
-test_expect_success 'remote update bookmark diverge' '
-	test_when_finished "rm -rf gitrepo*" &&
-
-	(
-	cd hgrepo &&
-	hg checkout tip^ &&
-	hg bookmark diverge
-	) &&
-
-	git clone "hg::hgrepo" gitrepo &&
-
-	(
-	cd hgrepo &&
-	echo "bump bookmark" > content &&
-	hg commit -m "bump bookmark"
-	) &&
-
-	(
-	cd gitrepo &&
-	git checkout --quiet diverge &&
-	echo diverge > content &&
-	git commit -a -m diverge &&
-	check_push 1 <<-EOF
-	diverge:fetch-first
-	EOF
-	) &&
-
-	check_bookmark hgrepo diverge "bump bookmark"
-'
-
-test_expect_success 'remote new bookmark multiple branch head' '
-	test_when_finished "rm -rf gitrepo*" &&
-
-	(
-	git clone "hg::hgrepo" gitrepo &&
-	cd gitrepo &&
-	git checkout --quiet -b feature-c HEAD^ &&
-	echo feature-c > content &&
-	git commit -a -m feature-c &&
-	git push --quiet origin feature-c
-	) &&
-
-	check_bookmark hgrepo feature-c feature-c
-'
-
-# cleanup previous stuff
-rm -rf hgrepo
-
-setup_big_push () {
-	(
-	hg init hgrepo &&
-	cd hgrepo &&
-	echo zero > content &&
-	hg add content &&
-	hg commit -m zero &&
-	hg bookmark bad_bmark1 &&
-	echo one > content &&
-	hg commit -m one &&
-	hg bookmark bad_bmark2 &&
-	hg bookmark good_bmark &&
-	hg bookmark -i good_bmark &&
-	hg -q branch good_branch &&
-	echo "good branch" > content &&
-	hg commit -m "good branch" &&
-	hg -q branch bad_branch &&
-	echo "bad branch" > content &&
-	hg commit -m "bad branch"
-	) &&
-
-	git clone "hg::hgrepo" gitrepo &&
-
-	(
-	cd gitrepo &&
-	echo two > content &&
-	git commit -q -a -m two &&
-
-	git checkout -q good_bmark &&
-	echo three > content &&
-	git commit -q -a -m three &&
-
-	git checkout -q bad_bmark1 &&
-	git reset --hard HEAD^ &&
-	echo four > content &&
-	git commit -q -a -m four &&
-
-	git checkout -q bad_bmark2 &&
-	git reset --hard HEAD^ &&
-	echo five > content &&
-	git commit -q -a -m five &&
-
-	git checkout -q -b new_bmark master &&
-	echo six > content &&
-	git commit -q -a -m six &&
-
-	git checkout -q branches/good_branch &&
-	echo seven > content &&
-	git commit -q -a -m seven &&
-	echo eight > content &&
-	git commit -q -a -m eight &&
-
-	git checkout -q branches/bad_branch &&
-	git reset --hard HEAD^ &&
-	echo nine > content &&
-	git commit -q -a -m nine &&
-
-	git checkout -q -b branches/new_branch master &&
-	echo ten > content &&
-	git commit -q -a -m ten
-	)
-}
-
-test_expect_success 'remote big push' '
-	test_when_finished "rm -rf hgrepo gitrepo*" &&
-
-	setup_big_push
-
-	(
-	cd gitrepo &&
-
-	check_push 1 --all <<-EOF
-	master
-	good_bmark
-	branches/good_branch
-	new_bmark:new
-	branches/new_branch:new
-	bad_bmark1:non-fast-forward
-	bad_bmark2:non-fast-forward
-	branches/bad_branch:non-fast-forward
-	EOF
-	) &&
-
-	check_branch hgrepo default one &&
-	check_branch hgrepo good_branch "good branch" &&
-	check_branch hgrepo bad_branch "bad branch" &&
-	check_branch hgrepo new_branch '' &&
-	check_bookmark hgrepo good_bmark one &&
-	check_bookmark hgrepo bad_bmark1 one &&
-	check_bookmark hgrepo bad_bmark2 one &&
-	check_bookmark hgrepo new_bmark ''
-'
-
-test_expect_success 'remote big push fetch first' '
-	test_when_finished "rm -rf hgrepo gitrepo*" &&
-
-	(
-	hg init hgrepo &&
-	cd hgrepo &&
-	echo zero > content &&
-	hg add content &&
-	hg commit -m zero &&
-	hg bookmark bad_bmark &&
-	hg bookmark good_bmark &&
-	hg bookmark -i good_bmark &&
-	hg -q branch good_branch &&
-	echo "good branch" > content &&
-	hg commit -m "good branch" &&
-	hg -q branch bad_branch &&
-	echo "bad branch" > content &&
-	hg commit -m "bad branch"
-	) &&
-
-	git clone "hg::hgrepo" gitrepo &&
-
-	(
-	cd hgrepo &&
-	hg bookmark -f bad_bmark &&
-	echo update_bmark > content &&
-	hg commit -m "update bmark"
-	) &&
-
-	(
-	cd gitrepo &&
-	echo two > content &&
-	git commit -q -a -m two &&
-
-	git checkout -q good_bmark &&
-	echo three > content &&
-	git commit -q -a -m three &&
-
-	git checkout -q bad_bmark &&
-	echo four > content &&
-	git commit -q -a -m four &&
-
-	git checkout -q branches/bad_branch &&
-	echo five > content &&
-	git commit -q -a -m five &&
-
-	check_push 1 --all <<-EOF
-	master
-	good_bmark
-	new_bmark:new
-	new_branch:new
-	bad_bmark:fetch-first
-	branches/bad_branch:festch-first
-	EOF
-
-	git fetch &&
-
-	check_push 1 --all <<-EOF
-	master
-	good_bmark
-	bad_bmark:non-fast-forward
-	branches/bad_branch:non-fast-forward
-	EOF
-	)
-'
-
-test_expect_failure 'remote big push force' '
-	test_when_finished "rm -rf hgrepo gitrepo*" &&
-
-	setup_big_push
-
-	(
-	cd gitrepo &&
-
-	check_push 0 --force --all <<-EOF
-	master
-	good_bmark
-	branches/good_branch
-	new_bmark:new
-	branches/new_branch:new
-	bad_bmark1:forced-update
-	bad_bmark2:forced-update
-	branches/bad_branch:forced-update
-	EOF
-	) &&
-
-	check_branch hgrepo default six &&
-	check_branch hgrepo good_branch eight &&
-	check_branch hgrepo bad_branch nine &&
-	check_branch hgrepo new_branch ten &&
-	check_bookmark hgrepo good_bmark three &&
-	check_bookmark hgrepo bad_bmark1 four &&
-	check_bookmark hgrepo bad_bmark2 five &&
-	check_bookmark hgrepo new_bmark six
-'
-
-test_expect_failure 'remote big push dry-run' '
-	test_when_finished "rm -rf hgrepo gitrepo*" &&
-
-	setup_big_push
-
-	(
-	cd gitrepo &&
-
-	check_push 0 --dry-run --all <<-EOF
-	master
-	good_bmark
-	branches/good_branch
-	new_bmark:new
-	branches/new_branch:new
-	bad_bmark1:non-fast-forward
-	bad_bmark2:non-fast-forward
-	branches/bad_branch:non-fast-forward
-	EOF
-
-	check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-EOF
-	master
-	good_bmark
-	branches/good_branch
-	new_bmark:new
-	branches/new_branch:new
-	EOF
-	) &&
-
-	check_branch hgrepo default one &&
-	check_branch hgrepo good_branch "good branch" &&
-	check_branch hgrepo bad_branch "bad branch" &&
-	check_branch hgrepo new_branch '' &&
-	check_bookmark hgrepo good_bmark one &&
-	check_bookmark hgrepo bad_bmark1 one &&
-	check_bookmark hgrepo bad_bmark2 one &&
-	check_bookmark hgrepo new_bmark ''
-'
-
-test_expect_success 'remote double failed push' '
-	test_when_finished "rm -rf hgrepo gitrepo*" &&
-
-	(
-	hg init hgrepo &&
-	cd hgrepo &&
-	echo zero > content &&
-	hg add content &&
-	hg commit -m zero &&
-	echo one > content &&
-	hg commit -m one
-	) &&
-
-	(
-	git clone "hg::hgrepo" gitrepo &&
-	cd gitrepo &&
-	git reset --hard HEAD^ &&
-	echo two > content &&
-	git commit -a -m two &&
-	test_expect_code 1 git push &&
-	test_expect_code 1 git push
-	)
-'
-
-test_done
diff --git a/contrib/remote-helpers/test-hg.t b/contrib/remote-helpers/test-hg.t
new file mode 100755
index 0000000..30f4ff6
--- /dev/null
+++ b/contrib/remote-helpers/test-hg.t
@@ -0,0 +1,692 @@
+#!/bin/sh
+#
+# Copyright (c) 2012 Felipe Contreras
+#
+# Base commands from hg-git tests:
+# https://bitbucket.org/durin42/hg-git/src
+#
+
+test_description='Test remote-hg'
+
+. ./test-lib.sh
+
+if ! test_have_prereq PYTHON; then
+	skip_all='skipping remote-hg tests; python not available'
+	test_done
+fi
+
+if ! "$PYTHON_PATH" -c 'import mercurial'; then
+	skip_all='skipping remote-hg tests; mercurial not available'
+	test_done
+fi
+
+check () {
+	echo $3 > expected &&
+	git --git-dir=$1/.git log --format='%s' -1 $2 > actual
+	test_cmp expected actual
+}
+
+check_branch () {
+	if [ -n "$3" ]; then
+		echo $3 > expected &&
+		hg -R $1 log -r $2 --template '{desc}\n' > actual &&
+		test_cmp expected actual
+	else
+		hg -R $1 branches > out &&
+		! grep $2 out
+	fi
+}
+
+check_bookmark () {
+	if [ -n "$3" ]; then
+		echo $3 > expected &&
+		hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' > actual &&
+		test_cmp expected actual
+	else
+		hg -R $1 bookmarks > out &&
+		! grep $2 out
+	fi
+}
+
+check_push () {
+	local expected_ret=$1 ret=0 ref_ret=0 IFS=':'
+
+	shift
+	git push origin "$@" 2> error
+	ret=$?
+	cat error
+
+	while read branch kind
+	do
+		case "$kind" in
+		'new')
+			grep "^ \* \[new branch\] *${branch} -> ${branch}$" error || ref_ret=1
+			;;
+		'non-fast-forward')
+			grep "^ ! \[rejected\] *${branch} -> ${branch} (non-fast-forward)$" error || ref_ret=1
+			;;
+		'fetch-first')
+			grep "^ ! \[rejected\] *${branch} -> ${branch} (fetch first)$" error || ref_ret=1
+			;;
+		'forced-update')
+			grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *${branch} -> ${branch} (forced update)$" error || ref_ret=1
+			;;
+		'')
+			grep "^   [a-f0-9]*\.\.[a-f0-9]* *${branch} -> ${branch}$" error || ref_ret=1
+			;;
+		esac
+		let 'ref_ret' && echo "match for '$branch' failed" && break
+	done
+
+	if let 'expected_ret != ret || ref_ret'
+	then
+		return 1
+	fi
+
+	return 0
+}
+
+setup () {
+	(
+	echo "[ui]"
+	echo "username = H G Wells <wells@example.com>"
+	echo "[extensions]"
+	echo "mq ="
+	) >> "$HOME"/.hgrc &&
+
+	GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230" &&
+	GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" &&
+	export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
+}
+
+setup
+
+test_expect_success 'cloning' '
+	test_when_finished "rm -rf gitrepo*" &&
+
+	(
+	hg init hgrepo &&
+	cd hgrepo &&
+	echo zero > content &&
+	hg add content &&
+	hg commit -m zero
+	) &&
+
+	git clone "hg::hgrepo" gitrepo &&
+	check gitrepo HEAD zero
+'
+
+test_expect_success 'cloning with branches' '
+	test_when_finished "rm -rf gitrepo*" &&
+
+	(
+	cd hgrepo &&
+	hg branch next &&
+	echo next > content &&
+	hg commit -m next
+	) &&
+
+	git clone "hg::hgrepo" gitrepo &&
+	check gitrepo origin/branches/next next
+'
+
+test_expect_success 'cloning with bookmarks' '
+	test_when_finished "rm -rf gitrepo*" &&
+
+	(
+	cd hgrepo &&
+	hg checkout default &&
+	hg bookmark feature-a &&
+	echo feature-a > content &&
+	hg commit -m feature-a
+	) &&
+
+	git clone "hg::hgrepo" gitrepo &&
+	check gitrepo origin/feature-a feature-a
+'
+
+test_expect_success 'update bookmark' '
+	test_when_finished "rm -rf gitrepo*" &&
+
+	(
+	cd hgrepo &&
+	hg bookmark devel
+	) &&
+
+	(
+	git clone "hg::hgrepo" gitrepo &&
+	cd gitrepo &&
+	git checkout --quiet devel &&
+	echo devel > content &&
+	git commit -a -m devel &&
+	git push --quiet
+	) &&
+
+	check_bookmark hgrepo devel devel
+'
+
+test_expect_success 'new bookmark' '
+	test_when_finished "rm -rf gitrepo*" &&
+
+	(
+	git clone "hg::hgrepo" gitrepo &&
+	cd gitrepo &&
+	git checkout --quiet -b feature-b &&
+	echo feature-b > content &&
+	git commit -a -m feature-b &&
+	git push --quiet origin feature-b
+	) &&
+
+	check_bookmark hgrepo feature-b feature-b
+'
+
+# cleanup previous stuff
+rm -rf hgrepo
+
+author_test () {
+	echo $1 >> content &&
+	hg commit -u "$2" -m "add $1" &&
+	echo "$3" >> ../expected
+}
+
+test_expect_success 'authors' '
+	test_when_finished "rm -rf hgrepo gitrepo" &&
+
+	(
+	hg init hgrepo &&
+	cd hgrepo &&
+
+	touch content &&
+	hg add content &&
+
+	> ../expected &&
+	author_test alpha "" "H G Wells <wells@example.com>" &&
+	author_test beta "test" "test <unknown>" &&
+	author_test beta "test <test@example.com> (comment)" "test <test@example.com>" &&
+	author_test gamma "<test@example.com>" "Unknown <test@example.com>" &&
+	author_test delta "name<test@example.com>" "name <test@example.com>" &&
+	author_test epsilon "name <test@example.com" "name <test@example.com>" &&
+	author_test zeta " test " "test <unknown>" &&
+	author_test eta "test < test@example.com >" "test <test@example.com>" &&
+	author_test theta "test >test@example.com>" "test <test@example.com>" &&
+	author_test iota "test < test <at> example <dot> com>" "test <unknown>" &&
+	author_test kappa "test@example.com" "Unknown <test@example.com>"
+	) &&
+
+	git clone "hg::hgrepo" gitrepo &&
+	git --git-dir=gitrepo/.git log --reverse --format="%an <%ae>" > actual &&
+
+	test_cmp expected actual
+'
+
+test_expect_success 'strip' '
+	test_when_finished "rm -rf hgrepo gitrepo" &&
+
+	(
+	hg init hgrepo &&
+	cd hgrepo &&
+
+	echo one >> content &&
+	hg add content &&
+	hg commit -m one &&
+
+	echo two >> content &&
+	hg commit -m two
+	) &&
+
+	git clone "hg::hgrepo" gitrepo &&
+
+	(
+	cd hgrepo &&
+	hg strip 1 &&
+
+	echo three >> content &&
+	hg commit -m three &&
+
+	echo four >> content &&
+	hg commit -m four
+	) &&
+
+	(
+	cd gitrepo &&
+	git fetch &&
+	git log --format="%s" origin/master > ../actual
+	) &&
+
+	hg -R hgrepo log --template "{desc}\n" > expected &&
+	test_cmp actual expected
+'
+
+test_expect_success 'remote push with master bookmark' '
+	test_when_finished "rm -rf hgrepo gitrepo*" &&
+
+	(
+	hg init hgrepo &&
+	cd hgrepo &&
+	echo zero > content &&
+	hg add content &&
+	hg commit -m zero &&
+	hg bookmark master &&
+	echo one > content &&
+	hg commit -m one
+	) &&
+
+	(
+	git clone "hg::hgrepo" gitrepo &&
+	cd gitrepo &&
+	echo two > content &&
+	git commit -a -m two &&
+	git push
+	) &&
+
+	check_branch hgrepo default two
+'
+
+cat > expected <<EOF
+changeset:   0:6e2126489d3d
+tag:         tip
+user:        A U Thor <author@example.com>
+date:        Mon Jan 01 00:00:00 2007 +0230
+summary:     one
+
+EOF
+
+test_expect_success 'remote push from master branch' '
+	test_when_finished "rm -rf hgrepo gitrepo*" &&
+
+	hg init hgrepo &&
+
+	(
+	git init gitrepo &&
+	cd gitrepo &&
+	git remote add origin "hg::../hgrepo" &&
+	echo one > content &&
+	git add content &&
+	git commit -a -m one &&
+	git push origin master
+	) &&
+
+	hg -R hgrepo log > actual &&
+	cat actual &&
+	test_cmp expected actual &&
+
+	check_branch hgrepo default one
+'
+
+GIT_REMOTE_HG_TEST_REMOTE=1
+export GIT_REMOTE_HG_TEST_REMOTE
+
+test_expect_success 'remote cloning' '
+	test_when_finished "rm -rf gitrepo*" &&
+
+	(
+	hg init hgrepo &&
+	cd hgrepo &&
+	echo zero > content &&
+	hg add content &&
+	hg commit -m zero
+	) &&
+
+	git clone "hg::hgrepo" gitrepo &&
+	check gitrepo HEAD zero
+'
+
+test_expect_success 'remote update bookmark' '
+	test_when_finished "rm -rf gitrepo*" &&
+
+	(
+	cd hgrepo &&
+	hg bookmark devel
+	) &&
+
+	(
+	git clone "hg::hgrepo" gitrepo &&
+	cd gitrepo &&
+	git checkout --quiet devel &&
+	echo devel > content &&
+	git commit -a -m devel &&
+	git push --quiet
+	) &&
+
+	check_bookmark hgrepo devel devel
+'
+
+test_expect_success 'remote new bookmark' '
+	test_when_finished "rm -rf gitrepo*" &&
+
+	(
+	git clone "hg::hgrepo" gitrepo &&
+	cd gitrepo &&
+	git checkout --quiet -b feature-b &&
+	echo feature-b > content &&
+	git commit -a -m feature-b &&
+	git push --quiet origin feature-b
+	) &&
+
+	check_bookmark hgrepo feature-b feature-b
+'
+
+test_expect_success 'remote push diverged' '
+	test_when_finished "rm -rf gitrepo*" &&
+
+	git clone "hg::hgrepo" gitrepo &&
+
+	(
+	cd hgrepo &&
+	hg checkout default &&
+	echo bump > content &&
+	hg commit -m bump
+	) &&
+
+	(
+	cd gitrepo &&
+	echo diverge > content &&
+	git commit -a -m diverged &&
+	check_push 1 <<-EOF
+	master:non-fast-forward
+	EOF
+	) &&
+
+	check_branch hgrepo default bump
+'
+
+test_expect_success 'remote update bookmark diverge' '
+	test_when_finished "rm -rf gitrepo*" &&
+
+	(
+	cd hgrepo &&
+	hg checkout tip^ &&
+	hg bookmark diverge
+	) &&
+
+	git clone "hg::hgrepo" gitrepo &&
+
+	(
+	cd hgrepo &&
+	echo "bump bookmark" > content &&
+	hg commit -m "bump bookmark"
+	) &&
+
+	(
+	cd gitrepo &&
+	git checkout --quiet diverge &&
+	echo diverge > content &&
+	git commit -a -m diverge &&
+	check_push 1 <<-EOF
+	diverge:fetch-first
+	EOF
+	) &&
+
+	check_bookmark hgrepo diverge "bump bookmark"
+'
+
+test_expect_success 'remote new bookmark multiple branch head' '
+	test_when_finished "rm -rf gitrepo*" &&
+
+	(
+	git clone "hg::hgrepo" gitrepo &&
+	cd gitrepo &&
+	git checkout --quiet -b feature-c HEAD^ &&
+	echo feature-c > content &&
+	git commit -a -m feature-c &&
+	git push --quiet origin feature-c
+	) &&
+
+	check_bookmark hgrepo feature-c feature-c
+'
+
+# cleanup previous stuff
+rm -rf hgrepo
+
+setup_big_push () {
+	(
+	hg init hgrepo &&
+	cd hgrepo &&
+	echo zero > content &&
+	hg add content &&
+	hg commit -m zero &&
+	hg bookmark bad_bmark1 &&
+	echo one > content &&
+	hg commit -m one &&
+	hg bookmark bad_bmark2 &&
+	hg bookmark good_bmark &&
+	hg bookmark -i good_bmark &&
+	hg -q branch good_branch &&
+	echo "good branch" > content &&
+	hg commit -m "good branch" &&
+	hg -q branch bad_branch &&
+	echo "bad branch" > content &&
+	hg commit -m "bad branch"
+	) &&
+
+	git clone "hg::hgrepo" gitrepo &&
+
+	(
+	cd gitrepo &&
+	echo two > content &&
+	git commit -q -a -m two &&
+
+	git checkout -q good_bmark &&
+	echo three > content &&
+	git commit -q -a -m three &&
+
+	git checkout -q bad_bmark1 &&
+	git reset --hard HEAD^ &&
+	echo four > content &&
+	git commit -q -a -m four &&
+
+	git checkout -q bad_bmark2 &&
+	git reset --hard HEAD^ &&
+	echo five > content &&
+	git commit -q -a -m five &&
+
+	git checkout -q -b new_bmark master &&
+	echo six > content &&
+	git commit -q -a -m six &&
+
+	git checkout -q branches/good_branch &&
+	echo seven > content &&
+	git commit -q -a -m seven &&
+	echo eight > content &&
+	git commit -q -a -m eight &&
+
+	git checkout -q branches/bad_branch &&
+	git reset --hard HEAD^ &&
+	echo nine > content &&
+	git commit -q -a -m nine &&
+
+	git checkout -q -b branches/new_branch master &&
+	echo ten > content &&
+	git commit -q -a -m ten
+	)
+}
+
+test_expect_success 'remote big push' '
+	test_when_finished "rm -rf hgrepo gitrepo*" &&
+
+	setup_big_push
+
+	(
+	cd gitrepo &&
+
+	check_push 1 --all <<-EOF
+	master
+	good_bmark
+	branches/good_branch
+	new_bmark:new
+	branches/new_branch:new
+	bad_bmark1:non-fast-forward
+	bad_bmark2:non-fast-forward
+	branches/bad_branch:non-fast-forward
+	EOF
+	) &&
+
+	check_branch hgrepo default one &&
+	check_branch hgrepo good_branch "good branch" &&
+	check_branch hgrepo bad_branch "bad branch" &&
+	check_branch hgrepo new_branch '' &&
+	check_bookmark hgrepo good_bmark one &&
+	check_bookmark hgrepo bad_bmark1 one &&
+	check_bookmark hgrepo bad_bmark2 one &&
+	check_bookmark hgrepo new_bmark ''
+'
+
+test_expect_success 'remote big push fetch first' '
+	test_when_finished "rm -rf hgrepo gitrepo*" &&
+
+	(
+	hg init hgrepo &&
+	cd hgrepo &&
+	echo zero > content &&
+	hg add content &&
+	hg commit -m zero &&
+	hg bookmark bad_bmark &&
+	hg bookmark good_bmark &&
+	hg bookmark -i good_bmark &&
+	hg -q branch good_branch &&
+	echo "good branch" > content &&
+	hg commit -m "good branch" &&
+	hg -q branch bad_branch &&
+	echo "bad branch" > content &&
+	hg commit -m "bad branch"
+	) &&
+
+	git clone "hg::hgrepo" gitrepo &&
+
+	(
+	cd hgrepo &&
+	hg bookmark -f bad_bmark &&
+	echo update_bmark > content &&
+	hg commit -m "update bmark"
+	) &&
+
+	(
+	cd gitrepo &&
+	echo two > content &&
+	git commit -q -a -m two &&
+
+	git checkout -q good_bmark &&
+	echo three > content &&
+	git commit -q -a -m three &&
+
+	git checkout -q bad_bmark &&
+	echo four > content &&
+	git commit -q -a -m four &&
+
+	git checkout -q branches/bad_branch &&
+	echo five > content &&
+	git commit -q -a -m five &&
+
+	check_push 1 --all <<-EOF
+	master
+	good_bmark
+	new_bmark:new
+	new_branch:new
+	bad_bmark:fetch-first
+	branches/bad_branch:festch-first
+	EOF
+
+	git fetch &&
+
+	check_push 1 --all <<-EOF
+	master
+	good_bmark
+	bad_bmark:non-fast-forward
+	branches/bad_branch:non-fast-forward
+	EOF
+	)
+'
+
+test_expect_failure 'remote big push force' '
+	test_when_finished "rm -rf hgrepo gitrepo*" &&
+
+	setup_big_push
+
+	(
+	cd gitrepo &&
+
+	check_push 0 --force --all <<-EOF
+	master
+	good_bmark
+	branches/good_branch
+	new_bmark:new
+	branches/new_branch:new
+	bad_bmark1:forced-update
+	bad_bmark2:forced-update
+	branches/bad_branch:forced-update
+	EOF
+	) &&
+
+	check_branch hgrepo default six &&
+	check_branch hgrepo good_branch eight &&
+	check_branch hgrepo bad_branch nine &&
+	check_branch hgrepo new_branch ten &&
+	check_bookmark hgrepo good_bmark three &&
+	check_bookmark hgrepo bad_bmark1 four &&
+	check_bookmark hgrepo bad_bmark2 five &&
+	check_bookmark hgrepo new_bmark six
+'
+
+test_expect_failure 'remote big push dry-run' '
+	test_when_finished "rm -rf hgrepo gitrepo*" &&
+
+	setup_big_push
+
+	(
+	cd gitrepo &&
+
+	check_push 0 --dry-run --all <<-EOF
+	master
+	good_bmark
+	branches/good_branch
+	new_bmark:new
+	branches/new_branch:new
+	bad_bmark1:non-fast-forward
+	bad_bmark2:non-fast-forward
+	branches/bad_branch:non-fast-forward
+	EOF
+
+	check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-EOF
+	master
+	good_bmark
+	branches/good_branch
+	new_bmark:new
+	branches/new_branch:new
+	EOF
+	) &&
+
+	check_branch hgrepo default one &&
+	check_branch hgrepo good_branch "good branch" &&
+	check_branch hgrepo bad_branch "bad branch" &&
+	check_branch hgrepo new_branch '' &&
+	check_bookmark hgrepo good_bmark one &&
+	check_bookmark hgrepo bad_bmark1 one &&
+	check_bookmark hgrepo bad_bmark2 one &&
+	check_bookmark hgrepo new_bmark ''
+'
+
+test_expect_success 'remote double failed push' '
+	test_when_finished "rm -rf hgrepo gitrepo*" &&
+
+	(
+	hg init hgrepo &&
+	cd hgrepo &&
+	echo zero > content &&
+	hg add content &&
+	hg commit -m zero &&
+	echo one > content &&
+	hg commit -m one
+	) &&
+
+	(
+	git clone "hg::hgrepo" gitrepo &&
+	cd gitrepo &&
+	git reset --hard HEAD^ &&
+	echo two > content &&
+	git commit -a -m two &&
+	test_expect_code 1 git push &&
+	test_expect_code 1 git push
+	)
+'
+
+test_done
-- 
1.8.4-fc

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/5] build: fix installation of scripts
  2013-10-12  7:04 [PATCH v2 0/5] remote-helpers: test reorganization Felipe Contreras
                   ` (2 preceding siblings ...)
  2013-10-12  7:04 ` [PATCH v2 3/5] remote-helpers: rename tests Felipe Contreras
@ 2013-10-12  7:04 ` Felipe Contreras
  3 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2013-10-12  7:04 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

They need the gitexecdir.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 Makefile | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 3588ca1..e51b92e 100644
--- a/Makefile
+++ b/Makefile
@@ -511,12 +511,14 @@ build-perl-script: $(SCRIPT_PERL_GEN)
 build-sh-script: $(SCRIPT_SH_GEN)
 build-python-script: $(SCRIPT_PYTHON_GEN)
 
-.PHONY: install-perl-script install-sh-script install-python-script
-install-sh-script: $(SCRIPT_SH_INS)
+.PHONY: install-gitexecdir install-perl-script install-sh-script install-python-script
+install-gitexecdir:
+	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+install-sh-script: $(SCRIPT_SH_INS) | install-gitexecdir
 	$(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
-install-perl-script: $(SCRIPT_PERL_INS)
+install-perl-script: $(SCRIPT_PERL_INS) | install-gitexecdir
 	$(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
-install-python-script: $(SCRIPT_PYTHON_INS)
+install-python-script: $(SCRIPT_PYTHON_INS) | install-gitexecdir
 	$(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
 
 .PHONY: clean-perl-script clean-sh-script clean-python-script
-- 
1.8.4-fc

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-10-12  7:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-12  7:04 [PATCH v2 0/5] remote-helpers: test reorganization Felipe Contreras
2013-10-12  7:04 ` [PATCH v2 5/5] remote-helpers: add exec-path links Felipe Contreras
2013-10-12  7:04 ` [PATCH v2 4/5] remote-helpers: allow direct test execution Felipe Contreras
2013-10-12  7:04 ` [PATCH v2 3/5] remote-helpers: rename tests Felipe Contreras
2013-10-12  7:04 ` [PATCH v2 2/5] build: fix installation of scripts Felipe Contreras

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).