Mercurial > hg-git
changeset 512:4473b3c1f2da
tests: unify test-push
author | David M. Carr <david@carrclan.us> |
---|---|
date | Mon, 10 Sep 2012 00:27:45 -0400 |
parents | 5f9267d9bf5d |
children | d298abb841ac |
files | tests/test-conflict-1.t tests/test-conflict-2.t tests/test-convergedmerge.t tests/test-empty-working-tree.t tests/test-file-removal.t tests/test-git-clone.t tests/test-git-submodules.t tests/test-git-tags.t tests/test-git-workflow.t tests/test-help.t tests/test-hg-author.t tests/test-hg-branch.t tests/test-hg-tags.t tests/test-incoming.t tests/test-keywords.t tests/test-merge.t tests/test-octopus.t tests/test-pull-after-strip.t tests/test-pull.t tests/test-push tests/test-push.out tests/test-push.t |
diffstat | 3 files changed, 169 insertions(+), 179 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test-push Mon Sep 10 00:27:44 2012 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ -#!/bin/sh - -# Fails for some reason, need to investigate -# "$TESTDIR/hghave" git || exit 80 - -# bail if the user does not have dulwich -python -c 'import dulwich, dulwich.repo' || exit 80 - -# bail early if the user is already running git-daemon -echo hi | nc localhost 9418 2>/dev/null && exit 80 - -echo "[extensions]" >> $HGRCPATH -echo "hggit=$(echo $(dirname $(dirname $0)))/hggit" >> $HGRCPATH -echo 'hgext.graphlog =' >> $HGRCPATH -echo 'hgext.bookmarks =' >> $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 - -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 | python -c "import sys; print sys.stdin.read().replace('$(dirname $(pwd))/', '')" - -echo alpha > alpha -git add alpha -commit -m "add alpha" -git checkout -b not-master 2>&1 | sed s/\'/\"/g - -# dulwich does not presently support local git repos, workaround -cd .. -git daemon --base-path="$(pwd)"\ - --listen=localhost\ - --export-all\ - --pid-file="$DAEMON_PIDS" \ - --detach --reuseaddr \ - --enable=receive-pack - -hg clone git://localhost/gitrepo hgrepo | grep -v '^updating' - -cd hgrepo -echo beta > beta -hg add beta -hgcommit -m 'add beta' - - -echo gamma > gamma -hg add gamma -hgcommit -m 'add gamma' - -hg book -r 1 beta -hg push -r beta -echo [$?] - -cd .. - -echo % should have two different branches -cd gitrepo -git branch -v - -echo % some more work on master from git -git checkout master 2>&1 | sed s/\'/\"/g -echo delta > delta -git add delta -commit -m "add delta" -git checkout not-master 2>&1 | sed s/\'/\"/g - -cd .. - -cd hgrepo -echo % this should fail -hg push -r master -echo [$?] - -echo % ... even with -f -hg push -fr master -echo [$?] - -hg pull -# TODO shouldn't need to do this since we're (in theory) pushing master explicitly, -# which should not implicitly also push the not-master ref. -hg book not-master -r default/not-master --force -echo % master and default/master should be diferent -hg log -r master | grep -v ': *master' -hg log -r default/master - -echo % this should also fail -hg push -r master -echo [$?] - -echo % ... but succeed with -f -hg push -fr master -echo [$?] - -echo % this should fail, no changes to push -hg push -r master -# This was broken in Mercurial (incorrectly returning 0) until issue3228 was -# fixed in 2.1 -echo [$?] | sed s/0/1/ - -cd ..
--- a/tests/test-push.out Mon Sep 10 00:27:44 2012 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -Initialized empty Git repository in gitrepo/.git/ - -Switched to a new branch "not-master" -importing git objects into hg -1 files updated, 0 files merged, 0 files removed, 0 files unresolved -pushing to git://localhost/gitrepo -exporting hg objects to git -creating and sending data - default::refs/heads/beta => GIT:cffa0e8d -[0] -% should have two different branches - beta cffa0e8 add beta - master 7eeab2e add alpha -* not-master 7eeab2e add alpha -% some more work on master from git -Switched to branch "master" -Switched to branch "not-master" -% this should fail -pushing to git://localhost/gitrepo -creating and sending data -abort: refs/heads/master changed on the server, please pull and merge before pushing -[255] -% ... even with -f -pushing to git://localhost/gitrepo -creating and sending data -abort: refs/heads/master changed on the server, please pull and merge before pushing -[255] -pulling from git://localhost/gitrepo -importing git objects into hg -(run 'hg update' to get a working copy) -% master and default/master should be diferent -changeset: 2:72f56395749d -user: test -date: Mon Jan 01 00:00:12 2007 +0000 -summary: add gamma - -changeset: 3:1436150b86c2 -tag: default/master -tag: tip -parent: 0:3442585be8a6 -user: test <test@example.org> -date: Mon Jan 01 00:00:13 2007 +0000 -summary: add delta - -% this should also fail -pushing to git://localhost/gitrepo -creating and sending data -abort: pushing refs/heads/master overwrites 72f56395749d -[255] -% ... but succeed with -f -pushing to git://localhost/gitrepo -creating and sending data - default::refs/heads/master => GIT:cc119202 -[0] -% this should fail, no changes to push -pushing to git://localhost/gitrepo -creating and sending data -no changes found -[1]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-push.t Mon Sep 10 00:27:45 2012 -0400 @@ -0,0 +1,169 @@ +# Fails for some reason, need to investigate +# $ "$TESTDIR/hghave" git || exit 80 + +bail if the user does not have dulwich + $ python -c 'import dulwich, dulwich.repo' || exit 80 + +bail early if the user is already running git-daemon + $ ! (echo hi | nc localhost 9418 2>/dev/null) || exit 80 + + $ echo "[extensions]" >> $HGRCPATH + $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH + $ echo 'hgext.graphlog =' >> $HGRCPATH + $ echo 'hgext.bookmarks =' >> $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 + + $ 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 | python -c "import sys; print sys.stdin.read().replace('$(dirname $(pwd))/', '')" + Initialized empty Git repository in gitrepo/.git/ + + + $ echo alpha > alpha + $ git add alpha + $ commit -m "add alpha" + $ git checkout -b not-master 2>&1 | sed s/\'/\"/g + Switched to a new branch "not-master" + +dulwich does not presently support local git repos, workaround + $ cd .. + $ git daemon --base-path="$(pwd)"\ + > --listen=localhost\ + > --export-all\ + > --pid-file="$DAEMON_PIDS" \ + > --detach --reuseaddr \ + > --enable=receive-pack + + $ hg clone git://localhost/gitrepo hgrepo | grep -v '^updating' + importing git objects into hg + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + + $ cd hgrepo + $ echo beta > beta + $ hg add beta + $ hgcommit -m 'add beta' + + + $ echo gamma > gamma + $ hg add gamma + $ hgcommit -m 'add gamma' + + $ hg book -r 1 beta + $ hg push -r beta + pushing to git://localhost/gitrepo + exporting hg objects to git + creating and sending data + default::refs/heads/beta => GIT:cffa0e8d + + $ cd .. + + $ echo % should have two different branches + % should have two different branches + $ cd gitrepo + $ git branch -v + beta cffa0e8 add beta + master 7eeab2e add alpha + * not-master 7eeab2e add alpha + + $ echo % some more work on master from git + % some more work on master from git + $ git checkout master 2>&1 | sed s/\'/\"/g + Switched to branch "master" + $ echo delta > delta + $ git add delta + $ commit -m "add delta" + $ git checkout not-master 2>&1 | sed s/\'/\"/g + Switched to branch "not-master" + + $ cd .. + + $ cd hgrepo + $ echo % this should fail + % this should fail + $ hg push -r master + pushing to git://localhost/gitrepo + creating and sending data + abort: refs/heads/master changed on the server, please pull and merge before pushing + [255] + + $ echo % ... even with -f + % ... even with -f + $ hg push -fr master + pushing to git://localhost/gitrepo + creating and sending data + abort: refs/heads/master changed on the server, please pull and merge before pushing + [255] + + $ hg pull + pulling from git://localhost/gitrepo + importing git objects into hg + (run 'hg update' to get a working copy) +TODO shouldn't need to do this since we're (in theory) pushing master explicitly, +which should not implicitly also push the not-master ref. + $ hg book not-master -r default/not-master --force + $ echo % master and default/master should be diferent + % master and default/master should be diferent + $ hg log -r master | grep -v ': *master' + changeset: 2:72f56395749d + user: test + date: Mon Jan 01 00:00:12 2007 +0000 + summary: add gamma + + $ hg log -r default/master + changeset: 3:1436150b86c2 + tag: default/master + tag: tip + parent: 0:3442585be8a6 + user: test <test@example.org> + date: Mon Jan 01 00:00:13 2007 +0000 + summary: add delta + + + $ echo % this should also fail + % this should also fail + $ hg push -r master + pushing to git://localhost/gitrepo + creating and sending data + abort: pushing refs/heads/master overwrites 72f56395749d + [255] + + $ echo % ... but succeed with -f + % ... but succeed with -f + $ hg push -fr master + pushing to git://localhost/gitrepo + creating and sending data + default::refs/heads/master => GIT:cc119202 + + $ echo % this should fail, no changes to push + % this should fail, no changes to push +The exit code for this was broken in Mercurial (incorrectly returning 0) until +issue3228 was fixed in 2.1 + $ hg push -r master && false + pushing to git://localhost/gitrepo + creating and sending data + no changes found + [1] + + $ cd ..