Mercurial > hg > hg-git
annotate tests/test-push.t @ 512:4473b3c1f2da
tests: unify test-push
author | David M. Carr <david@carrclan.us> |
---|---|
date | Mon, 10 Sep 2012 00:27:45 -0400 |
parents | tests/test-push@68e5dddc7a20 |
children | bc7b18c2e5ef |
rev | line source |
---|---|
512 | 1 # Fails for some reason, need to investigate |
2 # $ "$TESTDIR/hghave" git || exit 80 | |
3 | |
4 bail if the user does not have dulwich | |
5 $ python -c 'import dulwich, dulwich.repo' || exit 80 | |
6 | |
7 bail early if the user is already running git-daemon | |
8 $ ! (echo hi | nc localhost 9418 2>/dev/null) || exit 80 | |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
9 |
512 | 10 $ echo "[extensions]" >> $HGRCPATH |
11 $ echo "hggit=$(echo $(dirname $TESTDIR))/hggit" >> $HGRCPATH | |
12 $ echo 'hgext.graphlog =' >> $HGRCPATH | |
13 $ echo 'hgext.bookmarks =' >> $HGRCPATH | |
14 | |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
15 |
512 | 16 $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME |
17 $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL | |
18 $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE | |
19 $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME | |
20 $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL | |
21 $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE | |
259
8b9fc1b1cc40
tests: Fix tests with new repo layout.
Augie Fackler <durin42@gmail.com>
parents:
244
diff
changeset
|
22 |
512 | 23 $ count=10 |
24 $ commit() | |
25 > { | |
26 > GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000" | |
27 > GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" | |
28 > git commit "$@" >/dev/null 2>/dev/null || echo "git commit error" | |
29 > count=`expr $count + 1` | |
30 > } | |
31 $ hgcommit() | |
32 > { | |
33 > HGDATE="2007-01-01 00:00:$count +0000" | |
34 > hg commit -d "$HGDATE" "$@" >/dev/null 2>/dev/null || echo "hg commit error" | |
35 > count=`expr $count + 1` | |
36 > } | |
37 | |
38 $ mkdir gitrepo | |
39 $ cd gitrepo | |
40 $ git init | python -c "import sys; print sys.stdin.read().replace('$(dirname $(pwd))/', '')" | |
41 Initialized empty Git repository in gitrepo/.git/ | |
42 | |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
43 |
512 | 44 $ echo alpha > alpha |
45 $ git add alpha | |
46 $ commit -m "add alpha" | |
47 $ git checkout -b not-master 2>&1 | sed s/\'/\"/g | |
48 Switched to a new branch "not-master" | |
49 | |
50 dulwich does not presently support local git repos, workaround | |
51 $ cd .. | |
52 $ git daemon --base-path="$(pwd)"\ | |
53 > --listen=localhost\ | |
54 > --export-all\ | |
55 > --pid-file="$DAEMON_PIDS" \ | |
56 > --detach --reuseaddr \ | |
57 > --enable=receive-pack | |
58 | |
59 $ hg clone git://localhost/gitrepo hgrepo | grep -v '^updating' | |
60 importing git objects into hg | |
61 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
62 | |
63 $ cd hgrepo | |
64 $ echo beta > beta | |
65 $ hg add beta | |
66 $ hgcommit -m 'add beta' | |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
67 |
294
29e342590c11
tests: many, many changes so we never push into a checked-out ref
Augie Fackler <durin42@gmail.com>
parents:
273
diff
changeset
|
68 |
512 | 69 $ echo gamma > gamma |
70 $ hg add gamma | |
71 $ hgcommit -m 'add gamma' | |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
72 |
512 | 73 $ hg book -r 1 beta |
74 $ hg push -r beta | |
75 pushing to git://localhost/gitrepo | |
76 exporting hg objects to git | |
77 creating and sending data | |
78 default::refs/heads/beta => GIT:cffa0e8d | |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
79 |
512 | 80 $ cd .. |
81 | |
82 $ echo % should have two different branches | |
83 % should have two different branches | |
84 $ cd gitrepo | |
85 $ git branch -v | |
86 beta cffa0e8 add beta | |
87 master 7eeab2e add alpha | |
88 * not-master 7eeab2e add alpha | |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
89 |
512 | 90 $ echo % some more work on master from git |
91 % some more work on master from git | |
92 $ git checkout master 2>&1 | sed s/\'/\"/g | |
93 Switched to branch "master" | |
94 $ echo delta > delta | |
95 $ git add delta | |
96 $ commit -m "add delta" | |
97 $ git checkout not-master 2>&1 | sed s/\'/\"/g | |
98 Switched to branch "not-master" | |
99 | |
100 $ cd .. | |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
101 |
512 | 102 $ cd hgrepo |
103 $ echo % this should fail | |
104 % this should fail | |
105 $ hg push -r master | |
106 pushing to git://localhost/gitrepo | |
107 creating and sending data | |
108 abort: refs/heads/master changed on the server, please pull and merge before pushing | |
109 [255] | |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
110 |
512 | 111 $ echo % ... even with -f |
112 % ... even with -f | |
113 $ hg push -fr master | |
114 pushing to git://localhost/gitrepo | |
115 creating and sending data | |
116 abort: refs/heads/master changed on the server, please pull and merge before pushing | |
117 [255] | |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
118 |
512 | 119 $ hg pull |
120 pulling from git://localhost/gitrepo | |
121 importing git objects into hg | |
122 (run 'hg update' to get a working copy) | |
123 TODO shouldn't need to do this since we're (in theory) pushing master explicitly, | |
124 which should not implicitly also push the not-master ref. | |
125 $ hg book not-master -r default/not-master --force | |
126 $ echo % master and default/master should be diferent | |
127 % master and default/master should be diferent | |
128 $ hg log -r master | grep -v ': *master' | |
129 changeset: 2:72f56395749d | |
130 user: test | |
131 date: Mon Jan 01 00:00:12 2007 +0000 | |
132 summary: add gamma | |
133 | |
134 $ hg log -r default/master | |
135 changeset: 3:1436150b86c2 | |
136 tag: default/master | |
137 tag: tip | |
138 parent: 0:3442585be8a6 | |
139 user: test <test@example.org> | |
140 date: Mon Jan 01 00:00:13 2007 +0000 | |
141 summary: add delta | |
142 | |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
143 |
512 | 144 $ echo % this should also fail |
145 % this should also fail | |
146 $ hg push -r master | |
147 pushing to git://localhost/gitrepo | |
148 creating and sending data | |
149 abort: pushing refs/heads/master overwrites 72f56395749d | |
150 [255] | |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
151 |
512 | 152 $ echo % ... but succeed with -f |
153 % ... but succeed with -f | |
154 $ hg push -fr master | |
155 pushing to git://localhost/gitrepo | |
156 creating and sending data | |
157 default::refs/heads/master => GIT:cc119202 | |
487
68e5dddc7a20
push: return 1 if no changes found, 0 if success
David M. Carr <david@carrclan.us>
parents:
390
diff
changeset
|
158 |
512 | 159 $ echo % this should fail, no changes to push |
160 % this should fail, no changes to push | |
161 The exit code for this was broken in Mercurial (incorrectly returning 0) until | |
162 issue3228 was fixed in 2.1 | |
163 $ hg push -r master && false | |
164 pushing to git://localhost/gitrepo | |
165 creating and sending data | |
166 no changes found | |
167 [1] | |
230
51e4d6ebbc40
rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
diff
changeset
|
168 |
512 | 169 $ cd .. |