Mercurial > hg
annotate tests/test-import-bypass.t @ 20954:dba91f8060eb
bundle2: add an exchange.getbundle function
This function can return a `HG10` or `HG20` bundle. It uses the `bundlecaps`
parameters to decides which one to return.
This is a distinct function from `changegroup.getbundle` for two reasons. First
the APIs of `bundle10` and `bundle20` are not compatible yet. The two functions
may be reunited in the future. Second `exchange.getbundle` will grow parameters
for all kinds of data (phases, obsmarkers, ...) so it's better to keep the
changegroup generation in its own function for now.
This function will be used it in the next changesets.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 04 Apr 2014 01:51:54 -0700 |
parents | aa9385f983fa |
children | 308aaeb956e2 |
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 | |
25 | |
26 $ hg import --bypass --exact ../test.diff | |
27 applying ../test.diff | |
28 $ shortlog | |
29 o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
30 | | |
31 o 0:07f494440405 test 0 0 - default - adda | |
32 | |
33 | |
34 Test failure without --exact | |
35 | |
36 $ hg import --bypass ../test.diff | |
37 applying ../test.diff | |
38 unable to find 'a' for patching | |
39 abort: patch failed to apply | |
40 [255] | |
41 $ hg st | |
42 $ shortlog | |
43 o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
44 | | |
45 o 0:07f494440405 test 0 0 - default - adda | |
46 | |
47 | |
48 Test --user, --date and --message | |
49 | |
50 $ hg up 0 | |
51 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
52 $ hg import --bypass --u test2 -d '1 0' -m patch2 ../test.diff | |
53 applying ../test.diff | |
54 $ cat .hg/last-message.txt | |
55 patch2 (no-eol) | |
56 $ shortlog | |
57 o 2:2e127d1da504 test2 1 0 - default - patch2 | |
58 | | |
59 | o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
60 |/ | |
61 @ 0:07f494440405 test 0 0 - default - adda | |
62 | |
15198
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
63 $ hg rollback |
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
64 repository tip rolled back to revision 1 (undo import) |
14611 | 65 |
66 Test --import-branch | |
67 | |
68 $ hg import --bypass --import-branch ../test.diff | |
69 applying ../test.diff | |
70 $ shortlog | |
71 o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
72 | | |
73 @ 0:07f494440405 test 0 0 - default - adda | |
74 | |
15198
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
75 $ hg rollback |
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
76 repository tip rolled back to revision 1 (undo import) |
14611 | 77 |
78 Test --strip | |
79 | |
80 $ hg import --bypass --strip 0 - <<EOF | |
81 > # HG changeset patch | |
82 > # User test | |
83 > # Date 0 0 | |
84 > # Branch foo | |
85 > # Node ID 4e322f7ce8e3e4203950eac9ece27bf7e45ffa6c | |
86 > # Parent 07f4944404050f47db2e5c5071e0e84e7a27bba9 | |
87 > changea | |
88 > | |
89 > diff -r 07f494440405 -r 4e322f7ce8e3 a | |
90 > --- a Thu Jan 01 00:00:00 1970 +0000 | |
91 > +++ a Thu Jan 01 00:00:00 1970 +0000 | |
92 > @@ -1,1 +1,2 @@ | |
93 > a | |
94 > +a | |
95 > EOF | |
96 applying patch from stdin | |
15198
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
97 $ hg rollback |
62dc0e7ab092
import: wrap a transaction around the whole command
Greg Ward <greg@gerg.ca>
parents:
15194
diff
changeset
|
98 repository tip rolled back to revision 1 (undo import) |
14611 | 99 |
100 Test unsupported combinations | |
101 | |
102 $ hg import --bypass --no-commit ../test.diff | |
103 abort: cannot use --no-commit with --bypass | |
104 [255] | |
105 $ hg import --bypass --similarity 50 ../test.diff | |
106 abort: cannot use --similarity with --bypass | |
107 [255] | |
108 | |
109 Test commit editor | |
110 | |
16124
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
111 $ cat > ../test.diff <<EOF |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
112 > 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
|
113 > --- 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
|
114 > +++ 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
|
115 > @@ -1,1 +1,2 @@ |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
116 > -a |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
117 > +b |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
118 > +c |
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
119 > EOF |
14611 | 120 $ HGEDITOR=cat hg import --bypass ../test.diff |
121 applying ../test.diff | |
122 | |
123 | |
124 HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
125 HG: Leave message empty to abort commit. | |
126 HG: -- | |
127 HG: user: test | |
128 HG: branch 'default' | |
129 HG: changed a | |
130 abort: empty commit message | |
131 [255] | |
132 | |
133 Test patch.eol is handled | |
134 | |
135 $ python -c 'file("a", "wb").write("a\r\n")' | |
136 $ hg ci -m makeacrlf | |
137 $ hg import -m 'should fail because of eol' --bypass ../test.diff | |
138 applying ../test.diff | |
139 patching file a | |
140 Hunk #1 FAILED at 0 | |
141 abort: patch failed to apply | |
142 [255] | |
143 $ hg --config patch.eol=auto import -d '0 0' -m 'test patch.eol' --bypass ../test.diff | |
144 applying ../test.diff | |
145 $ shortlog | |
16124
0e0060bf2f44
patch: fuzz more aggressively to match patch(1) behaviour
Patrick Mezard <patrick@mezard.eu>
parents:
15623
diff
changeset
|
146 o 3:c606edafba99 test 0 0 - default - test patch.eol |
14611 | 147 | |
148 @ 2:872023de769d test 0 0 - default - makeacrlf | |
149 | | |
150 | o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
151 |/ | |
152 o 0:07f494440405 test 0 0 - default - adda | |
153 | |
154 | |
155 Test applying multiple patches | |
156 | |
157 $ hg up -qC 0 | |
158 $ echo e > e | |
159 $ hg ci -Am adde | |
160 adding e | |
161 created new head | |
162 $ hg export . > ../patch1.diff | |
163 $ hg up -qC 1 | |
164 $ echo f > f | |
165 $ hg ci -Am addf | |
166 adding f | |
167 $ hg export . > ../patch2.diff | |
168 $ cd .. | |
169 $ hg clone -r1 repo-options repo-multi1 | |
170 adding changesets | |
171 adding manifests | |
172 adding file changes | |
173 added 2 changesets with 2 changes to 1 files | |
174 updating to branch foo | |
175 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
176 $ cd repo-multi1 | |
177 $ hg up 0 | |
178 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
179 $ hg import --bypass ../patch1.diff ../patch2.diff | |
180 applying ../patch1.diff | |
181 applying ../patch2.diff | |
182 $ shortlog | |
183 o 3:bc8ca3f8a7c4 test 0 0 - default - addf | |
184 | | |
185 o 2:16581080145e test 0 0 - default - adde | |
186 | | |
187 | o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
188 |/ | |
189 @ 0:07f494440405 test 0 0 - default - adda | |
190 | |
191 | |
192 Test applying multiple patches with --exact | |
193 | |
194 $ cd .. | |
195 $ hg clone -r1 repo-options repo-multi2 | |
196 adding changesets | |
197 adding manifests | |
198 adding file changes | |
199 added 2 changesets with 2 changes to 1 files | |
200 updating to branch foo | |
201 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
202 $ cd repo-multi2 | |
203 $ hg import --bypass --exact ../patch1.diff ../patch2.diff | |
204 applying ../patch1.diff | |
205 applying ../patch2.diff | |
206 $ shortlog | |
207 o 3:d60cb8989666 test 0 0 - foo - addf | |
208 | | |
209 | o 2:16581080145e test 0 0 - default - adde | |
210 | | | |
211 @ | 1:4e322f7ce8e3 test 0 0 - foo - changea | |
212 |/ | |
213 o 0:07f494440405 test 0 0 - default - adda | |
214 | |
215 | |
216 $ cd .. | |
217 | |
16899
8149ff405c78
tests: convert some 'hghave execbit' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16124
diff
changeset
|
218 #if symlink execbit |
8149ff405c78
tests: convert some 'hghave execbit' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16124
diff
changeset
|
219 |
14611 | 220 Test complicated patch with --exact |
221 | |
222 $ hg init repo-exact | |
223 $ cd repo-exact | |
224 $ echo a > a | |
225 $ echo c > c | |
226 $ echo d > d | |
227 $ echo e > e | |
228 $ echo f > f | |
229 $ chmod +x f | |
230 $ ln -s c linkc | |
231 $ hg ci -Am t | |
232 adding a | |
233 adding c | |
234 adding d | |
235 adding e | |
236 adding f | |
237 adding linkc | |
238 $ hg cp a aa1 | |
239 $ echo b >> a | |
240 $ echo b > b | |
241 $ hg add b | |
242 $ hg cp a aa2 | |
243 $ echo aa >> aa2 | |
244 $ chmod +x e | |
245 $ chmod -x f | |
246 $ ln -s a linka | |
247 $ hg rm d | |
248 $ hg rm linkc | |
249 $ hg mv c cc | |
250 $ hg ci -m patch | |
251 $ hg export --git . > ../test.diff | |
252 $ hg up -C null | |
253 0 files updated, 0 files merged, 7 files removed, 0 files unresolved | |
254 $ hg purge | |
255 $ hg st | |
256 $ hg import --bypass --exact ../test.diff | |
257 applying ../test.diff | |
258 | |
259 The patch should have matched the exported revision and generated no additional | |
260 data. If not, diff both heads to debug it. | |
261 | |
262 $ shortlog | |
263 o 1:2978fd5c8aa4 test 0 0 - default - patch | |
264 | | |
265 o 0:a0e19e636a43 test 0 0 - default - t | |
266 | |
16899
8149ff405c78
tests: convert some 'hghave execbit' to #if
Mads Kiilerich <mads@kiilerich.com>
parents:
16124
diff
changeset
|
267 #endif |
16913
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
16899
diff
changeset
|
268 |
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
16899
diff
changeset
|
269 $ cd .. |