Patchwork D8817: merge: move conversion of file-key dict to action-key dict in mergeresult

login
register
mail settings
Submitter phabricator
Date July 25, 2020, 9:59 a.m.
Message ID <differential-rev-PHID-DREV-iy5j3o2l2f3tquo7zczt-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46888/
State Superseded
Headers show

Comments

phabricator - July 25, 2020, 9:59 a.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Initially the actions dict which we get has file has keys, but later we want a
  dict which has actions as keys. This patch moves code computing that to
  mergeresult class as that's where it should be anyway.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8817

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -578,6 +578,19 @@ 
     def commitinfo(self):
         return self._commitinfo
 
+    @property
+    def actionsdict(self):
+        """ returns a dictionary of actions to be perfomed with action as key
+        and a list of files and related arguments as values """
+        # Convert to dictionary-of-lists format
+        actions = emptyactions()
+        for f, (m, args, msg) in pycompat.iteritems(self._actions):
+            if m not in actions:
+                actions[m] = []
+            actions[m].append((f, args, msg))
+
+        return actions
+
     def setactions(self, actions):
         self._actions = actions
 
@@ -1821,8 +1834,6 @@ 
             mergeforce=mergeforce,
         )
 
-        actionbyfile = mresult.actions
-
         if updatecheck == UPDATECHECK_NO_CONFLICT:
             if mresult.hasconflicts():
                 msg = _(b"conflicting changes")
@@ -1832,9 +1843,9 @@ 
         # Prompt and create actions. Most of this is in the resolve phase
         # already, but we can't handle .hgsubstate in filemerge or
         # subrepoutil.submerge yet so we have to keep prompting for it.
-        if b'.hgsubstate' in actionbyfile:
+        if b'.hgsubstate' in mresult.actions:
             f = b'.hgsubstate'
-            m, args, msg = actionbyfile[f]
+            m, args, msg = mresult.actions[f]
             prompts = filemerge.partextras(labels)
             prompts[b'f'] = f
             if m == mergestatemod.ACTION_CHANGED_DELETED:
@@ -1847,19 +1858,19 @@ 
                     % prompts,
                     0,
                 ):
-                    actionbyfile[f] = (
+                    mresult.actions[f] = (
                         mergestatemod.ACTION_REMOVE,
                         None,
                         b'prompt delete',
                     )
                 elif f in p1:
-                    actionbyfile[f] = (
+                    mresult.actions[f] = (
                         mergestatemod.ACTION_ADD_MODIFIED,
                         None,
                         b'prompt keep',
                     )
                 else:
-                    actionbyfile[f] = (
+                    mresult.actions[f] = (
                         mergestatemod.ACTION_ADD,
                         None,
                         b'prompt keep',
@@ -1879,20 +1890,16 @@ 
                     )
                     == 0
                 ):
-                    actionbyfile[f] = (
+                    mresult.actions[f] = (
                         mergestatemod.ACTION_GET,
                         (flags, False),
                         b'prompt recreating',
                     )
                 else:
-                    del actionbyfile[f]
+                    del mresult.actions[f]
 
         # Convert to dictionary-of-lists format
-        actions = emptyactions()
-        for f, (m, args, msg) in pycompat.iteritems(actionbyfile):
-            if m not in actions:
-                actions[m] = []
-            actions[m].append((f, args, msg))
+        actions = mresult.actionsdict
 
         if not util.fscasesensitive(repo.path):
             # check collision between files only in p2 for clean update