comparison tests/test-resolve.t @ 44396:acbfa31cfaf2

debugmergestate: make templated Our IntelliJ team wants to be able to read the merge state in order to help the user resolve merge conflicts. They had so far been reading file contents from p1() and p2() and their merge base. That is not ideal for several reasons (merge base is not necessarily the "graft base", renames are not handled, commands like `hg update -m` is not handled). It will get especially bad as of my D7827. This patch makes the output s a templated. I haven't bothered to make it complete (e.g. merge driver states are not handled), but it's probably good enough as a start. I've done a web search for "debugmergestate" and I can't find any indication that any tools currently rely on its output. If it turns out that we get bug reports for it once this is released, I won't object to backing this patch out on the stable branch (and then perhaps replace it by a separate command, or put it behind a new flag). The changes in test-backout.t are interesting, in particular this: ``` - other path: foo (node not stored in v1 format) + other path: (node foo) ``` I wonder if that means that we actually read v1 format incorrectly. That seems to be an old format that was switched away from in 2014, so it doesn't matter now anyway. Differential Revision: https://phab.mercurial-scm.org/D8120
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 13 Feb 2020 21:14:20 -0800
parents 7b80ad5af239
children b7808443ed6a
comparison
equal deleted inserted replaced
44395:382f4f09f0bd 44396:acbfa31cfaf2
304 304
305 insert unsupported advisory merge record 305 insert unsupported advisory merge record
306 306
307 $ hg --config extensions.fakemergerecord=$TESTDIR/fakemergerecord.py fakemergerecord -x 307 $ hg --config extensions.fakemergerecord=$TESTDIR/fakemergerecord.py fakemergerecord -x
308 $ hg debugmergestate 308 $ hg debugmergestate
309 * version 2 records 309 local (working copy): 57653b9f834a4493f7240b0681efcb9ae7cab745
310 local: 57653b9f834a4493f7240b0681efcb9ae7cab745 310 other (merge rev): dc77451844e37f03f5c559e3b8529b2b48d381d1
311 other: dc77451844e37f03f5c559e3b8529b2b48d381d1 311 file: file1 (state "r")
312 labels: 312 local path: file1 (hash 60b27f004e454aca81b0480209cce5081ec52390, flags "")
313 local: working copy
314 other: merge rev
315 unrecognized entry: x advisory record
316 file extras: file1 (ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac)
317 file: file1 (record type "F", state "r", hash 60b27f004e454aca81b0480209cce5081ec52390)
318 local path: file1 (flags "")
319 ancestor path: file1 (node 2ed2a3912a0b24502043eae84ee4b279c18b90dd) 313 ancestor path: file1 (node 2ed2a3912a0b24502043eae84ee4b279c18b90dd)
320 other path: file1 (node 6f4310b00b9a147241b071a60c28a650827fb03d) 314 other path: file1 (node 6f4310b00b9a147241b071a60c28a650827fb03d)
321 file extras: file2 (ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac) 315 extra: ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac
322 file: file2 (record type "F", state "u", hash cb99b709a1978bd205ab9dfd4c5aaa1fc91c7523) 316 file: file2 (state "u")
323 local path: file2 (flags "") 317 local path: file2 (hash cb99b709a1978bd205ab9dfd4c5aaa1fc91c7523, flags "")
324 ancestor path: file2 (node 2ed2a3912a0b24502043eae84ee4b279c18b90dd) 318 ancestor path: file2 (node 2ed2a3912a0b24502043eae84ee4b279c18b90dd)
325 other path: file2 (node 6f4310b00b9a147241b071a60c28a650827fb03d) 319 other path: file2 (node 6f4310b00b9a147241b071a60c28a650827fb03d)
326 $ hg resolve -l 320 extra: ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac
327 R file1 321 $ hg resolve -l
328 U file2 322 R file1
323 U file2
324
325 test json output
326
327 $ hg debugmergestate -T json
328 [
329 {
330 "commits": [{"label": "working copy", "name": "local", "node": "57653b9f834a4493f7240b0681efcb9ae7cab745"}, {"label": "merge rev", "name": "other", "node": "dc77451844e37f03f5c559e3b8529b2b48d381d1"}],
331 "files": [{"ancestor_node": "2ed2a3912a0b24502043eae84ee4b279c18b90dd", "ancestor_path": "file1", "extras": [{"key": "ancestorlinknode", "value": "99726c03216e233810a2564cbc0adfe395007eac"}], "local_flags": "", "local_key": "60b27f004e454aca81b0480209cce5081ec52390", "local_path": "file1", "other_node": "6f4310b00b9a147241b071a60c28a650827fb03d", "other_path": "file1", "path": "file1", "state": "r"}, {"ancestor_node": "2ed2a3912a0b24502043eae84ee4b279c18b90dd", "ancestor_path": "file2", "extras": [{"key": "ancestorlinknode", "value": "99726c03216e233810a2564cbc0adfe395007eac"}], "local_flags": "", "local_key": "cb99b709a1978bd205ab9dfd4c5aaa1fc91c7523", "local_path": "file2", "other_node": "6f4310b00b9a147241b071a60c28a650827fb03d", "other_path": "file2", "path": "file2", "state": "u"}]
332 }
333 ]
334
329 335
330 insert unsupported mandatory merge record 336 insert unsupported mandatory merge record
331 337
332 $ hg --config extensions.fakemergerecord=$TESTDIR/fakemergerecord.py fakemergerecord -X 338 $ hg --config extensions.fakemergerecord=$TESTDIR/fakemergerecord.py fakemergerecord -X
333 $ hg debugmergestate 339 $ hg debugmergestate
334 * version 2 records 340 abort: unsupported merge state records: X
335 local: 57653b9f834a4493f7240b0681efcb9ae7cab745 341 (see https://mercurial-scm.org/wiki/MergeStateRecords for more information)
336 other: dc77451844e37f03f5c559e3b8529b2b48d381d1 342 [255]
337 labels:
338 local: working copy
339 other: merge rev
340 file extras: file1 (ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac)
341 file: file1 (record type "F", state "r", hash 60b27f004e454aca81b0480209cce5081ec52390)
342 local path: file1 (flags "")
343 ancestor path: file1 (node 2ed2a3912a0b24502043eae84ee4b279c18b90dd)
344 other path: file1 (node 6f4310b00b9a147241b071a60c28a650827fb03d)
345 file extras: file2 (ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac)
346 file: file2 (record type "F", state "u", hash cb99b709a1978bd205ab9dfd4c5aaa1fc91c7523)
347 local path: file2 (flags "")
348 ancestor path: file2 (node 2ed2a3912a0b24502043eae84ee4b279c18b90dd)
349 other path: file2 (node 6f4310b00b9a147241b071a60c28a650827fb03d)
350 unrecognized entry: X mandatory record
351 $ hg resolve -l 343 $ hg resolve -l
352 abort: unsupported merge state records: X 344 abort: unsupported merge state records: X
353 (see https://mercurial-scm.org/wiki/MergeStateRecords for more information) 345 (see https://mercurial-scm.org/wiki/MergeStateRecords for more information)
354 [255] 346 [255]
355 $ hg resolve -ma 347 $ hg resolve -ma