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
|
|
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 |
|
|
63 |
$ hg rollback
|
|
64 |
repository tip rolled back to revision 1 (undo commit)
|
|
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 |
|
|
75 |
$ hg rollback
|
|
76 |
repository tip rolled back to revision 1 (undo commit)
|
|
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
|
|
97 |
$ hg rollback
|
|
98 |
repository tip rolled back to revision 1 (undo commit)
|
|
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 |
|
|
111 |
$ hg diff -c 1 > ../test.diff
|
|
112 |
$ HGEDITOR=cat hg import --bypass ../test.diff
|
|
113 |
applying ../test.diff
|
|
114 |
|
|
115 |
|
|
116 |
HG: Enter commit message. Lines beginning with 'HG:' are removed.
|
|
117 |
HG: Leave message empty to abort commit.
|
|
118 |
HG: --
|
|
119 |
HG: user: test
|
|
120 |
HG: branch 'default'
|
|
121 |
HG: changed a
|
|
122 |
abort: empty commit message
|
|
123 |
[255]
|
|
124 |
|
|
125 |
Test patch.eol is handled
|
|
126 |
|
|
127 |
$ python -c 'file("a", "wb").write("a\r\n")'
|
|
128 |
$ hg ci -m makeacrlf
|
|
129 |
$ hg import -m 'should fail because of eol' --bypass ../test.diff
|
|
130 |
applying ../test.diff
|
|
131 |
patching file a
|
|
132 |
Hunk #1 FAILED at 0
|
|
133 |
abort: patch failed to apply
|
|
134 |
[255]
|
|
135 |
$ hg --config patch.eol=auto import -d '0 0' -m 'test patch.eol' --bypass ../test.diff
|
|
136 |
applying ../test.diff
|
|
137 |
$ shortlog
|
|
138 |
o 3:d7805b4d2cb3 test 0 0 - default - test patch.eol
|
|
139 |
|
|
|
140 |
@ 2:872023de769d test 0 0 - default - makeacrlf
|
|
141 |
|
|
|
142 |
| o 1:4e322f7ce8e3 test 0 0 - foo - changea
|
|
143 |
|/
|
|
144 |
o 0:07f494440405 test 0 0 - default - adda
|
|
145 |
|
|
146 |
|
|
147 |
Test applying multiple patches
|
|
148 |
|
|
149 |
$ hg up -qC 0
|
|
150 |
$ echo e > e
|
|
151 |
$ hg ci -Am adde
|
|
152 |
adding e
|
|
153 |
created new head
|
|
154 |
$ hg export . > ../patch1.diff
|
|
155 |
$ hg up -qC 1
|
|
156 |
$ echo f > f
|
|
157 |
$ hg ci -Am addf
|
|
158 |
adding f
|
|
159 |
$ hg export . > ../patch2.diff
|
|
160 |
$ cd ..
|
|
161 |
$ hg clone -r1 repo-options repo-multi1
|
|
162 |
adding changesets
|
|
163 |
adding manifests
|
|
164 |
adding file changes
|
|
165 |
added 2 changesets with 2 changes to 1 files
|
|
166 |
updating to branch foo
|
|
167 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
168 |
$ cd repo-multi1
|
|
169 |
$ hg up 0
|
|
170 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
171 |
$ hg import --bypass ../patch1.diff ../patch2.diff
|
|
172 |
applying ../patch1.diff
|
|
173 |
applying ../patch2.diff
|
|
174 |
applied 16581080145e
|
|
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 |
applied 16581080145e
|
|
200 |
$ shortlog
|
|
201 |
o 3:d60cb8989666 test 0 0 - foo - addf
|
|
202 |
|
|
|
203 |
| o 2:16581080145e test 0 0 - default - adde
|
|
204 |
| |
|
|
205 |
@ | 1:4e322f7ce8e3 test 0 0 - foo - changea
|
|
206 |
|/
|
|
207 |
o 0:07f494440405 test 0 0 - default - adda
|
|
208 |
|
|
209 |
|
|
210 |
$ cd ..
|
|
211 |
|
|
212 |
Test complicated patch with --exact
|
|
213 |
|
|
214 |
$ hg init repo-exact
|
|
215 |
$ cd repo-exact
|
|
216 |
$ echo a > a
|
|
217 |
$ echo c > c
|
|
218 |
$ echo d > d
|
|
219 |
$ echo e > e
|
|
220 |
$ echo f > f
|
|
221 |
$ chmod +x f
|
|
222 |
$ ln -s c linkc
|
|
223 |
$ hg ci -Am t
|
|
224 |
adding a
|
|
225 |
adding c
|
|
226 |
adding d
|
|
227 |
adding e
|
|
228 |
adding f
|
|
229 |
adding linkc
|
|
230 |
$ hg cp a aa1
|
|
231 |
$ echo b >> a
|
|
232 |
$ echo b > b
|
|
233 |
$ hg add b
|
|
234 |
$ hg cp a aa2
|
|
235 |
$ echo aa >> aa2
|
|
236 |
$ chmod +x e
|
|
237 |
$ chmod -x f
|
|
238 |
$ ln -s a linka
|
|
239 |
$ hg rm d
|
|
240 |
$ hg rm linkc
|
|
241 |
$ hg mv c cc
|
|
242 |
$ hg ci -m patch
|
|
243 |
$ hg export --git . > ../test.diff
|
|
244 |
$ hg up -C null
|
|
245 |
0 files updated, 0 files merged, 7 files removed, 0 files unresolved
|
|
246 |
$ hg purge
|
|
247 |
$ hg st
|
|
248 |
$ hg import --bypass --exact ../test.diff
|
|
249 |
applying ../test.diff
|
|
250 |
|
|
251 |
The patch should have matched the exported revision and generated no additional
|
|
252 |
data. If not, diff both heads to debug it.
|
|
253 |
|
|
254 |
$ shortlog
|
|
255 |
o 1:2978fd5c8aa4 test 0 0 - default - patch
|
|
256 |
|
|
|
257 |
o 0:a0e19e636a43 test 0 0 - default - t
|
|
258 |
|