author | Mads Kiilerich <mads@kiilerich.com> |
Mon, 07 Nov 2011 03:14:54 +0100 | |
changeset 15441 | e0348815e806 |
parent 15198 | 62dc0e7ab092 |
child 15442 | db0340f4b507 |
permissions | -rw-r--r-- |
15441
e0348815e806
tests: use 'hghave symlink' for tests using symlinks
Mads Kiilerich <mads@kiilerich.com>
parents:
15198
diff
changeset
|
1 |
$ "$TESTDIR/hghave" symlink || exit 80 |
e0348815e806
tests: use 'hghave symlink' for tests using symlinks
Mads Kiilerich <mads@kiilerich.com>
parents:
15198
diff
changeset
|
2 |
|
14611 | 3 |
$ echo "[extensions]" >> $HGRCPATH |
4 |
$ echo "purge=" >> $HGRCPATH |
|
5 |
$ echo "graphlog=" >> $HGRCPATH |
|
6 |
||
7 |
$ shortlog() { |
|
8 |
> hg glog --template '{rev}:{node|short} {author} {date|hgdate} - {branch} - {desc|firstline}\n' |
|
9 |
> } |
|
10 |
||
11 |
Test --bypass with other options |
|
12 |
||
13 |
$ hg init repo-options |
|
14 |
$ cd repo-options |
|
15 |
$ echo a > a |
|
16 |
$ hg ci -Am adda |
|
17 |
adding a |
|
18 |
$ echo a >> a |
|
19 |
$ hg branch foo |
|
20 |
marked working directory as branch foo |
|
21 |
$ hg ci -Am changea |
|
22 |
$ hg export . > ../test.diff |
|
23 |
$ hg up null |
|
24 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
25 |
||
26 |
Test importing an existing revision |
|
27 |
||
28 |
$ hg import --bypass --exact ../test.diff |
|
29 |
applying ../test.diff |
|
30 |
$ shortlog |
|
31 |
o 1:4e322f7ce8e3 test 0 0 - foo - changea |
|
32 |
| |
|
33 |
o 0:07f494440405 test 0 0 - default - adda |
|
34 |
||
35 |
||
36 |
Test failure without --exact |
|
37 |
||
38 |
$ hg import --bypass ../test.diff |
|
39 |
applying ../test.diff |
|
40 |
unable to find 'a' for patching |
|
41 |
abort: patch failed to apply |
|
42 |
[255] |
|
43 |
$ hg st |
|
44 |
$ shortlog |
|
45 |
o 1:4e322f7ce8e3 test 0 0 - foo - changea |
|
46 |
| |
|
47 |
o 0:07f494440405 test 0 0 - default - adda |
|
48 |
||
49 |
||
50 |
Test --user, --date and --message |
|
51 |
||
52 |
$ hg up 0 |
|
53 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
54 |
$ hg import --bypass --u test2 -d '1 0' -m patch2 ../test.diff |
|
55 |
applying ../test.diff |
|
56 |
$ cat .hg/last-message.txt |
|
57 |
patch2 (no-eol) |
|
58 |
$ shortlog |
|
59 |
o 2:2e127d1da504 test2 1 0 - default - patch2 |
|
60 |
| |
|
61 |
| o 1:4e322f7ce8e3 test 0 0 - foo - changea |
|
62 |
|/ |
|
63 |
@ 0:07f494440405 test 0 0 - default - adda |
|
64 |
||
15198
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
65 |
$ hg rollback |
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
66 |
repository tip rolled back to revision 1 (undo import) |
14611 | 67 |
|
68 |
Test --import-branch |
|
69 |
||
70 |
$ hg import --bypass --import-branch ../test.diff |
|
71 |
applying ../test.diff |
|
72 |
$ shortlog |
|
73 |
o 1:4e322f7ce8e3 test 0 0 - foo - changea |
|
74 |
| |
|
75 |
@ 0:07f494440405 test 0 0 - default - adda |
|
76 |
||
15198
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
77 |
$ hg rollback |
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
78 |
repository tip rolled back to revision 1 (undo import) |
14611 | 79 |
|
80 |
Test --strip |
|
81 |
||
82 |
$ hg import --bypass --strip 0 - <<EOF |
|
83 |
> # HG changeset patch |
|
84 |
> # User test |
|
85 |
> # Date 0 0 |
|
86 |
> # Branch foo |
|
87 |
> # Node ID 4e322f7ce8e3e4203950eac9ece27bf7e45ffa6c |
|
88 |
> # Parent 07f4944404050f47db2e5c5071e0e84e7a27bba9 |
|
89 |
> changea |
|
90 |
> |
|
91 |
> diff -r 07f494440405 -r 4e322f7ce8e3 a |
|
92 |
> --- a Thu Jan 01 00:00:00 1970 +0000 |
|
93 |
> +++ a Thu Jan 01 00:00:00 1970 +0000 |
|
94 |
> @@ -1,1 +1,2 @@ |
|
95 |
> a |
|
96 |
> +a |
|
97 |
> EOF |
|
98 |
applying patch from stdin |
|
15198
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
99 |
$ hg rollback |
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
100 |
repository tip rolled back to revision 1 (undo import) |
14611 | 101 |
|
102 |
Test unsupported combinations |
|
103 |
||
104 |
$ hg import --bypass --no-commit ../test.diff |
|
105 |
abort: cannot use --no-commit with --bypass |
|
106 |
[255] |
|
107 |
$ hg import --bypass --similarity 50 ../test.diff |
|
108 |
abort: cannot use --similarity with --bypass |
|
109 |
[255] |
|
110 |
||
111 |
Test commit editor |
|
112 |
||
113 |
$ hg diff -c 1 > ../test.diff |
|
114 |
$ HGEDITOR=cat hg import --bypass ../test.diff |
|
115 |
applying ../test.diff |
|
116 |
||
117 |
||
118 |
HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
119 |
HG: Leave message empty to abort commit. |
|
120 |
HG: -- |
|
121 |
HG: user: test |
|
122 |
HG: branch 'default' |
|
123 |
HG: changed a |
|
124 |
abort: empty commit message |
|
125 |
[255] |
|
126 |
||
127 |
Test patch.eol is handled |
|
128 |
||
129 |
$ python -c 'file("a", "wb").write("a\r\n")' |
|
130 |
$ hg ci -m makeacrlf |
|
131 |
$ hg import -m 'should fail because of eol' --bypass ../test.diff |
|
132 |
applying ../test.diff |
|
133 |
patching file a |
|
134 |
Hunk #1 FAILED at 0 |
|
135 |
abort: patch failed to apply |
|
136 |
[255] |
|
137 |
$ hg --config patch.eol=auto import -d '0 0' -m 'test patch.eol' --bypass ../test.diff |
|
138 |
applying ../test.diff |
|
139 |
$ shortlog |
|
140 |
o 3:d7805b4d2cb3 test 0 0 - default - test patch.eol |
|
141 |
| |
|
142 |
@ 2:872023de769d test 0 0 - default - makeacrlf |
|
143 |
| |
|
144 |
| o 1:4e322f7ce8e3 test 0 0 - foo - changea |
|
145 |
|/ |
|
146 |
o 0:07f494440405 test 0 0 - default - adda |
|
147 |
||
148 |
||
149 |
Test applying multiple patches |
|
150 |
||
151 |
$ hg up -qC 0 |
|
152 |
$ echo e > e |
|
153 |
$ hg ci -Am adde |
|
154 |
adding e |
|
155 |
created new head |
|
156 |
$ hg export . > ../patch1.diff |
|
157 |
$ hg up -qC 1 |
|
158 |
$ echo f > f |
|
159 |
$ hg ci -Am addf |
|
160 |
adding f |
|
161 |
$ hg export . > ../patch2.diff |
|
162 |
$ cd .. |
|
163 |
$ hg clone -r1 repo-options repo-multi1 |
|
164 |
adding changesets |
|
165 |
adding manifests |
|
166 |
adding file changes |
|
167 |
added 2 changesets with 2 changes to 1 files |
|
168 |
updating to branch foo |
|
169 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
170 |
$ cd repo-multi1 |
|
171 |
$ hg up 0 |
|
172 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
173 |
$ hg import --bypass ../patch1.diff ../patch2.diff |
|
174 |
applying ../patch1.diff |
|
175 |
applying ../patch2.diff |
|
176 |
$ shortlog |
|
177 |
o 3:bc8ca3f8a7c4 test 0 0 - default - addf |
|
178 |
| |
|
179 |
o 2:16581080145e test 0 0 - default - adde |
|
180 |
| |
|
181 |
| o 1:4e322f7ce8e3 test 0 0 - foo - changea |
|
182 |
|/ |
|
183 |
@ 0:07f494440405 test 0 0 - default - adda |
|
184 |
||
185 |
||
186 |
Test applying multiple patches with --exact |
|
187 |
||
188 |
$ cd .. |
|
189 |
$ hg clone -r1 repo-options repo-multi2 |
|
190 |
adding changesets |
|
191 |
adding manifests |
|
192 |
adding file changes |
|
193 |
added 2 changesets with 2 changes to 1 files |
|
194 |
updating to branch foo |
|
195 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
196 |
$ cd repo-multi2 |
|
197 |
$ hg import --bypass --exact ../patch1.diff ../patch2.diff |
|
198 |
applying ../patch1.diff |
|
199 |
applying ../patch2.diff |
|
200 |
$ shortlog |
|
201 |
o 3:d60cb8989666 test 0 0 - foo - addf |
|
202 |
| |
|
203 |
| o 2:16581080145e test 0 0 - default - adde |
|
204 |
| | |
|
205 |
@ | 1:4e322f7ce8e3 test 0 0 - foo - changea |
|
206 |
|/ |
|
207 |
o 0:07f494440405 test 0 0 - default - adda |
|
208 |
||
209 |
||
210 |
$ cd .. |
|
211 |
||
212 |
Test complicated patch with --exact |
|
213 |
||
214 |
$ hg init repo-exact |
|
215 |
$ cd repo-exact |
|
216 |
$ echo a > a |
|
217 |
$ echo c > c |
|
218 |
$ echo d > d |
|
219 |
$ echo e > e |
|
220 |
$ echo f > f |
|
221 |
$ chmod +x f |
|
222 |
$ ln -s c linkc |
|
223 |
$ hg ci -Am t |
|
224 |
adding a |
|
225 |
adding c |
|
226 |
adding d |
|
227 |
adding e |
|
228 |
adding f |
|
229 |
adding linkc |
|
230 |
$ hg cp a aa1 |
|
231 |
$ echo b >> a |
|
232 |
$ echo b > b |
|
233 |
$ hg add b |
|
234 |
$ hg cp a aa2 |
|
235 |
$ echo aa >> aa2 |
|
236 |
$ chmod +x e |
|
237 |
$ chmod -x f |
|
238 |
$ ln -s a linka |
|
239 |
$ hg rm d |
|
240 |
$ hg rm linkc |
|
241 |
$ hg mv c cc |
|
242 |
$ hg ci -m patch |
|
243 |
$ hg export --git . > ../test.diff |
|
244 |
$ hg up -C null |
|
245 |
0 files updated, 0 files merged, 7 files removed, 0 files unresolved |
|
246 |
$ hg purge |
|
247 |
$ hg st |
|
248 |
$ hg import --bypass --exact ../test.diff |
|
249 |
applying ../test.diff |
|
250 |
||
251 |
The patch should have matched the exported revision and generated no additional |
|
252 |
data. If not, diff both heads to debug it. |
|
253 |
||
254 |
$ shortlog |
|
255 |
o 1:2978fd5c8aa4 test 0 0 - default - patch |
|
256 |
| |
|
257 |
o 0:a0e19e636a43 test 0 0 - default - t |
|
258 |