diff --git a/tests/test-bookmark-workflow.t b/tests/test-bookmark-workflow.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1ib29rbWFyay13b3JrZmxvdy50..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1ib29rbWFyay13b3JrZmxvdy50 100644
--- a/tests/test-bookmark-workflow.t
+++ b/tests/test-bookmark-workflow.t
@@ -9,6 +9,9 @@
 of bookmarks should be considered "under test", and mutation of bookmarks
 locally is only to provide a test fixture.
 
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
@@ -19,9 +22,6 @@
   $ python -c 'from mercurial import util ; assert \
   >  util.version() != "unknown" and util.version() >= "2.1"' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-clone.t b/tests/test-clone.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1jbG9uZS50..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1jbG9uZS50 100755
--- a/tests/test-clone.t
+++ b/tests/test-clone.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-conflict-1.t b/tests/test-conflict-1.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1jb25mbGljdC0xLnQ=..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1jb25mbGljdC0xLnQ= 100644
--- a/tests/test-conflict-1.t
+++ b/tests/test-conflict-1.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ hg init hgrepo1
   $ cd hgrepo1
   $ echo A > afile
diff --git a/tests/test-conflict-2.t b/tests/test-conflict-2.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1jb25mbGljdC0yLnQ=..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1jb25mbGljdC0yLnQ= 100644
--- a/tests/test-conflict-2.t
+++ b/tests/test-conflict-2.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ hg init hgrepo1
   $ cd hgrepo1
   $ echo A > afile
diff --git a/tests/test-convergedmerge.t b/tests/test-convergedmerge.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1jb252ZXJnZWRtZXJnZS50..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1jb252ZXJnZWRtZXJnZS50 100644
--- a/tests/test-convergedmerge.t
+++ b/tests/test-convergedmerge.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ hg init hgrepo1
   $ cd hgrepo1
   $ echo A > afile
diff --git a/tests/test-empty-working-tree.t b/tests/test-empty-working-tree.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1lbXB0eS13b3JraW5nLXRyZWUudA==..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1lbXB0eS13b3JraW5nLXRyZWUudA== 100644
--- a/tests/test-empty-working-tree.t
+++ b/tests/test-empty-working-tree.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,12 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-encoding.t b/tests/test-encoding.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1lbmNvZGluZy50..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1lbmNvZGluZy50 100644
--- a/tests/test-encoding.t
+++ b/tests/test-encoding.t
@@ -1,8 +1,11 @@
 # -*- coding: utf-8 -*-
 
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -3,13 +6,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-file-removal.t b/tests/test-file-removal.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1maWxlLXJlbW92YWwudA==..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1maWxlLXJlbW92YWwudA== 100644
--- a/tests/test-file-removal.t
+++ b/tests/test-file-removal.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-git-clone.t b/tests/test-git-clone.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1naXQtY2xvbmUudA==..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1naXQtY2xvbmUudA== 100755
--- a/tests/test-git-clone.t
+++ b/tests/test-git-clone.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-git-submodules.t b/tests/test-git-submodules.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1naXQtc3VibW9kdWxlcy50..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1naXQtc3VibW9kdWxlcy50 100644
--- a/tests/test-git-submodules.t
+++ b/tests/test-git-submodules.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-git-tags.t b/tests/test-git-tags.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1naXQtdGFncy50..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1naXQtdGFncy50 100644
--- a/tests/test-git-tags.t
+++ b/tests/test-git-tags.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-git-workflow.t b/tests/test-git-workflow.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1naXQtd29ya2Zsb3cudA==..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1naXQtd29ya2Zsb3cudA== 100755
--- a/tests/test-git-workflow.t
+++ b/tests/test-git-workflow.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-help.t b/tests/test-help.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1oZWxwLnQ=..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1oZWxwLnQ= 100755
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1,7 +1,7 @@
 Tests that the various help files are properly registered
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
 
   $ hg help | grep 'git' | sed 's/  */ /g'
    hggit push and pull from a Git server
