Show More
@@ -1,366 +1,367 b'' | |||
|
1 | 1 | test that a commit clears the merge state. |
|
2 | 2 | |
|
3 | 3 | $ hg init repo |
|
4 | 4 | $ cd repo |
|
5 | 5 | |
|
6 | 6 | $ echo foo > file1 |
|
7 | 7 | $ echo foo > file2 |
|
8 | 8 | $ hg commit -Am 'add files' |
|
9 | 9 | adding file1 |
|
10 | 10 | adding file2 |
|
11 | 11 | |
|
12 | 12 | $ echo bar >> file1 |
|
13 | 13 | $ echo bar >> file2 |
|
14 | 14 | $ hg commit -Am 'append bar to files' |
|
15 | 15 | |
|
16 | 16 | create a second head with conflicting edits |
|
17 | 17 | |
|
18 | 18 | $ hg up -C 0 |
|
19 | 19 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
20 | 20 | $ echo baz >> file1 |
|
21 | 21 | $ echo baz >> file2 |
|
22 | 22 | $ hg commit -Am 'append baz to files' |
|
23 | 23 | created new head |
|
24 | 24 | |
|
25 | 25 | create a third head with no conflicting edits |
|
26 | 26 | $ hg up -qC 0 |
|
27 | 27 | $ echo foo > file3 |
|
28 | 28 | $ hg commit -Am 'add non-conflicting file' |
|
29 | 29 | adding file3 |
|
30 | 30 | created new head |
|
31 | 31 | |
|
32 | 32 | failing merge |
|
33 | 33 | |
|
34 | 34 | $ hg up -qC 2 |
|
35 | 35 | $ hg merge --tool=internal:fail 1 |
|
36 | 36 | 0 files updated, 0 files merged, 0 files removed, 2 files unresolved |
|
37 | 37 | use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon |
|
38 | 38 | [1] |
|
39 | 39 | |
|
40 | 40 | resolve -l should contain unresolved entries |
|
41 | 41 | |
|
42 | 42 | $ hg resolve -l |
|
43 | 43 | U file1 |
|
44 | 44 | U file2 |
|
45 | 45 | |
|
46 | 46 | $ hg resolve -l --no-status |
|
47 | 47 | file1 |
|
48 | 48 | file2 |
|
49 | 49 | |
|
50 | 50 | resolving an unknown path should emit a warning, but not for -l |
|
51 | 51 | |
|
52 | 52 | $ hg resolve -m does-not-exist |
|
53 | 53 | arguments do not match paths that need resolving |
|
54 | 54 | $ hg resolve -l does-not-exist |
|
55 | 55 | |
|
56 | 56 | tell users how they could have used resolve |
|
57 | 57 | |
|
58 | 58 | $ mkdir nested |
|
59 | 59 | $ cd nested |
|
60 | 60 | $ hg resolve -m file1 |
|
61 | 61 | arguments do not match paths that need resolving |
|
62 | 62 | (try: hg resolve -m path:file1) |
|
63 | 63 | $ hg resolve -m file1 filez |
|
64 | 64 | arguments do not match paths that need resolving |
|
65 | 65 | (try: hg resolve -m path:file1 path:filez) |
|
66 | 66 | $ hg resolve -m path:file1 path:filez |
|
67 | 67 | $ hg resolve -l |
|
68 | 68 | R file1 |
|
69 | 69 | U file2 |
|
70 | 70 | $ hg resolve -m filez file2 |
|
71 | 71 | arguments do not match paths that need resolving |
|
72 | 72 | (try: hg resolve -m path:filez path:file2) |
|
73 | 73 | $ hg resolve -m path:filez path:file2 |
|
74 | 74 | (no more unresolved files) |
|
75 | 75 | $ hg resolve -l |
|
76 | 76 | R file1 |
|
77 | 77 | R file2 |
|
78 | 78 | |
|
79 | 79 | cleanup |
|
80 | 80 | $ hg resolve -u |
|
81 | 81 | $ cd .. |
|
82 | 82 | $ rmdir nested |
|
83 | 83 | |
|
84 | 84 | don't allow marking or unmarking driver-resolved files |
|
85 | 85 | |
|
86 | 86 | $ cat > $TESTTMP/markdriver.py << EOF |
|
87 | 87 | > '''mark and unmark files as driver-resolved''' |
|
88 | > from mercurial import merge, registrar, scmutil | |
|
88 | > from mercurial import merge, registrar, scmutil, pycompat | |
|
89 | 89 | > cmdtable = {} |
|
90 | 90 | > command = registrar.command(cmdtable) |
|
91 | 91 | > @command(b'markdriver', |
|
92 | > [('u', 'unmark', None, '')], | |
|
93 | > 'FILE...') | |
|
92 | > [(b'u', b'unmark', None, b'')], | |
|
93 | > b'FILE...') | |
|
94 | 94 | > def markdriver(ui, repo, *pats, **opts): |
|
95 | 95 | > wlock = repo.wlock() |
|
96 | > opts = pycompat.byteskwargs(opts) | |
|
96 | 97 | > try: |
|
97 | 98 | > ms = merge.mergestate.read(repo) |
|
98 | 99 | > m = scmutil.match(repo[None], pats, opts) |
|
99 | 100 | > for f in ms: |
|
100 | 101 | > if not m(f): |
|
101 | 102 | > continue |
|
102 | > if not opts['unmark']: | |
|
103 | > ms.mark(f, 'd') | |
|
103 | > if not opts[b'unmark']: | |
|
104 | > ms.mark(f, b'd') | |
|
104 | 105 | > else: |
|
105 | > ms.mark(f, 'u') | |
|
106 | > ms.mark(f, b'u') | |
|
106 | 107 | > ms.commit() |
|
107 | 108 | > finally: |
|
108 | 109 | > wlock.release() |
|
109 | 110 | > EOF |
|
110 | 111 | $ hg --config extensions.markdriver=$TESTTMP/markdriver.py markdriver file1 |
|
111 | 112 | $ hg resolve --list |
|
112 | 113 | D file1 |
|
113 | 114 | U file2 |
|
114 | 115 | $ hg resolve --mark file1 |
|
115 | 116 | not marking file1 as it is driver-resolved |
|
116 | 117 | this should not print out file1 |
|
117 | 118 | $ hg resolve --mark --all |
|
118 | 119 | (no more unresolved files -- run "hg resolve --all" to conclude) |
|
119 | 120 | $ hg resolve --mark 'glob:file*' |
|
120 | 121 | (no more unresolved files -- run "hg resolve --all" to conclude) |
|
121 | 122 | $ hg resolve --list |
|
122 | 123 | D file1 |
|
123 | 124 | R file2 |
|
124 | 125 | $ hg resolve --unmark file1 |
|
125 | 126 | not unmarking file1 as it is driver-resolved |
|
126 | 127 | (no more unresolved files -- run "hg resolve --all" to conclude) |
|
127 | 128 | $ hg resolve --unmark --all |
|
128 | 129 | $ hg resolve --list |
|
129 | 130 | D file1 |
|
130 | 131 | U file2 |
|
131 | 132 | $ hg --config extensions.markdriver=$TESTTMP/markdriver.py markdriver --unmark file1 |
|
132 | 133 | $ hg resolve --list |
|
133 | 134 | U file1 |
|
134 | 135 | U file2 |
|
135 | 136 | |
|
136 | 137 | resolve the failure |
|
137 | 138 | |
|
138 | 139 | $ echo resolved > file1 |
|
139 | 140 | $ hg resolve -m file1 |
|
140 | 141 | |
|
141 | 142 | resolve -l should show resolved file as resolved |
|
142 | 143 | |
|
143 | 144 | $ hg resolve -l |
|
144 | 145 | R file1 |
|
145 | 146 | U file2 |
|
146 | 147 | |
|
147 | 148 | $ hg resolve -l -Tjson |
|
148 | 149 | [ |
|
149 | 150 | { |
|
150 | 151 | "path": "file1", |
|
151 | 152 | "status": "R" |
|
152 | 153 | }, |
|
153 | 154 | { |
|
154 | 155 | "path": "file2", |
|
155 | 156 | "status": "U" |
|
156 | 157 | } |
|
157 | 158 | ] |
|
158 | 159 | |
|
159 | 160 | resolve -m without paths should mark all resolved |
|
160 | 161 | |
|
161 | 162 | $ hg resolve -m |
|
162 | 163 | (no more unresolved files) |
|
163 | 164 | $ hg commit -m 'resolved' |
|
164 | 165 | |
|
165 | 166 | resolve -l should be empty after commit |
|
166 | 167 | |
|
167 | 168 | $ hg resolve -l |
|
168 | 169 | |
|
169 | 170 | $ hg resolve -l -Tjson |
|
170 | 171 | [ |
|
171 | 172 | ] |
|
172 | 173 | |
|
173 | 174 | resolve --all should abort when no merge in progress |
|
174 | 175 | |
|
175 | 176 | $ hg resolve --all |
|
176 | 177 | abort: resolve command not applicable when not merging |
|
177 | 178 | [255] |
|
178 | 179 | |
|
179 | 180 | resolve -m should abort when no merge in progress |
|
180 | 181 | |
|
181 | 182 | $ hg resolve -m |
|
182 | 183 | abort: resolve command not applicable when not merging |
|
183 | 184 | [255] |
|
184 | 185 | |
|
185 | 186 | can not update or merge when there are unresolved conflicts |
|
186 | 187 | |
|
187 | 188 | $ hg up -qC 0 |
|
188 | 189 | $ echo quux >> file1 |
|
189 | 190 | $ hg up 1 |
|
190 | 191 | merging file1 |
|
191 | 192 | warning: conflicts while merging file1! (edit, then use 'hg resolve --mark') |
|
192 | 193 | 1 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
193 | 194 | use 'hg resolve' to retry unresolved file merges |
|
194 | 195 | [1] |
|
195 | 196 | $ hg up 0 |
|
196 | 197 | abort: outstanding merge conflicts |
|
197 | 198 | [255] |
|
198 | 199 | $ hg merge 2 |
|
199 | 200 | abort: outstanding merge conflicts |
|
200 | 201 | [255] |
|
201 | 202 | $ hg merge --force 2 |
|
202 | 203 | abort: outstanding merge conflicts |
|
203 | 204 | [255] |
|
204 | 205 | |
|
205 | 206 | set up conflict-free merge |
|
206 | 207 | |
|
207 | 208 | $ hg up -qC 3 |
|
208 | 209 | $ hg merge 1 |
|
209 | 210 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
210 | 211 | (branch merge, don't forget to commit) |
|
211 | 212 | |
|
212 | 213 | resolve --all should do nothing in merge without conflicts |
|
213 | 214 | $ hg resolve --all |
|
214 | 215 | (no more unresolved files) |
|
215 | 216 | |
|
216 | 217 | resolve -m should do nothing in merge without conflicts |
|
217 | 218 | |
|
218 | 219 | $ hg resolve -m |
|
219 | 220 | (no more unresolved files) |
|
220 | 221 | |
|
221 | 222 | get back to conflicting state |
|
222 | 223 | |
|
223 | 224 | $ hg up -qC 2 |
|
224 | 225 | $ hg merge --tool=internal:fail 1 |
|
225 | 226 | 0 files updated, 0 files merged, 0 files removed, 2 files unresolved |
|
226 | 227 | use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon |
|
227 | 228 | [1] |
|
228 | 229 | |
|
229 | 230 | resolve without arguments should suggest --all |
|
230 | 231 | $ hg resolve |
|
231 | 232 | abort: no files or directories specified |
|
232 | 233 | (use --all to re-merge all unresolved files) |
|
233 | 234 | [255] |
|
234 | 235 | |
|
235 | 236 | resolve --all should re-merge all unresolved files |
|
236 | 237 | $ hg resolve --all |
|
237 | 238 | merging file1 |
|
238 | 239 | merging file2 |
|
239 | 240 | warning: conflicts while merging file1! (edit, then use 'hg resolve --mark') |
|
240 | 241 | warning: conflicts while merging file2! (edit, then use 'hg resolve --mark') |
|
241 | 242 | [1] |
|
242 | 243 | $ cat file1.orig |
|
243 | 244 | foo |
|
244 | 245 | baz |
|
245 | 246 | $ cat file2.orig |
|
246 | 247 | foo |
|
247 | 248 | baz |
|
248 | 249 | |
|
249 | 250 | .orig files should exists where specified |
|
250 | 251 | $ hg resolve --all --verbose --config 'ui.origbackuppath=.hg/origbackups' |
|
251 | 252 | merging file1 |
|
252 | 253 | creating directory: $TESTTMP/repo/.hg/origbackups |
|
253 | 254 | merging file2 |
|
254 | 255 | warning: conflicts while merging file1! (edit, then use 'hg resolve --mark') |
|
255 | 256 | warning: conflicts while merging file2! (edit, then use 'hg resolve --mark') |
|
256 | 257 | [1] |
|
257 | 258 | $ ls .hg/origbackups |
|
258 | 259 | file1 |
|
259 | 260 | file2 |
|
260 | 261 | $ grep '<<<' file1 > /dev/null |
|
261 | 262 | $ grep '<<<' file2 > /dev/null |
|
262 | 263 | |
|
263 | 264 | resolve <file> should re-merge file |
|
264 | 265 | $ echo resolved > file1 |
|
265 | 266 | $ hg resolve -q file1 |
|
266 | 267 | warning: conflicts while merging file1! (edit, then use 'hg resolve --mark') |
|
267 | 268 | [1] |
|
268 | 269 | $ grep '<<<' file1 > /dev/null |
|
269 | 270 | |
|
270 | 271 | test .orig behavior with resolve |
|
271 | 272 | |
|
272 | 273 | $ hg resolve -q file1 --tool "sh -c 'f --dump \"$TESTTMP/repo/file1.orig\"'" |
|
273 | 274 | $TESTTMP/repo/file1.orig: |
|
274 | 275 | >>> |
|
275 | 276 | foo |
|
276 | 277 | baz |
|
277 | 278 | <<< |
|
278 | 279 | |
|
279 | 280 | resolve <file> should do nothing if 'file' was marked resolved |
|
280 | 281 | $ echo resolved > file1 |
|
281 | 282 | $ hg resolve -m file1 |
|
282 | 283 | $ hg resolve -q file1 |
|
283 | 284 | $ cat file1 |
|
284 | 285 | resolved |
|
285 | 286 | |
|
286 | 287 | insert unsupported advisory merge record |
|
287 | 288 | |
|
288 | 289 | $ hg --config extensions.fakemergerecord=$TESTDIR/fakemergerecord.py fakemergerecord -x |
|
289 | 290 | $ hg debugmergestate |
|
290 | 291 | * version 2 records |
|
291 | 292 | local: 57653b9f834a4493f7240b0681efcb9ae7cab745 |
|
292 | 293 | other: dc77451844e37f03f5c559e3b8529b2b48d381d1 |
|
293 | 294 | labels: |
|
294 | 295 | local: working copy |
|
295 | 296 | other: merge rev |
|
296 | 297 | unrecognized entry: x advisory record |
|
297 | 298 | file extras: file1 (ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac) |
|
298 | 299 | file: file1 (record type "F", state "r", hash 60b27f004e454aca81b0480209cce5081ec52390) |
|
299 | 300 | local path: file1 (flags "") |
|
300 | 301 | ancestor path: file1 (node 2ed2a3912a0b24502043eae84ee4b279c18b90dd) |
|
301 | 302 | other path: file1 (node 6f4310b00b9a147241b071a60c28a650827fb03d) |
|
302 | 303 | file extras: file2 (ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac) |
|
303 | 304 | file: file2 (record type "F", state "u", hash cb99b709a1978bd205ab9dfd4c5aaa1fc91c7523) |
|
304 | 305 | local path: file2 (flags "") |
|
305 | 306 | ancestor path: file2 (node 2ed2a3912a0b24502043eae84ee4b279c18b90dd) |
|
306 | 307 | other path: file2 (node 6f4310b00b9a147241b071a60c28a650827fb03d) |
|
307 | 308 | $ hg resolve -l |
|
308 | 309 | R file1 |
|
309 | 310 | U file2 |
|
310 | 311 | |
|
311 | 312 | insert unsupported mandatory merge record |
|
312 | 313 | |
|
313 | 314 | $ hg --config extensions.fakemergerecord=$TESTDIR/fakemergerecord.py fakemergerecord -X |
|
314 | 315 | $ hg debugmergestate |
|
315 | 316 | * version 2 records |
|
316 | 317 | local: 57653b9f834a4493f7240b0681efcb9ae7cab745 |
|
317 | 318 | other: dc77451844e37f03f5c559e3b8529b2b48d381d1 |
|
318 | 319 | labels: |
|
319 | 320 | local: working copy |
|
320 | 321 | other: merge rev |
|
321 | 322 | file extras: file1 (ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac) |
|
322 | 323 | file: file1 (record type "F", state "r", hash 60b27f004e454aca81b0480209cce5081ec52390) |
|
323 | 324 | local path: file1 (flags "") |
|
324 | 325 | ancestor path: file1 (node 2ed2a3912a0b24502043eae84ee4b279c18b90dd) |
|
325 | 326 | other path: file1 (node 6f4310b00b9a147241b071a60c28a650827fb03d) |
|
326 | 327 | file extras: file2 (ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac) |
|
327 | 328 | file: file2 (record type "F", state "u", hash cb99b709a1978bd205ab9dfd4c5aaa1fc91c7523) |
|
328 | 329 | local path: file2 (flags "") |
|
329 | 330 | ancestor path: file2 (node 2ed2a3912a0b24502043eae84ee4b279c18b90dd) |
|
330 | 331 | other path: file2 (node 6f4310b00b9a147241b071a60c28a650827fb03d) |
|
331 | 332 | unrecognized entry: X mandatory record |
|
332 | 333 | $ hg resolve -l |
|
333 | 334 | abort: unsupported merge state records: X |
|
334 | 335 | (see https://mercurial-scm.org/wiki/MergeStateRecords for more information) |
|
335 | 336 | [255] |
|
336 | 337 | $ hg resolve -ma |
|
337 | 338 | abort: unsupported merge state records: X |
|
338 | 339 | (see https://mercurial-scm.org/wiki/MergeStateRecords for more information) |
|
339 | 340 | [255] |
|
340 | 341 | $ hg summary |
|
341 | 342 | warning: merge state has unsupported record types: X |
|
342 | 343 | parent: 2:57653b9f834a |
|
343 | 344 | append baz to files |
|
344 | 345 | parent: 1:dc77451844e3 |
|
345 | 346 | append bar to files |
|
346 | 347 | branch: default |
|
347 | 348 | commit: 2 modified, 2 unknown (merge) |
|
348 | 349 | update: 2 new changesets (update) |
|
349 | 350 | phases: 5 draft |
|
350 | 351 | |
|
351 | 352 | update --clean shouldn't abort on unsupported records |
|
352 | 353 | |
|
353 | 354 | $ hg up -qC 1 |
|
354 | 355 | $ hg debugmergestate |
|
355 | 356 | no merge state found |
|
356 | 357 | |
|
357 | 358 | test crashed merge with empty mergestate |
|
358 | 359 | |
|
359 | 360 | $ mkdir .hg/merge |
|
360 | 361 | $ touch .hg/merge/state |
|
361 | 362 | |
|
362 | 363 | resolve -l should be empty |
|
363 | 364 | |
|
364 | 365 | $ hg resolve -l |
|
365 | 366 | |
|
366 | 367 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now