Mercurial > hg
annotate tests/test-import-bypass.t @ 24160:b9ae778d78a2 stable
Added tag 3.3.1 for changeset 5b4ed033390b
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 02 Mar 2015 01:06:27 -0600 |
parents | c63a09b6b337 |
children | 093e8a5e995f |
rev | line source |
---|---|
14611 | 1 $ echo "[extensions]" >> $HGRCPATH |
2 $ echo "purge=" >> $HGRCPATH | |
3 | |
4 $ shortlog() { | |
20117
aa9385f983fa
tests: don't load unnecessary graphlog extension
Martin Geisler <martin@geisler.net>
parents:
16913
diff
changeset
|
5 > hg log -G --template '{rev}:{node|short} {author} {date|hgdate} - {branch} - {desc|firstline}\n' |
14611 | 6 > } |
7 | |
8 Test --bypass with other options | |
9 | |
10 $ hg init repo-options | |
11 $ cd repo-options | |
12 $ echo a > a | |
13 $ hg ci -Am adda | |
14 adding a | |
15 $ echo a >> a | |
16 $ hg branch foo | |
17 marked working directory as branch foo | |
15615 | 18 (branches are permanent and global, did you want a bookmark?) |
14611 | 19 $ hg ci -Am changea |
20 $ hg export . > ../test.diff | |
21 $ hg up null | |
22 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
23 | |
24 Test importing an existing revision | |
22277
e116abad3afa
import: disallow meaningless combination of "--exact" and "--edit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21417
diff
changeset
|
25 (this also tests that "hg import" disallows combination of '--exact' |
e116abad3afa
import: disallow meaningless combination of "--exact" and "--edit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21417
diff
changeset
|
26 and '--edit') |
14611 | 27 |
22277
e116abad3afa
import: disallow meaningless combination of "--exact" and "--edit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21417
diff
changeset
|
28 $ hg import --bypass --exact --edit ../test.diff |
e116abad3afa
import: disallow meaningless combination of "--exact" and "--edit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21417
diff
changeset
|
29 abort: cannot use --exact with --edit |
e116abad3afa
import: disallow meaningless combination of "--exact" and "--edit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21417
diff
changeset
|
30 [255] |
e116abad3afa
import: disallow meaningless combination of "--exact" and "--edit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21417
diff
changeset
|
31 $ hg import --bypass --exact ../test.diff |
14611 | 32 applying ../test.diff |
33 $ shortlog | |
34 o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
35 | | |
36 o 0:07f494440405 test 0 0 - default - adda | |
37 | |
38 | |
39 Test failure without --exact | |
40 | |
41 $ hg import --bypass ../test.diff | |
42 applying ../test.diff | |
43 unable to find 'a' for patching | |
44 abort: patch failed to apply | |
45 [255] | |
46 $ hg st | |
47 $ shortlog | |
48 o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
49 | | |
50 o 0:07f494440405 test 0 0 - default - adda | |
51 | |
52 | |
53 Test --user, --date and --message | |
54 | |
55 $ hg up 0 | |
56 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
57 $ hg import --bypass --u test2 -d '1 0' -m patch2 ../test.diff | |
58 applying ../test.diff | |
59 $ cat .hg/last-message.txt | |
60 patch2 (no-eol) | |
61 $ shortlog | |
62 o 2:2e127d1da504 test2 1 0 - default - patch2 | |
63 | | |
64 | o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
65 |/ | |
66 @ 0:07f494440405 test 0 0 - default - adda | |
67 | |
15198
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
68 $ hg rollback |
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
69 repository tip rolled back to revision 1 (undo import) |
14611 | 70 |
71 Test --import-branch | |
22277
e116abad3afa
import: disallow meaningless combination of "--exact" and "--edit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21417
diff
changeset
|
72 (this also tests that editor is not invoked for '--bypass', if the |
e116abad3afa
import: disallow meaningless combination of "--exact" and "--edit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21417
diff
changeset
|
73 patch contains the commit message, regardless of '--edit') |
14611 | 74 |
22277
e116abad3afa
import: disallow meaningless combination of "--exact" and "--edit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21417
diff
changeset
|
75 $ HGEDITOR=cat hg import --bypass --import-branch --edit ../test.diff |
14611 | 76 applying ../test.diff |
77 $ shortlog | |
78 o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
79 | | |
80 @ 0:07f494440405 test 0 0 - default - adda | |
81 | |
15198
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
82 $ hg rollback |
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
83 repository tip rolled back to revision 1 (undo import) |
14611 | 84 |
85 Test --strip | |
86 | |
87 $ hg import --bypass --strip 0 - <<EOF | |
88 > # HG changeset patch | |
89 > # User test | |
90 > # Date 0 0 | |
91 > # Branch foo | |
92 > # Node ID 4e322f7ce8e3e4203950eac9ece27bf7e45ffa6c | |
93 > # Parent 07f4944404050f47db2e5c5071e0e84e7a27bba9 | |
94 > changea | |
95 > | |
96 > diff -r 07f494440405 -r 4e322f7ce8e3 a | |
97 > --- a Thu Jan 01 00:00:00 1970 +0000 | |
98 > +++ a Thu Jan 01 00:00:00 1970 +0000 | |
99 > @@ -1,1 +1,2 @@ | |
100 > a | |
101 > +a | |
102 > EOF | |
103 applying patch from stdin | |
15198
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
104 $ hg rollback |
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
105 repository tip rolled back to revision 1 (undo import) |
14611 | 106 |
107 Test unsupported combinations | |
108 | |
109 $ hg import --bypass --no-commit ../test.diff | |
110 abort: cannot use --no-commit with --bypass | |
111 [255] | |
112 $ hg import --bypass --similarity 50 ../test.diff | |
113 abort: cannot use --similarity with --bypass | |
114 [255] | |
115 | |
116 Test commit editor | |
21417
308aaeb956e2
import: use "getcommiteditor()" instead of explicit editor choice
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20117
diff
changeset
|
117 (this also tests that editor is invoked, if the patch doesn't contain |
308aaeb956e2
import: use "getcommiteditor()" instead of explicit editor choice
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20117
diff
changeset
|
118 the commit message, regardless of '--edit') |
14611 | 119 |
16124
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
120 $ cat > ../test.diff <<EOF |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
121 > diff -r 07f494440405 -r 4e322f7ce8e3 a |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
122 > --- a/a Thu Jan 01 00:00:00 1970 +0000 |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
123 > +++ b/a Thu Jan 01 00:00:00 1970 +0000 |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
124 > @@ -1,1 +1,2 @@ |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
125 > -a |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
126 > +b |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
127 > +c |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
128 > EOF |
14611 | 129 $ HGEDITOR=cat hg import --bypass ../test.diff |
130 applying ../test.diff | |
131 | |
132 | |
133 HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
134 HG: Leave message empty to abort commit. | |
135 HG: -- | |
136 HG: user: test | |
137 HG: branch 'default' | |
138 HG: changed a | |
139 abort: empty commit message | |
140 [255] | |
141 | |
142 Test patch.eol is handled | |
21417
308aaeb956e2
import: use "getcommiteditor()" instead of explicit editor choice
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20117
diff
changeset
|
143 (this also tests that editor is not invoked for '--bypass', if the |
308aaeb956e2
import: use "getcommiteditor()" instead of explicit editor choice
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20117
diff
changeset
|
144 commit message is explicitly specified, regardless of '--edit') |
14611 | 145 |
22947
c63a09b6b337
tests: use $PYTHON instead of hardcoding python
Augie Fackler <raf@durin42.com>
parents:
22278
diff
changeset
|
146 $ $PYTHON -c 'file("a", "wb").write("a\r\n")' |
14611 | 147 $ hg ci -m makeacrlf |
21417
308aaeb956e2
import: use "getcommiteditor()" instead of explicit editor choice
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20117
diff
changeset
|
148 $ HGEDITOR=cat hg import -m 'should fail because of eol' --edit --bypass ../test.diff |
14611 | 149 applying ../test.diff |
150 patching file a | |
151 Hunk #1 FAILED at 0 | |
152 abort: patch failed to apply | |
153 [255] | |
154 $ hg --config patch.eol=auto import -d '0 0' -m 'test patch.eol' --bypass ../test.diff | |
155 applying ../test.diff | |
156 $ shortlog | |
16124
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
157 o 3:c606edafba99 test 0 0 - default - test patch.eol |
14611 | 158 | |
159 @ 2:872023de769d test 0 0 - default - makeacrlf | |
160 | | |
161 | o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
162 |/ | |
163 o 0:07f494440405 test 0 0 - default - adda | |
164 | |
165 | |
166 Test applying multiple patches | |
167 | |
168 $ hg up -qC 0 | |
169 $ echo e > e | |
170 $ hg ci -Am adde | |
171 adding e | |
172 created new head | |
173 $ hg export . > ../patch1.diff | |
174 $ hg up -qC 1 | |
175 $ echo f > f | |
176 $ hg ci -Am addf | |
177 adding f | |
178 $ hg export . > ../patch2.diff | |
179 $ cd .. | |
180 $ hg clone -r1 repo-options repo-multi1 | |
181 adding changesets | |
182 adding manifests | |
183 adding file changes | |
184 added 2 changesets with 2 changes to 1 files | |
185 updating to branch foo | |
186 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
187 $ cd repo-multi1 | |
188 $ hg up 0 | |
189 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
190 $ hg import --bypass ../patch1.diff ../patch2.diff | |
191 applying ../patch1.diff | |
192 applying ../patch2.diff | |
193 $ shortlog | |
194 o 3:bc8ca3f8a7c4 test 0 0 - default - addf | |
195 | | |
196 o 2:16581080145e test 0 0 - default - adde | |
197 | | |
198 | o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
199 |/ | |
200 @ 0:07f494440405 test 0 0 - default - adda | |
201 | |
202 | |
203 Test applying multiple patches with --exact | |
204 | |
205 $ cd .. | |
206 $ hg clone -r1 repo-options repo-multi2 | |
207 adding changesets | |
208 adding manifests | |
209 adding file changes | |
210 added 2 changesets with 2 changes to 1 files | |
211 updating to branch foo | |
212 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
213 $ cd repo-multi2 | |
214 $ hg import --bypass --exact ../patch1.diff ../patch2.diff | |
215 applying ../patch1.diff | |
216 applying ../patch2.diff | |
217 $ shortlog | |
218 o 3:d60cb8989666 test 0 0 - foo - addf | |
219 | | |
220 | o 2:16581080145e test 0 0 - default - adde | |
221 | | | |
222 @ | 1:4e322f7ce8e3 test 0 0 - foo - changea | |
223 |/ | |
224 o 0:07f494440405 test 0 0 - default - adda | |
225 | |
226 | |
227 $ cd .. | |
228 | |
22278
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
229 Test avoiding editor invocation at applying the patch with --exact |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
230 even if commit message is empty |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
231 |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
232 $ cd repo-options |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
233 |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
234 $ echo a >> a |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
235 $ hg commit -m ' ' |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
236 $ hg tip -T "{node}\n" |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
237 1b77bc7d1db9f0e7f1716d515b630516ab386c89 |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
238 $ hg export -o ../empty-log.diff . |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
239 $ hg update -q -C ".^1" |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
240 $ hg --config extensions.strip= strip -q tip |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
241 $ HGEDITOR=cat hg import --exact --bypass ../empty-log.diff |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
242 applying ../empty-log.diff |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
243 $ hg tip -T "{node}\n" |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
244 1b77bc7d1db9f0e7f1716d515b630516ab386c89 |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
245 |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
246 $ cd .. |
ffaaa80fa724
import: avoid editor invocation when importing with "--exact" for exact-ness
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
22277
diff
changeset
|
247 |
16899
8149ff405c78
tests: convert some 'hghave execbit' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16124
diff
changeset
|
248 #if symlink execbit |
8149ff405c78
tests: convert some 'hghave execbit' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16124
diff
changeset
|
249 |
14611 | 250 Test complicated patch with --exact |
251 | |
252 $ hg init repo-exact | |
253 $ cd repo-exact | |
254 $ echo a > a | |
255 $ echo c > c | |
256 $ echo d > d | |
257 $ echo e > e | |
258 $ echo f > f | |
259 $ chmod +x f | |
260 $ ln -s c linkc | |
261 $ hg ci -Am t | |
262 adding a | |
263 adding c | |
264 adding d | |
265 adding e | |
266 adding f | |
267 adding linkc | |
268 $ hg cp a aa1 | |
269 $ echo b >> a | |
270 $ echo b > b | |
271 $ hg add b | |
272 $ hg cp a aa2 | |
273 $ echo aa >> aa2 | |
274 $ chmod +x e | |
275 $ chmod -x f | |
276 $ ln -s a linka | |
277 $ hg rm d | |
278 $ hg rm linkc | |
279 $ hg mv c cc | |
280 $ hg ci -m patch | |
281 $ hg export --git . > ../test.diff | |
282 $ hg up -C null | |
283 0 files updated, 0 files merged, 7 files removed, 0 files unresolved | |
284 $ hg purge | |
285 $ hg st | |
286 $ hg import --bypass --exact ../test.diff | |
287 applying ../test.diff | |
288 | |
289 The patch should have matched the exported revision and generated no additional | |
290 data. If not, diff both heads to debug it. | |
291 | |
292 $ shortlog | |
293 o 1:2978fd5c8aa4 test 0 0 - default - patch | |
294 | | |
295 o 0:a0e19e636a43 test 0 0 - default - t | |
296 | |
16899
8149ff405c78
tests: convert some 'hghave execbit' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16124
diff
changeset
|
297 #endif |
16913
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
16899
diff
changeset
|
298 |
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
16899
diff
changeset
|
299 $ cd .. |