diff --git a/tests/test-hg-author.t b/tests/test-hg-author.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1oZy1hdXRob3IudA==..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1oZy1hdXRob3IudA== 100644
--- a/tests/test-hg-author.t
+++ b/tests/test-hg-author.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-hg-branch.t b/tests/test-hg-branch.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1oZy1icmFuY2gudA==..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1oZy1icmFuY2gudA== 100644
--- a/tests/test-hg-branch.t
+++ b/tests/test-hg-branch.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-hg-tags.t b/tests/test-hg-tags.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1oZy10YWdzLnQ=..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1oZy10YWdzLnQ= 100644
--- a/tests/test-hg-tags.t
+++ b/tests/test-hg-tags.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-incoming.t b/tests/test-incoming.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1pbmNvbWluZy50..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1pbmNvbWluZy50 100755
--- a/tests/test-incoming.t
+++ b/tests/test-incoming.t
@@ -1,3 +1,6 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
@@ -8,10 +11,6 @@
   $ python -c 'from mercurial import util ; assert \
   >  util.version() != "unknown" and util.version() > "1.7"' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-keywords.t b/tests/test-keywords.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1rZXl3b3Jkcy50..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1rZXl3b3Jkcy50 100755
--- a/tests/test-keywords.t
+++ b/tests/test-keywords.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,12 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-merge.t b/tests/test-merge.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1tZXJnZS50..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1tZXJnZS50 100644
--- a/tests/test-merge.t
+++ b/tests/test-merge.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-octopus.t b/tests/test-octopus.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1vY3RvcHVzLnQ=..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1vY3RvcHVzLnQ= 100644
--- a/tests/test-octopus.t
+++ b/tests/test-octopus.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-outgoing.t b/tests/test-outgoing.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1vdXRnb2luZy50..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1vdXRnb2luZy50 100755
--- a/tests/test-outgoing.t
+++ b/tests/test-outgoing.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-pull-after-strip.t b/tests/test-pull-after-strip.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1wdWxsLWFmdGVyLXN0cmlwLnQ=..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1wdWxsLWFmdGVyLXN0cmlwLnQ= 100755
--- a/tests/test-pull-after-strip.t
+++ b/tests/test-pull-after-strip.t
@@ -1,3 +1,6 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
@@ -15,13 +18,6 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ cat >> $HGRCPATH <<EOF
-  > [extensions]
-  > graphlog=
-  > mq=
-  > EOF
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-pull.t b/tests/test-pull.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1wdWxsLnQ=..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1wdWxsLnQ= 100644
--- a/tests/test-pull.t
+++ b/tests/test-pull.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-push-r.t b/tests/test-push-r.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1wdXNoLXIudA==..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1wdXNoLXIudA== 100755
--- a/tests/test-push-r.t
+++ b/tests/test-push-r.t
@@ -1,3 +1,6 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,10 +4,6 @@
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ hg init test
   $ cd test
   $ cat >>afile <<EOF
diff --git a/tests/test-push.t b/tests/test-push.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1wdXNoLnQ=..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1wdXNoLnQ= 100644
--- a/tests/test-push.t
+++ b/tests/test-push.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,13 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-  $ echo 'hgext.graphlog =' >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-subrepos.t b/tests/test-subrepos.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC1zdWJyZXBvcy50..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC1zdWJyZXBvcy50 100644
--- a/tests/test-subrepos.t
+++ b/tests/test-subrepos.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,12 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/test-tree-decomposition.t b/tests/test-tree-decomposition.t
index d4ad5de012a0e56b7b9da47dccabdc589642e904_dGVzdHMvdGVzdC10cmVlLWRlY29tcG9zaXRpb24udA==..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdC10cmVlLWRlY29tcG9zaXRpb24udA== 100644
--- a/tests/test-tree-decomposition.t
+++ b/tests/test-tree-decomposition.t
@@ -1,6 +1,9 @@
+Load commonly used test logic
+  $ . "$TESTDIR/testutil"
+
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
@@ -1,12 +4,9 @@
 bail if the user does not have git command-line client
   $ "$TESTDIR/hghave" git || exit 80
 
 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ echo "[extensions]" >> $HGRCPATH
-  $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
-
   $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
   $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
   $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
diff --git a/tests/testutil b/tests/testutil
new file mode 100755
index 0000000000000000000000000000000000000000..a7da97e69d56a7edc284cd7cfe1f552c9288d45d_dGVzdHMvdGVzdHV0aWw=
--- /dev/null
+++ b/tests/testutil
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# This file holds logic that is used in many tests.
+# It can be called in a test like this:
+#  $ . "$TESTDIR/testutil"
+
+# Activate extensions
+echo "[extensions]" >> $HGRCPATH
+echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH
+# Not needed in Mercurial 2.3+, as graphlog was integrated into core
+echo 'graphlog=' >> $HGRCPATH
+echo 'mq=' >> $HGRCPATH