Commits

David Carr committed c4849b2

tests: extract commonly used commit/tag functions into testutil library

Thanks to Felipe Contreras for the patch which this was based on.

The functions were renamed to make it clearer that these are shell functions
rather than normal git/hg commands, and to make it clearer which tool is being
invoked.

Old name | New name
------------------------
commit | fn_git_commit
tag | fn_git_tag
hgcommit | fn_hg_commit
hgtag | fn_hg_tag

Extraction from test-encoding.t was left for a subsequent patch, as I was seeing
unexpected output changes when I attempted the extraction.

The gitcommit and hgcommit functions in test-bookmark-workflow.t were left
as-is for now, as they have a different behavior than the standard version
(separate counters for each).

  • Participants
  • Parent commits a7da97e

Comments (0)

Files changed (22)

File tests/test-bookmark-workflow.t

   $ python -c 'from mercurial import util ; assert \
   >  util.version() != "unknown" and util.version() >= "2.1"' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
   $ gitcount=10
   $ gitcommit()
   > {

File tests/test-clone.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init
   Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m 'add alpha'
+  $ fn_git_commit -m 'add alpha'
 
   $ git tag alpha
 
   Switched to a new branch "beta"
   $ echo beta > beta
   $ git add beta
-  $ commit -m 'add beta'
+  $ fn_git_commit -m 'add beta'
 
 
   $ cd ..

File tests/test-empty-working-tree.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init

File tests/test-file-removal.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init
   Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m 'add alpha'
+  $ fn_git_commit -m 'add alpha'
   $ echo beta > beta
   $ git add beta
-  $ commit -m 'add beta'
+  $ fn_git_commit -m 'add beta'
   $ mkdir foo
   $ echo blah > foo/bar
   $ git add foo
-  $ commit -m 'add foo'
+  $ fn_git_commit -m 'add foo'
   $ git rm alpha
   rm 'alpha'
-  $ commit -m 'remove alpha'
+  $ fn_git_commit -m 'remove alpha'
   $ git rm foo/bar
   rm 'foo/bar'
-  $ commit -m 'remove foo/bar'
+  $ fn_git_commit -m 'remove foo/bar'
   $ echo % final manifest in git is just beta
   % final manifest in git is just beta
   $ git ls-files

File tests/test-git-clone.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init
   Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m 'add alpha'
+  $ fn_git_commit -m 'add alpha'
   $ echo beta > beta
   $ git add beta
-  $ commit -m 'add beta'
+  $ fn_git_commit -m 'add beta'
 
   $ cd ..
 

File tests/test-git-submodules.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error" | sed 's/, 0 deletions(-)//'
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo1
   $ cd gitrepo1
   $ git init
   Initialized empty Git repository in $TESTTMP/gitrepo1/.git/
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m 'add alpha'
+  $ fn_git_commit -m 'add alpha'
   $ cd ..
 
   $ mkdir gitsubrepo
   Initialized empty Git repository in $TESTTMP/gitsubrepo/.git/
   $ echo beta > beta
   $ git add beta
-  $ commit -m 'add beta'
+  $ fn_git_commit -m 'add beta'
   $ cd ..
 
   $ mkdir gitrepo2

File tests/test-git-tags.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-  $ tag()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git tag "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init
   $ git config receive.denyCurrentBranch ignore
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m 'add alpha'
-  $ tag alpha
+  $ fn_git_commit -m 'add alpha'
+  $ fn_git_tag alpha
 
   $ echo beta > beta
   $ git add beta
-  $ commit -m 'add beta'
-  $ tag -a -m 'added tag beta' beta
+  $ fn_git_commit -m 'add beta'
+  $ fn_git_tag -a -m 'added tag beta' beta
 
   $ cd ..
   $ hg clone gitrepo hgrepo | grep -v '^updating'

File tests/test-git-workflow.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-  $ hgcommit()
-  > {
-  >     HGDATE="2007-01-01 00:00:$count +0000"
-  >     hg commit -d "$HGDATE" "$@" >/dev/null 2>/dev/null || echo "hg commit error"
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir hgrepo
   $ cd hgrepo
   $ hg init
 
   $ echo alpha > alpha
   $ hg add alpha
-  $ hgcommit -m "add alpha"
+  $ fn_hg_commit -m "add alpha"
   $ hg log --graph --debug | grep -v phase:
   @  changeset:   0:0221c246a56712c6aa64e5ee382244d8a471b1e2
      tag:         tip
   Already on "master"
   $ echo beta > beta
   $ git add beta
-  $ commit -m 'add beta'
+  $ fn_git_commit -m 'add beta'
 
   $ echo % get things back to hg
   % get things back to hg

File tests/test-hg-author.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-  $ hgcommit()
-  > {
-  >     HGDATE="2007-01-01 00:00:$count +0000"
-  >     hg commit -d "$HGDATE" "$@" >/dev/null 2>/dev/null || echo "hg commit error"
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init
 
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m "add alpha"
+  $ fn_git_commit -m "add alpha"
   $ git checkout -b not-master
   Switched to a new branch 'not-master'
 
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ echo beta > beta
   $ hg add beta
-  $ hgcommit -u "test" -m 'add beta'
+  $ fn_hg_commit -u "test" -m 'add beta'
   $ hg push
   pushing to $TESTTMP/gitrepo
   searching for changes
 
   $ echo gamma >> beta
-  $ hgcommit -u "test <test@example.com> (comment)" -m 'modify beta'
+  $ fn_hg_commit -u "test <test@example.com> (comment)" -m 'modify beta'
   $ hg push
   pushing to $TESTTMP/gitrepo
   searching for changes
 
   $ echo gamma > gamma
   $ hg add gamma
-  $ hgcommit -u "<test@example.com>" -m 'add gamma'
+  $ fn_hg_commit -u "<test@example.com>" -m 'add gamma'
   $ hg push
   pushing to $TESTTMP/gitrepo
   searching for changes
 
   $ echo delta > delta
   $ hg add delta
-  $ hgcommit -u "name<test@example.com>" -m 'add delta'
+  $ fn_hg_commit -u "name<test@example.com>" -m 'add delta'
   $ hg push
   pushing to $TESTTMP/gitrepo
   searching for changes
 
   $ echo epsilon > epsilon
   $ hg add epsilon
-  $ hgcommit -u "name <test@example.com" -m 'add epsilon'
+  $ fn_hg_commit -u "name <test@example.com" -m 'add epsilon'
   $ hg push
   pushing to $TESTTMP/gitrepo
   searching for changes
 
   $ echo zeta > zeta
   $ hg add zeta
-  $ hgcommit -u " test " -m 'add zeta'
+  $ fn_hg_commit -u " test " -m 'add zeta'
   $ hg push
   pushing to $TESTTMP/gitrepo
   searching for changes
 
   $ echo eta > eta
   $ hg add eta
-  $ hgcommit -u "test < test@example.com >" -m 'add eta'
+  $ fn_hg_commit -u "test < test@example.com >" -m 'add eta'
   $ hg push
   pushing to $TESTTMP/gitrepo
   searching for changes
 
   $ echo theta > theta
   $ hg add theta
-  $ hgcommit -u "test >test@example.com>" -m 'add theta'
+  $ fn_hg_commit -u "test >test@example.com>" -m 'add theta'
   $ hg push
   pushing to $TESTTMP/gitrepo
   searching for changes

File tests/test-hg-branch.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
 TODO stop using this when we're 1.5 only
   $ filterhash="sed s/71414c4e3c6f/a31e374801c9/;s/698615204564/d93a72262a83/"
   $ filterhash="$filterhash;s/d93a72262a83/05aed681ccb3/"
 
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-  $ hgcommit()
-  > {
-  >     HGDATE="2007-01-01 00:00:$count +0000"
-  >     hg commit -d "$HGDATE" "$@" >/dev/null 2>/dev/null || echo "hg commit error"
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init
 
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m "add alpha"
+  $ fn_git_commit -m "add alpha"
   $ git checkout -b not-master
   Switched to a new branch 'not-master'
 
   $ hg co master
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg mv alpha beta
-  $ hgcommit -m 'rename alpha to beta'
+  $ fn_hg_commit -m 'rename alpha to beta'
   $ hg push
   pushing to $TESTTMP/gitrepo
   searching for changes
 
   $ hg branch gamma | grep -v 'permanent and global'
   marked working directory as branch gamma
-  $ hgcommit -m 'started branch gamma'
+  $ fn_hg_commit -m 'started branch gamma'
   $ hg push
   pushing to $TESTTMP/gitrepo
   searching for changes

File tests/test-hg-tags.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-  $ hgtag()
-  > {
-  >     HGDATE="2007-01-01 00:00:$count +0000"
-  >     hg tag -d "$HGDATE" "$@" >/dev/null 2>/dev/null || echo "hg commit error"
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init
 
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m "add alpha"
+  $ fn_git_commit -m "add alpha"
   $ git checkout -b not-master
   Switched to a new branch 'not-master'
 
   $ cd hgrepo
   $ hg co master
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hgtag alpha
+  $ fn_hg_tag alpha
   $ hg push
   pushing to $TESTTMP/gitrepo
   searching for changes

File tests/test-incoming.t

   $ python -c 'from mercurial import util ; assert \
   >  util.version() != "unknown" and util.version() > "1.7"' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-  $ hgcommit()
-  > {
-  >     HGDATE="2007-01-01 00:00:$count +0000"
-  >     hg commit -d "$HGDATE" "$@" >/dev/null 2>/dev/null || echo "hg commit error"
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init
 
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m "add alpha"
+  $ fn_git_commit -m "add alpha"
 
   $ cd ..
   $ hg clone gitrepo hgrepo | grep -v '^updating'
   $ cd ../gitrepo
   $ echo beta > beta
   $ git add beta
-  $ commit -m 'add beta'
+  $ fn_git_commit -m 'add beta'
 
   $ cd ../hgrepo
   $ hg incoming | grep -v 'no changes found' | grep -v 'bookmark:'
   $ mkdir d
   $ echo gamma > d/gamma
   $ git add d/gamma
-  $ commit -m'add d/gamma'
+  $ fn_git_commit -m'add d/gamma'
   $ git tag t1
 
   $ echo gamma 2 >> d/gamma
   $ git add d/gamma
-  $ commit -m'add d/gamma line 2'
+  $ fn_git_commit -m'add d/gamma line 2'
 
   $ cd ../hgrepo
   $ hg incoming -p | grep -v 'no changes found' | grep -v 'bookmark:'

File tests/test-keywords.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init
   Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m 'add alpha'
+  $ fn_git_commit -m 'add alpha'
   $ echo beta > beta
   $ git add beta
-  $ commit -m 'add beta'
+  $ fn_git_commit -m 'add beta'
 
   $ cd ..
 

File tests/test-merge.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error" | sed 's/, 0 deletions(-)//'
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init
   Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m 'add alpha'
+  $ fn_git_commit -m 'add alpha'
 
   $ git checkout -b beta 2>&1 | sed s/\'/\"/g
   Switched to a new branch "beta"
   $ echo beta > beta
   $ git add beta
-  $ commit -m 'add beta'
+  $ fn_git_commit -m 'add beta'
 
   $ git checkout master 2>&1 | sed s/\'/\"/g
   Switched to branch "master"
   $ echo gamma > gamma
   $ git add gamma
-  $ commit -m 'add gamma'
+  $ fn_git_commit -m 'add gamma'
 
 clean merge
   $ git merge beta | sed "s/the '//;s/' strategy//" | sed 's/^Merge.*recursive.*$/Merge successful/' | sed 's/files/file/;s/insertions/insertion/;s/, 0 deletions.*//' | sed 's/|  */| /'

File tests/test-octopus.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error" | sed 's/0 deletions(-)//'
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init
 
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m 'add alpha'
+  $ fn_git_commit -m 'add alpha'
 
   $ git checkout -b branch1 2>&1 | sed s/\'/\"/g
   Switched to a new branch "branch1"
   $ echo beta > beta
   $ git add beta
-  $ commit -m 'add beta'
+  $ fn_git_commit -m 'add beta'
 
   $ git checkout -b branch2 master 2>&1 | sed s/\'/\"/g
   Switched to a new branch "branch2"
   $ echo gamma > gamma
   $ git add gamma
-  $ commit -m 'add gamma'
+  $ fn_git_commit -m 'add gamma'
 
   $ git checkout master 2>&1 | sed s/\'/\"/g
   Switched to branch "master"
   $ echo delta > delta
   $ git add delta
-  $ commit -m 'add delta'
+  $ fn_git_commit -m 'add delta'
 
   $ git merge branch1 branch2 | sed "s/the '//;s/' strategy//" | sed 's/^Merge.*octopus.*$/Merge successful/;s/, 0 deletions.*//'  | sed 's/|  */| /'
   Trying simple merge with branch1

File tests/test-outgoing.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-  $ hgcommit()
-  > {
-  >     HGDATE="2007-01-01 00:00:$count +0000"
-  >     hg commit -d "$HGDATE" "$@" >/dev/null 2>/dev/null || echo "hg commit error"
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init
 
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m "add alpha"
+  $ fn_git_commit -m "add alpha"
   $ git branch alpha
   $ git show-ref
   7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 refs/heads/alpha
   $ hg update -q master
   $ echo beta > beta
   $ hg add beta
-  $ hgcommit -m 'add beta'
+  $ fn_hg_commit -m 'add beta'
 
 
   $ echo gamma > gamma
   $ hg add gamma
-  $ hgcommit -m 'add gamma'
+  $ fn_hg_commit -m 'add gamma'
 
   $ hg book -r 1 beta
 
   Already on "master"
   $ echo delta > delta
   $ git add delta
-  $ commit -m "add delta"
+  $ fn_git_commit -m "add delta"
 
   $ cd ..
 

File tests/test-pull-after-strip.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init
   Initialized empty Git repository in $TESTTMP/gitrepo/.git/
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m 'add alpha'
+  $ fn_git_commit -m 'add alpha'
 
   $ git tag alpha
 
   Switched to a new branch "beta"
   $ echo beta > beta
   $ git add beta
-  $ commit -m 'add beta'
+  $ fn_git_commit -m 'add beta'
 
 
   $ cd ..
   $ cd gitrepo
   $ echo beta line 2 >> beta
   $ git add beta
-  $ commit -m 'add to beta'
+  $ fn_git_commit -m 'add to beta'
 
   $ cd ..
   $ cd hgrepo-b

File tests/test-pull.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-
 set up a git repo with some commits, branches and a tag
   $ git init -q gitrepo
   $ cd gitrepo
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m 'add alpha'
+  $ fn_git_commit -m 'add alpha'
   $ git tag t_alpha
   $ git checkout -qb beta
   $ echo beta > beta
   $ git add beta
-  $ commit -m 'add beta'
+  $ fn_git_commit -m 'add beta'
   $ cd ..
 
 clone a tag (ideally we'd want to pull it, but that seems broken for now)
   $ git checkout -q master
   $ echo gamma > gamma
   $ git add gamma
-  $ commit -m 'add gamma'
+  $ fn_git_commit -m 'add gamma'
   $ cd ..
 
 pull everything else

File tests/test-push.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-  $ hgcommit()
-  > {
-  >     HGDATE="2007-01-01 00:00:$count +0000"
-  >     hg commit -d "$HGDATE" "$@" >/dev/null 2>/dev/null || echo "hg commit error"
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init
 
   $ echo alpha > alpha
   $ git add alpha
-  $ commit -m "add alpha"
+  $ fn_git_commit -m "add alpha"
   $ git checkout -b not-master 2>&1 | sed s/\'/\"/g
   Switched to a new branch "not-master"
 
   $ cd hgrepo
   $ echo beta > beta
   $ hg add beta
-  $ hgcommit -m 'add beta'
+  $ fn_hg_commit -m 'add beta'
 
 
   $ echo gamma > gamma
   $ hg add gamma
-  $ hgcommit -m 'add gamma'
+  $ fn_hg_commit -m 'add gamma'
 
   $ hg book -r 1 beta
   $ hg push -r beta
   Switched to branch "master"
   $ echo delta > delta
   $ git add delta
-  $ commit -m "add delta"
+  $ fn_git_commit -m "add delta"
   $ git checkout not-master 2>&1 | sed s/\'/\"/g
   Switched to branch "not-master"
 

File tests/test-subrepos.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ gitcommit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-  $ hgcommit()
-  > {
-  >     HGDATE="2007-01-01 00:00:$count +0000"
-  >     hg commit -d "$HGDATE" "$@" >/dev/null 2>/dev/null || echo "hg commit error"
-  >     count=`expr $count + 1`
-  > }
-
-
   $ mkdir gitsubrepo
   $ cd gitsubrepo
   $ git init
   Initialized empty Git repository in $TESTTMP/gitsubrepo/.git/
   $ echo beta > beta
   $ git add beta
-  $ gitcommit -m 'add beta'
+  $ fn_git_commit -m 'add beta'
   $ cd ..
 
   $ mkdir gitrepo1
   Initialized empty Git repository in $TESTTMP/gitrepo1/.git/
   $ echo alpha > alpha
   $ git add alpha
-  $ gitcommit -m 'add alpha'
+  $ fn_git_commit -m 'add alpha'
   $ git submodule add ../gitsubrepo subrepo1
   Cloning into 'subrepo1'...
   done.
-  $ gitcommit -m 'add subrepo1'
+  $ fn_git_commit -m 'add subrepo1'
   $ git submodule add ../gitsubrepo xyz/subrepo2
   Cloning into 'xyz/subrepo2'...
   done.
-  $ gitcommit -m 'add subrepo2'
+  $ fn_git_commit -m 'add subrepo2'
 we are going to push to this repo from our hg clone,
 allow commits despite working copy presense
   $ git config receive.denyCurrentBranch ignore
   $ cd gitsubrepo
   $ echo gamma > gamma
   $ git add gamma
-  $ gitcommit -m 'add gamma'
+  $ fn_git_commit -m 'add gamma'
   $ cd ..
   $ cd hgrepo
   $ cd xyz/subrepo2
   $ cd hgsub
   $ echo delta > delta
   $ hg add delta
-  $ hgcommit -m "add delta"
+  $ fn_hg_commit -m "add delta"
   $ echo "`hg tip --template '{node}'` hgsub" > ../gitrepo1/.hgsubstate
   $ echo "hgsub = $(pwd)" > ../gitrepo1/.hgsub
   $ cd ../gitrepo1
   $ git add .hgsubstate .hgsub
-  $ gitcommit -m "Test3. Prepare .hgsub and .hgsubstate sources"
+  $ fn_git_commit -m "Test3. Prepare .hgsub and .hgsubstate sources"
   $ cd ../hgrepo
   $ hg pull
   pulling from $TESTTMP/gitrepo1

File tests/test-tree-decomposition.t

 bail if the user does not have dulwich
   $ python -c 'import dulwich, dulwich.repo' || exit 80
 
-  $ 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
-  $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
-  $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
-  $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
-
-  $ count=10
-  $ commit()
-  > {
-  >     GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
-  >     GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
-  >     git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
-  >     count=`expr $count + 1`
-  > }
-
   $ mkdir gitrepo
   $ cd gitrepo
   $ git init
   $ echo a > d1/f1
   $ echo b > d1/f2
   $ git add d1/f1 d1/f2
-  $ commit -m initial
+  $ fn_git_commit -m initial
 
   $ mkdir d2
   $ git mv d1/f2 d2/f2
-  $ commit -m 'rename'
+  $ fn_git_commit -m 'rename'
 
   $ rm -r d1
   $ echo c > d1
   $ git add d1
-  $ commit -m 'replace a dir with a file'
+  $ fn_git_commit -m 'replace a dir with a file'
 
 
   $ cd ..

File tests/testutil

 # Not needed in Mercurial 2.3+, as graphlog was integrated into core
 echo 'graphlog=' >> $HGRCPATH
 echo 'mq=' >> $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
+GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
+GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
+GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
+
+# Functions to commit and tag in Mercurial and Git in a predictable manner
+count=10
+
+fn_git_commit() {
+    GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
+    GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
+    git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
+    count=`expr $count + 1`
+}
+
+fn_hg_commit() {
+    HGDATE="2007-01-01 00:00:$count +0000"
+    hg commit -d "$HGDATE" "$@" >/dev/null 2>/dev/null || echo "hg commit error"
+    count=`expr $count + 1`
+}
+
+fn_git_tag() {
+    GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
+    GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
+    git tag "$@" >/dev/null 2>/dev/null || echo "git tag error"
+    count=`expr $count + 1`
+}
+
+fn_hg_tag() {
+    HGDATE="2007-01-01 00:00:$count +0000"
+    hg tag -d "$HGDATE" "$@" >/dev/null 2>/dev/null || echo "hg tag error"
+    count=`expr $count + 1`
+}