diff tests/test-resolve.t @ 44427: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
line wrap: on
line diff
--- a/tests/test-resolve.t	Thu Feb 13 21:55:38 2020 -0800
+++ b/tests/test-resolve.t	Thu Feb 13 21:14:20 2020 -0800
@@ -306,48 +306,40 @@
 
   $ hg --config extensions.fakemergerecord=$TESTDIR/fakemergerecord.py fakemergerecord -x
   $ hg debugmergestate
-  * version 2 records
-  local: 57653b9f834a4493f7240b0681efcb9ae7cab745
-  other: dc77451844e37f03f5c559e3b8529b2b48d381d1
-  labels:
-    local: working copy
-    other: merge rev
-  unrecognized entry: x	advisory record
-  file extras: file1 (ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac)
-  file: file1 (record type "F", state "r", hash 60b27f004e454aca81b0480209cce5081ec52390)
-    local path: file1 (flags "")
+  local (working copy): 57653b9f834a4493f7240b0681efcb9ae7cab745
+  other (merge rev): dc77451844e37f03f5c559e3b8529b2b48d381d1
+  file: file1 (state "r")
+    local path: file1 (hash 60b27f004e454aca81b0480209cce5081ec52390, flags "")
     ancestor path: file1 (node 2ed2a3912a0b24502043eae84ee4b279c18b90dd)
     other path: file1 (node 6f4310b00b9a147241b071a60c28a650827fb03d)
-  file extras: file2 (ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac)
-  file: file2 (record type "F", state "u", hash cb99b709a1978bd205ab9dfd4c5aaa1fc91c7523)
-    local path: file2 (flags "")
+    extra: ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac
+  file: file2 (state "u")
+    local path: file2 (hash cb99b709a1978bd205ab9dfd4c5aaa1fc91c7523, flags "")
     ancestor path: file2 (node 2ed2a3912a0b24502043eae84ee4b279c18b90dd)
     other path: file2 (node 6f4310b00b9a147241b071a60c28a650827fb03d)
+    extra: ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac
   $ hg resolve -l
   R file1
   U file2
 
+test json output
+
+  $ hg debugmergestate -T json
+  [
+   {
+    "commits": [{"label": "working copy", "name": "local", "node": "57653b9f834a4493f7240b0681efcb9ae7cab745"}, {"label": "merge rev", "name": "other", "node": "dc77451844e37f03f5c559e3b8529b2b48d381d1"}],
+    "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"}]
+   }
+  ]
+
+
 insert unsupported mandatory merge record
 
   $ hg --config extensions.fakemergerecord=$TESTDIR/fakemergerecord.py fakemergerecord -X
   $ hg debugmergestate
-  * version 2 records
-  local: 57653b9f834a4493f7240b0681efcb9ae7cab745
-  other: dc77451844e37f03f5c559e3b8529b2b48d381d1
-  labels:
-    local: working copy
-    other: merge rev
-  file extras: file1 (ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac)
-  file: file1 (record type "F", state "r", hash 60b27f004e454aca81b0480209cce5081ec52390)
-    local path: file1 (flags "")
-    ancestor path: file1 (node 2ed2a3912a0b24502043eae84ee4b279c18b90dd)
-    other path: file1 (node 6f4310b00b9a147241b071a60c28a650827fb03d)
-  file extras: file2 (ancestorlinknode = 99726c03216e233810a2564cbc0adfe395007eac)
-  file: file2 (record type "F", state "u", hash cb99b709a1978bd205ab9dfd4c5aaa1fc91c7523)
-    local path: file2 (flags "")
-    ancestor path: file2 (node 2ed2a3912a0b24502043eae84ee4b279c18b90dd)
-    other path: file2 (node 6f4310b00b9a147241b071a60c28a650827fb03d)
-  unrecognized entry: X	mandatory record
+  abort: unsupported merge state records: X
+  (see https://mercurial-scm.org/wiki/MergeStateRecords for more information)
+  [255]
   $ hg resolve -l
   abort: unsupported merge state records: X
   (see https://mercurial-scm.org/wiki/MergeStateRecords for more information)