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