merge: pass mergeresult instead of actions in _checkunknownfiles() (API)
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 24 Jul 2020 17:57:23 +0530
changeset 45287 4ad6c4e9e35f
parent 45286 00e9c5edcd58
child 45288 3f5ac87ae10f
merge: pass mergeresult instead of actions in _checkunknownfiles() (API) Differential Revision: https://phab.mercurial-scm.org/D8825
hgext/remotefilelog/__init__.py
mercurial/merge.py
--- a/hgext/remotefilelog/__init__.py	Fri Jul 24 17:52:33 2020 +0530
+++ b/hgext/remotefilelog/__init__.py	Fri Jul 24 17:57:23 2020 +0530
@@ -492,11 +492,11 @@
 
 
 # Prefetch merge checkunknownfiles
-def checkunknownfiles(orig, repo, wctx, mctx, force, actions, *args, **kwargs):
+def checkunknownfiles(orig, repo, wctx, mctx, force, mresult, *args, **kwargs):
     if isenabled(repo):
         files = []
         sparsematch = repo.maybesparsematch(mctx.rev())
-        for f, (m, actionargs, msg) in pycompat.iteritems(actions):
+        for f, (m, actionargs, msg) in pycompat.iteritems(mresult.actions):
             if sparsematch and not sparsematch(f):
                 continue
             if m in (b'c', b'dc', b'cm'):
@@ -506,7 +506,7 @@
                 files.append((f2, hex(mctx.filenode(f2))))
         # batch fetch the needed files from the server
         repo.fileservice.prefetch(files)
-    return orig(repo, wctx, mctx, force, actions, *args, **kwargs)
+    return orig(repo, wctx, mctx, force, mresult, *args, **kwargs)
 
 
 # Prefetch files before status attempts to look at their size and contents
--- a/mercurial/merge.py	Fri Jul 24 17:52:33 2020 +0530
+++ b/mercurial/merge.py	Fri Jul 24 17:57:23 2020 +0530
@@ -126,7 +126,7 @@
         return None
 
 
-def _checkunknownfiles(repo, wctx, mctx, force, actions, mergeforce):
+def _checkunknownfiles(repo, wctx, mctx, force, mresult, mergeforce):
     """
     Considers any actions that care about the presence of conflicting unknown
     files. For some actions, the result is to abort; for others, it is to
@@ -150,7 +150,7 @@
                 warnconflicts.update(conflicts)
 
         checkunknowndirs = _unknowndirschecker()
-        for f, (m, args, msg) in pycompat.iteritems(actions):
+        for f, (m, args, msg) in pycompat.iteritems(mresult.actions):
             if m in (
                 mergestatemod.ACTION_CREATED,
                 mergestatemod.ACTION_DELETED_CHANGED,
@@ -171,7 +171,7 @@
         collectconflicts(ignoredconflicts, ignoredconfig)
         collectconflicts(unknownconflicts, unknownconfig)
     else:
-        for f, (m, args, msg) in pycompat.iteritems(actions):
+        for f, (m, args, msg) in pycompat.iteritems(mresult.actions):
             if m == mergestatemod.ACTION_CREATED_MERGE:
                 fl2, anc = args
                 different = _checkunknownfile(repo, wctx, mctx, f)
@@ -193,13 +193,15 @@
                 #     don't like an abort happening in the middle of
                 #     merge.update.
                 if not different:
-                    actions[f] = (
+                    mresult.addfile(
+                        f,
                         mergestatemod.ACTION_GET,
                         (fl2, False),
                         b'remote created',
                     )
                 elif mergeforce or config == b'abort':
-                    actions[f] = (
+                    mresult.addfile(
+                        f,
                         mergestatemod.ACTION_MERGE,
                         (f, f, None, False, anc),
                         b'remote differs from untracked local',
@@ -209,7 +211,8 @@
                 else:
                     if config == b'warn':
                         warnconflicts.add(f)
-                    actions[f] = (
+                    mresult.addfile(
+                        f,
                         mergestatemod.ACTION_GET,
                         (fl2, True),
                         b'remote created',
@@ -238,7 +241,7 @@
         else:
             repo.ui.warn(_(b"%s: replacing untracked files in directory\n") % f)
 
-    for f, (m, args, msg) in pycompat.iteritems(actions):
+    for f, (m, args, msg) in pycompat.iteritems(mresult.actions):
         if m == mergestatemod.ACTION_CREATED:
             backup = (
                 f in fileconflicts
@@ -246,7 +249,7 @@
                 or any(p in pathconflicts for p in pathutil.finddirs(f))
             )
             (flags,) = args
-            actions[f] = (mergestatemod.ACTION_GET, (flags, backup), msg)
+            mresult.addfile(f, mergestatemod.ACTION_GET, (flags, backup), msg)
 
 
 def _forgetremoved(wctx, mctx, branchmerge):
@@ -1022,7 +1025,7 @@
             acceptremote,
             followcopies,
         )
-        _checkunknownfiles(repo, wctx, mctx, force, mresult.actions, mergeforce)
+        _checkunknownfiles(repo, wctx, mctx, force, mresult, mergeforce)
 
     else:  # only when merge.preferancestor=* - the default
         repo.ui.note(
@@ -1055,9 +1058,7 @@
                 followcopies,
                 forcefulldiff=True,
             )
-            _checkunknownfiles(
-                repo, wctx, mctx, force, mresult1.actions, mergeforce
-            )
+            _checkunknownfiles(repo, wctx, mctx, force, mresult1, mergeforce)
 
             # Track the shortest set of warning on the theory that bid
             # merge will correctly incorporate more information