Mercurial > hg
annotate tests/test-import-bypass.t @ 15615:41885892796e stable
branch: warn on branching
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 08 Dec 2011 14:32:44 -0600 |
parents | 62dc0e7ab092 |
children | fc8c7a5ccc4a |
rev | line source |
---|---|
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 | |
112 $ hg diff -c 1 > ../test.diff | |
113 $ HGEDITOR=cat hg import --bypass ../test.diff | |
114 applying ../test.diff | |
115 | |
116 | |
117 HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
118 HG: Leave message empty to abort commit. | |
119 HG: -- | |
120 HG: user: test | |
121 HG: branch 'default' | |
122 HG: changed a | |
123 abort: empty commit message | |
124 [255] | |
125 | |
126 Test patch.eol is handled | |
127 | |
128 $ python -c 'file("a", "wb").write("a\r\n")' | |
129 $ hg ci -m makeacrlf | |
130 $ hg import -m 'should fail because of eol' --bypass ../test.diff | |
131 applying ../test.diff | |
132 patching file a | |
133 Hunk #1 FAILED at 0 | |
134 abort: patch failed to apply | |
135 [255] | |
136 $ hg --config patch.eol=auto import -d '0 0' -m 'test patch.eol' --bypass ../test.diff | |
137 applying ../test.diff | |
138 $ shortlog | |
139 o 3:d7805b4d2cb3 test 0 0 - default - test patch.eol | |
140 | | |
141 @ 2:872023de769d test 0 0 - default - makeacrlf | |
142 | | |
143 | o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
144 |/ | |
145 o 0:07f494440405 test 0 0 - default - adda | |
146 | |
147 | |
148 Test applying multiple patches | |
149 | |
150 $ hg up -qC 0 | |
151 $ echo e > e | |
152 $ hg ci -Am adde | |
153 adding e | |
154 created new head | |
155 $ hg export . > ../patch1.diff | |
156 $ hg up -qC 1 | |
157 $ echo f > f | |
158 $ hg ci -Am addf | |
159 adding f | |
160 $ hg export . > ../patch2.diff | |
161 $ cd .. | |
162 $ hg clone -r1 repo-options repo-multi1 | |
163 adding changesets | |
164 adding manifests | |
165 adding file changes | |
166 added 2 changesets with 2 changes to 1 files | |
167 updating to branch foo | |
168 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
169 $ cd repo-multi1 | |
170 $ hg up 0 | |
171 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
172 $ hg import --bypass ../patch1.diff ../patch2.diff | |
173 applying ../patch1.diff | |
174 applying ../patch2.diff | |
175 $ shortlog | |
176 o 3:bc8ca3f8a7c4 test 0 0 - default - addf | |
177 | | |
178 o 2:16581080145e test 0 0 - default - adde | |
179 | | |
180 | o 1:4e322f7ce8e3 test 0 0 - foo - changea | |
181 |/ | |
182 @ 0:07f494440405 test 0 0 - default - adda | |
183 | |
184 | |
185 Test applying multiple patches with --exact | |
186 | |
187 $ cd .. | |
188 $ hg clone -r1 repo-options repo-multi2 | |
189 adding changesets | |
190 adding manifests | |
191 adding file changes | |
192 added 2 changesets with 2 changes to 1 files | |
193 updating to branch foo | |
194 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
195 $ cd repo-multi2 | |
196 $ hg import --bypass --exact ../patch1.diff ../patch2.diff | |
197 applying ../patch1.diff | |
198 applying ../patch2.diff | |
199 $ shortlog | |
200 o 3:d60cb8989666 test 0 0 - foo - addf | |
201 | | |
202 | o 2:16581080145e test 0 0 - default - adde | |
203 | | | |
204 @ | 1:4e322f7ce8e3 test 0 0 - foo - changea | |
205 |/ | |
206 o 0:07f494440405 test 0 0 - default - adda | |
207 | |
208 | |
209 $ cd .. | |
210 | |
211 Test complicated patch with --exact | |
212 | |
213 $ hg init repo-exact | |
214 $ cd repo-exact | |
215 $ echo a > a | |
216 $ echo c > c | |
217 $ echo d > d | |
218 $ echo e > e | |
219 $ echo f > f | |
220 $ chmod +x f | |
221 $ ln -s c linkc | |
222 $ hg ci -Am t | |
223 adding a | |
224 adding c | |
225 adding d | |
226 adding e | |
227 adding f | |
228 adding linkc | |
229 $ hg cp a aa1 | |
230 $ echo b >> a | |
231 $ echo b > b | |
232 $ hg add b | |
233 $ hg cp a aa2 | |
234 $ echo aa >> aa2 | |
235 $ chmod +x e | |
236 $ chmod -x f | |
237 $ ln -s a linka | |
238 $ hg rm d | |
239 $ hg rm linkc | |
240 $ hg mv c cc | |
241 $ hg ci -m patch | |
242 $ hg export --git . > ../test.diff | |
243 $ hg up -C null | |
244 0 files updated, 0 files merged, 7 files removed, 0 files unresolved | |
245 $ hg purge | |
246 $ hg st | |
247 $ hg import --bypass --exact ../test.diff | |
248 applying ../test.diff | |
249 | |
250 The patch should have matched the exported revision and generated no additional | |
251 data. If not, diff both heads to debug it. | |
252 | |
253 $ shortlog | |
254 o 1:2978fd5c8aa4 test 0 0 - default - patch | |
255 | | |
256 o 0:a0e19e636a43 test 0 0 - default - t | |
257 |