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 working directory now based on revision 0
|
|
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
|
|
76 $ hg rollback
|
|
77 repository tip rolled back to revision 1 (undo commit)
|
|
78 working directory now based on revision 0
|
|
79
|
|
80 Test --strip
|
|
81
|
|
82 $ hg import --bypass --strip 0 - <<EOF
|
|
83 > # HG changeset patch
|
|
84 > # User test
|
|
85 > # Date 0 0
|
|
86 > # Branch foo
|
|
87 > # Node ID 4e322f7ce8e3e4203950eac9ece27bf7e45ffa6c
|
|
88 > # Parent 07f4944404050f47db2e5c5071e0e84e7a27bba9
|
|
89 > changea
|
|
90 >
|
|
91 > diff -r 07f494440405 -r 4e322f7ce8e3 a
|
|
92 > --- a Thu Jan 01 00:00:00 1970 +0000
|
|
93 > +++ a Thu Jan 01 00:00:00 1970 +0000
|
|
94 > @@ -1,1 +1,2 @@
|
|
95 > a
|
|
96 > +a
|
|
97 > EOF
|
|
98 applying patch from stdin
|
|
99 $ hg rollback
|
|
100 repository tip rolled back to revision 1 (undo commit)
|
|
101 working directory now based on revision 0
|
|
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 applied 16581080145e
|
|
178 $ shortlog
|
|
179 o 3:bc8ca3f8a7c4 test 0 0 - default - addf
|
|
180 |
|
|
181 o 2:16581080145e test 0 0 - default - adde
|
|
182 |
|
|
183 | o 1:4e322f7ce8e3 test 0 0 - foo - changea
|
|
184 |/
|
|
185 @ 0:07f494440405 test 0 0 - default - adda
|
|
186
|
|
187
|
|
188 Test applying multiple patches with --exact
|
|
189
|
|
190 $ cd ..
|
|
191 $ hg clone -r1 repo-options repo-multi2
|
|
192 adding changesets
|
|
193 adding manifests
|
|
194 adding file changes
|
|
195 added 2 changesets with 2 changes to 1 files
|
|
196 updating to branch foo
|
|
197 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
198 $ cd repo-multi2
|
|
199 $ hg import --bypass --exact ../patch1.diff ../patch2.diff
|
|
200 applying ../patch1.diff
|
|
201 applying ../patch2.diff
|
|
202 applied 16581080145e
|
|
203 $ shortlog
|
|
204 o 3:d60cb8989666 test 0 0 - foo - addf
|
|
205 |
|
|
206 | o 2:16581080145e test 0 0 - default - adde
|
|
207 | |
|
|
208 @ | 1:4e322f7ce8e3 test 0 0 - foo - changea
|
|
209 |/
|
|
210 o 0:07f494440405 test 0 0 - default - adda
|
|
211
|
|
212
|
|
213 $ cd ..
|
|
214
|
|
215 Test complicated patch with --exact
|
|
216
|
|
217 $ hg init repo-exact
|
|
218 $ cd repo-exact
|
|
219 $ echo a > a
|
|
220 $ echo c > c
|
|
221 $ echo d > d
|
|
222 $ echo e > e
|
|
223 $ echo f > f
|
|
224 $ chmod +x f
|
|
225 $ ln -s c linkc
|
|
226 $ hg ci -Am t
|
|
227 adding a
|
|
228 adding c
|
|
229 adding d
|
|
230 adding e
|
|
231 adding f
|
|
232 adding linkc
|
|
233 $ hg cp a aa1
|
|
234 $ echo b >> a
|
|
235 $ echo b > b
|
|
236 $ hg add b
|
|
237 $ hg cp a aa2
|
|
238 $ echo aa >> aa2
|
|
239 $ chmod +x e
|
|
240 $ chmod -x f
|
|
241 $ ln -s a linka
|
|
242 $ hg rm d
|
|
243 $ hg rm linkc
|
|
244 $ hg mv c cc
|
|
245 $ hg ci -m patch
|
|
246 $ hg export --git . > ../test.diff
|
|
247 $ hg up -C null
|
|
248 0 files updated, 0 files merged, 7 files removed, 0 files unresolved
|
|
249 $ hg purge
|
|
250 $ hg st
|
|
251 $ hg import --bypass --exact ../test.diff
|
|
252 applying ../test.diff
|
|
253
|
|
254 The patch should have matched the exported revision and generated no additional
|
|
255 data. If not, diff both heads to debug it.
|
|
256
|
|
257 $ shortlog
|
|
258 o 1:2978fd5c8aa4 test 0 0 - default - patch
|
|
259 |
|
|
260 o 0:a0e19e636a43 test 0 0 - default - t
|
|
261
|