Patchwork [1,of,5] debugmergestate: show extras for files which are not in mergestate

login
register
mail settings
Submitter Pulkit Goyal
Date Sept. 11, 2020, 7:05 a.m.
Message ID <c196dc7f6cf18e32a864.1599807929@workspace>
Download mbox | patch
Permalink /patch/47132/
State Accepted
Headers show

Comments

Pulkit Goyal - Sept. 11, 2020, 7:05 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1598275759 -19800
#      Mon Aug 24 18:59:19 2020 +0530
# Node ID c196dc7f6cf18e32a8646ae7cd0b08014f8ffbdf
# Parent  c889e1fddc190ff73265939965706b2dd0bfec3b
# EXP-Topic merge-newnode
debugmergestate: show extras for files which are not in mergestate

With recent changes and future changes, we will like to store extras information
about files which were merged automatically. Hence, we will have merge extras
for files which are not in the mergestate.

Differential Revision: https://phab.mercurial-scm.org/D8942
Yuya Nishihara - Sept. 12, 2020, 2:51 a.m.
On Fri, 11 Sep 2020 12:35:29 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1598275759 -19800
> #      Mon Aug 24 18:59:19 2020 +0530
> # Node ID c196dc7f6cf18e32a8646ae7cd0b08014f8ffbdf
> # Parent  c889e1fddc190ff73265939965706b2dd0bfec3b
> # EXP-Topic merge-newnode
> debugmergestate: show extras for files which are not in mergestate

Queued 1, 3, 4, thanks.

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2016,6 +2016,7 @@  def debugmergestate(ui, repo, *args, **o
             b'")}'
             b'{extras % "  extra: {key} = {value}\n"}'
             b'"}'
+            b'{extras % "extra: {file} ({key} = {value})\n"}'
         )
 
     ms = mergestatemod.mergestate.read(repo)
@@ -2069,6 +2070,18 @@  def debugmergestate(ui, repo, *args, **o
 
     fm_files.end()
 
+    fm_extras = fm.nested(b'extras')
+    for f, d in sorted(pycompat.iteritems(ms._stateextras)):
+        if f in ms:
+            # If file is in mergestate, we have already processed it's extras
+            continue
+        for k, v in pycompat.iteritems(d):
+            fm_extras.startitem()
+            fm_extras.data(file=f)
+            fm_extras.data(key=k)
+            fm_extras.data(value=v)
+    fm_extras.end()
+
     fm.end()
 
 
diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -328,6 +328,7 @@  test json output
   [
    {
     "commits": [{"label": "working copy", "name": "local", "node": "57653b9f834a4493f7240b0681efcb9ae7cab745"}, {"label": "merge rev", "name": "other", "node": "dc77451844e37f03f5c559e3b8529b2b48d381d1"}],
+    "extras": [],
     "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"}]
    }
   ]