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