Mercurial > hg > hg-git
annotate tests/test-push @ 487:68e5dddc7a20
push: return 1 if no changes found, 0 if success
While working on some other tests, I noticed that the push command was returning
exit code 1 on success. This changeset makes hgrepo.push use the same return
code contract as localrepo.push, which makes the exit codes behave as expected.
author | David M. Carr <david@carrclan.us> |
---|---|
date | Wed, 05 Sep 2012 23:27:31 -0400 |
parents | 3f0f0c64f81c |
children |
rev | line source |
---|---|
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
1 #!/bin/sh |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
2 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
3 # Fails for some reason, need to investigate |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
4 # "$TESTDIR/hghave" git || exit 80 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
5 |
259
8b9fc1b1cc40
tests: Fix tests with new repo layout.
Augie Fackler <durin42@gmail.com>
parents:
244
diff
changeset
|
6 # bail if the user does not have dulwich |
8b9fc1b1cc40
tests: Fix tests with new repo layout.
Augie Fackler <durin42@gmail.com>
parents:
244
diff
changeset
|
7 python -c 'import dulwich, dulwich.repo' || exit 80 |
8b9fc1b1cc40
tests: Fix tests with new repo layout.
Augie Fackler <durin42@gmail.com>
parents:
244
diff
changeset
|
8 |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
9 # bail early if the user is already running git-daemon |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
10 echo hi | nc localhost 9418 2>/dev/null && exit 80 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
11 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
12 echo "[extensions]" >> $HGRCPATH |
259
8b9fc1b1cc40
tests: Fix tests with new repo layout.
Augie Fackler <durin42@gmail.com>
parents:
244
diff
changeset
|
13 echo "hggit=$(echo $(dirname $(dirname $0)))/hggit" >> $HGRCPATH |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
14 echo 'hgext.graphlog =' >> $HGRCPATH |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
15 echo 'hgext.bookmarks =' >> $HGRCPATH |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
16 |
294
29e342590c11
tests: many, many changes so we never push into a checked-out ref
Augie Fackler <durin42@gmail.com>
parents:
273
diff
changeset
|
17 |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
18 GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
19 GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
20 GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
21 GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
22 GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
23 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
24 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
25 count=10 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
26 commit() |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
27 { |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
28 GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000" |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
29 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" |
271
d32590df65ef
undo changes from ea0728d8cdc2 (GNU sed doesn't have a -E option)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
259
diff
changeset
|
30 git commit "$@" >/dev/null 2>/dev/null || echo "git commit error" |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
31 count=`expr $count + 1` |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
32 } |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
33 hgcommit() |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
34 { |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
35 HGDATE="2007-01-01 00:00:$count +0000" |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
36 hg commit -d "$HGDATE" "$@" >/dev/null 2>/dev/null || echo "hg commit error" |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
37 count=`expr $count + 1` |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
38 } |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
39 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
40 mkdir gitrepo |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
41 cd gitrepo |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
42 git init | python -c "import sys; print sys.stdin.read().replace('$(dirname $(pwd))/', '')" |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
43 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
44 echo alpha > alpha |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
45 git add alpha |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
46 commit -m "add alpha" |
294
29e342590c11
tests: many, many changes so we never push into a checked-out ref
Augie Fackler <durin42@gmail.com>
parents:
273
diff
changeset
|
47 git checkout -b not-master 2>&1 | sed s/\'/\"/g |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
48 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
49 # dulwich does not presently support local git repos, workaround |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
50 cd .. |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
51 git daemon --base-path="$(pwd)"\ |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
52 --listen=localhost\ |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
53 --export-all\ |
386
525ffe284b0c
tests: use run-tests.py's built-in daemon killing
Augie Fackler <durin42@gmail.com>
parents:
294
diff
changeset
|
54 --pid-file="$DAEMON_PIDS" \ |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
55 --detach --reuseaddr \ |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
56 --enable=receive-pack |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
57 |
273
e331d19fd0bf
accept both old and new hg output for clone
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
271
diff
changeset
|
58 hg clone git://localhost/gitrepo hgrepo | grep -v '^updating' |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
59 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
60 cd hgrepo |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
61 echo beta > beta |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
62 hg add beta |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
63 hgcommit -m 'add beta' |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
64 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
65 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
66 echo gamma > gamma |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
67 hg add gamma |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
68 hgcommit -m 'add gamma' |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
69 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
70 hg book -r 1 beta |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
71 hg push -r beta |
487
68e5dddc7a20
push: return 1 if no changes found, 0 if success
David M. Carr <david@carrclan.us>
parents:
390
diff
changeset
|
72 echo [$?] |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
73 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
74 cd .. |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
75 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
76 echo % should have two different branches |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
77 cd gitrepo |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
78 git branch -v |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
79 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
80 echo % some more work on master from git |
244
ea0728d8cdc2
tests: work around output changes in newer git versions
Augie Fackler <durin42@gmail.com>
parents:
230
diff
changeset
|
81 git checkout master 2>&1 | sed s/\'/\"/g |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
82 echo delta > delta |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
83 git add delta |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
84 commit -m "add delta" |
294
29e342590c11
tests: many, many changes so we never push into a checked-out ref
Augie Fackler <durin42@gmail.com>
parents:
273
diff
changeset
|
85 git checkout not-master 2>&1 | sed s/\'/\"/g |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
86 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
87 cd .. |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
88 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
89 cd hgrepo |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
90 echo % this should fail |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
91 hg push -r master |
487
68e5dddc7a20
push: return 1 if no changes found, 0 if success
David M. Carr <david@carrclan.us>
parents:
390
diff
changeset
|
92 echo [$?] |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
93 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
94 echo % ... even with -f |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
95 hg push -fr master |
487
68e5dddc7a20
push: return 1 if no changes found, 0 if success
David M. Carr <david@carrclan.us>
parents:
390
diff
changeset
|
96 echo [$?] |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
97 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
98 hg pull |
294
29e342590c11
tests: many, many changes so we never push into a checked-out ref
Augie Fackler <durin42@gmail.com>
parents:
273
diff
changeset
|
99 # TODO shouldn't need to do this since we're (in theory) pushing master explicitly, |
29e342590c11
tests: many, many changes so we never push into a checked-out ref
Augie Fackler <durin42@gmail.com>
parents:
273
diff
changeset
|
100 # which should not implicitly also push the not-master ref. |
29e342590c11
tests: many, many changes so we never push into a checked-out ref
Augie Fackler <durin42@gmail.com>
parents:
273
diff
changeset
|
101 hg book not-master -r default/not-master --force |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
102 echo % master and default/master should be diferent |
390
3f0f0c64f81c
tests: cope with output format changes in hg 1.8
Augie Fackler <durin42@gmail.com>
parents:
386
diff
changeset
|
103 hg log -r master | grep -v ': *master' |
3f0f0c64f81c
tests: cope with output format changes in hg 1.8
Augie Fackler <durin42@gmail.com>
parents:
386
diff
changeset
|
104 hg log -r default/master |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
105 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
106 echo % this should also fail |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
107 hg push -r master |
487
68e5dddc7a20
push: return 1 if no changes found, 0 if success
David M. Carr <david@carrclan.us>
parents:
390
diff
changeset
|
108 echo [$?] |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
109 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
110 echo % ... but succeed with -f |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
111 hg push -fr master |
487
68e5dddc7a20
push: return 1 if no changes found, 0 if success
David M. Carr <david@carrclan.us>
parents:
390
diff
changeset
|
112 echo [$?] |
68e5dddc7a20
push: return 1 if no changes found, 0 if success
David M. Carr <david@carrclan.us>
parents:
390
diff
changeset
|
113 |
68e5dddc7a20
push: return 1 if no changes found, 0 if success
David M. Carr <david@carrclan.us>
parents:
390
diff
changeset
|
114 echo % this should fail, no changes to push |
68e5dddc7a20
push: return 1 if no changes found, 0 if success
David M. Carr <david@carrclan.us>
parents:
390
diff
changeset
|
115 hg push -r master |
68e5dddc7a20
push: return 1 if no changes found, 0 if success
David M. Carr <david@carrclan.us>
parents:
390
diff
changeset
|
116 # This was broken in Mercurial (incorrectly returning 0) until issue3228 was |
68e5dddc7a20
push: return 1 if no changes found, 0 if success
David M. Carr <david@carrclan.us>
parents:
390
diff
changeset
|
117 # fixed in 2.1 |
68e5dddc7a20
push: return 1 if no changes found, 0 if success
David M. Carr <david@carrclan.us>
parents:
390
diff
changeset
|
118 echo [$?] | sed s/0/1/ |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
119 |
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
120 cd .. |