Patchwork D8825: merge: pass mergeresult instead of actions in _checkunknownfiles() (API)

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

Comments

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/remotefilelog/__init__.py
  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
@@ -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
diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py
--- a/hgext/remotefilelog/__init__.py
+++ b/hgext/remotefilelog/__init__.py
@@ -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