Mercurial > hg
annotate tests/test-import-bypass.t @ 21766:a039e1f2326f
cmdutil: better document command()
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 04 May 2014 18:45:04 -0700 |
parents | 308aaeb956e2 |
children | e116abad3afa |
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 | |
21417
308aaeb956e2
import: use "getcommiteditor()" instead of explicit editor choice
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20117
diff
changeset
|
25 (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
|
26 patch contains the commit message, regardless of '--edit') |
14611 | 27 |
21417
308aaeb956e2
import: use "getcommiteditor()" instead of explicit editor choice
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20117
diff
changeset
|
28 $ HGEDITOR=cat hg import --bypass --exact --edit ../test.diff |
14611 | 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 | |
21417
308aaeb956e2
import: use "getcommiteditor()" instead of explicit editor choice
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20117
diff
changeset
|
112 (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
|
113 the commit message, regardless of '--edit') |
14611 | 114 |
16124
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
115 $ cat > ../test.diff <<EOF |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
116 > 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
|
117 > --- 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
|
118 > +++ 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
|
119 > @@ -1,1 +1,2 @@ |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
120 > -a |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
121 > +b |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
122 > +c |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
123 > EOF |
14611 | 124 $ HGEDITOR=cat hg import --bypass ../test.diff |
125 applying ../test.diff | |
126 | |
127 | |
128 HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
129 HG: Leave message empty to abort commit. | |
130 HG: -- | |
131 HG: user: test | |
132 HG: branch 'default' | |
133 HG: changed a | |
134 abort: empty commit message | |
135 [255] | |
136 | |
137 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
|
138 (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
|
139 commit message is explicitly specified, regardless of '--edit') |
14611 | 140 |
141 $ python -c 'file("a", "wb").write("a\r\n")' | |
142 $ 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
|
143 $ HGEDITOR=cat hg import -m 'should fail because of eol' --edit --bypass ../test.diff |
14611 | 144 applying ../test.diff |
145 patching file a | |
146 Hunk #1 FAILED at 0 | |
147 abort: patch failed to apply | |
148 [255] | |
149 $ hg --config patch.eol=auto import -d '0 0' -m 'test patch.eol' --bypass ../test.diff | |
150 applying ../test.diff | |
151 $ shortlog | |
16124
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
152 o 3:c606edafba99 test 0 0 - default - test patch.eol |
14611 | 153 | |
154 @ 2:872023de769d test 0 0 - default - makeacrlf | |
155 | | |
156 | o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
157 |/ | |
158 o 0:07f494440405 test 0 0 - default - adda | |
159 | |
160 | |
161 Test applying multiple patches | |
162 | |
163 $ hg up -qC 0 | |
164 $ echo e > e | |
165 $ hg ci -Am adde | |
166 adding e | |
167 created new head | |
168 $ hg export . > ../patch1.diff | |
169 $ hg up -qC 1 | |
170 $ echo f > f | |
171 $ hg ci -Am addf | |
172 adding f | |
173 $ hg export . > ../patch2.diff | |
174 $ cd .. | |
175 $ hg clone -r1 repo-options repo-multi1 | |
176 adding changesets | |
177 adding manifests | |
178 adding file changes | |
179 added 2 changesets with 2 changes to 1 files | |
180 updating to branch foo | |
181 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
182 $ cd repo-multi1 | |
183 $ hg up 0 | |
184 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
185 $ hg import --bypass ../patch1.diff ../patch2.diff | |
186 applying ../patch1.diff | |
187 applying ../patch2.diff | |
188 $ shortlog | |
189 o 3:bc8ca3f8a7c4 test 0 0 - default - addf | |
190 | | |
191 o 2:16581080145e test 0 0 - default - adde | |
192 | | |
193 | o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
194 |/ | |
195 @ 0:07f494440405 test 0 0 - default - adda | |
196 | |
197 | |
198 Test applying multiple patches with --exact | |
199 | |
200 $ cd .. | |
201 $ hg clone -r1 repo-options repo-multi2 | |
202 adding changesets | |
203 adding manifests | |
204 adding file changes | |
205 added 2 changesets with 2 changes to 1 files | |
206 updating to branch foo | |
207 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
208 $ cd repo-multi2 | |
209 $ hg import --bypass --exact ../patch1.diff ../patch2.diff | |
210 applying ../patch1.diff | |
211 applying ../patch2.diff | |
212 $ shortlog | |
213 o 3:d60cb8989666 test 0 0 - foo - addf | |
214 | | |
215 | o 2:16581080145e test 0 0 - default - adde | |
216 | | | |
217 @ | 1:4e322f7ce8e3 test 0 0 - foo - changea | |
218 |/ | |
219 o 0:07f494440405 test 0 0 - default - adda | |
220 | |
221 | |
222 $ cd .. | |
223 | |
16899
8149ff405c78
tests: convert some 'hghave execbit' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16124
diff
changeset
|
224 #if symlink execbit |
8149ff405c78
tests: convert some 'hghave execbit' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16124
diff
changeset
|
225 |
14611 | 226 Test complicated patch with --exact |
227 | |
228 $ hg init repo-exact | |
229 $ cd repo-exact | |
230 $ echo a > a | |
231 $ echo c > c | |
232 $ echo d > d | |
233 $ echo e > e | |
234 $ echo f > f | |
235 $ chmod +x f | |
236 $ ln -s c linkc | |
237 $ hg ci -Am t | |
238 adding a | |
239 adding c | |
240 adding d | |
241 adding e | |
242 adding f | |
243 adding linkc | |
244 $ hg cp a aa1 | |
245 $ echo b >> a | |
246 $ echo b > b | |
247 $ hg add b | |
248 $ hg cp a aa2 | |
249 $ echo aa >> aa2 | |
250 $ chmod +x e | |
251 $ chmod -x f | |
252 $ ln -s a linka | |
253 $ hg rm d | |
254 $ hg rm linkc | |
255 $ hg mv c cc | |
256 $ hg ci -m patch | |
257 $ hg export --git . > ../test.diff | |
258 $ hg up -C null | |
259 0 files updated, 0 files merged, 7 files removed, 0 files unresolved | |
260 $ hg purge | |
261 $ hg st | |
262 $ hg import --bypass --exact ../test.diff | |
263 applying ../test.diff | |
264 | |
265 The patch should have matched the exported revision and generated no additional | |
266 data. If not, diff both heads to debug it. | |
267 | |
268 $ shortlog | |
269 o 1:2978fd5c8aa4 test 0 0 - default - patch | |
270 | | |
271 o 0:a0e19e636a43 test 0 0 - default - t | |
272 | |
16899
8149ff405c78
tests: convert some 'hghave execbit' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16124
diff
changeset
|
273 #endif |
16913
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
16899
diff
changeset
|
274 |
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
16899
diff
changeset
|
275 $ cd .. |