Patchwork D450: filemerge: add wctx to all internal tools

login
register
mail settings
Submitter phabricator
Date Aug. 23, 2017, 9:28 p.m.
Message ID <527e5f84d22577a13a2eb7dfba4866d1@localhost.localdomain>
Download mbox | patch
Permalink /patch/23282/
State Not Applicable
Headers show

Comments

phabricator - Aug. 23, 2017, 9:28 p.m.
phillco updated this revision to Diff 1234.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D450?vs=1211&id=1234

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

AFFECTED FILES
  mercurial/filemerge.py
  mercurial/tagmerge.py

CHANGE DETAILS




To: phillco, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/tagmerge.py b/mercurial/tagmerge.py
--- a/mercurial/tagmerge.py
+++ b/mercurial/tagmerge.py
@@ -216,7 +216,7 @@ 
     # whole list of lr nodes
     return lrnodes + hrnodes[commonidx:]
 
-def merge(repo, fcd, fco, fca):
+def merge(repo, wctx, fcd, fco, fca):
     '''
     Merge the tags of two revisions, taking into account the base tags
     Try to minimize the diff between the merged tags and the first parent tags
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -238,7 +238,7 @@ 
                 util.writefile(file, newdata)
 
 @internaltool('prompt', nomerge)
-def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _iprompt(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
     """Asks the user which of the local `p1()` or the other `p2()` version to
     keep as the merged version."""
     ui = repo.ui
@@ -263,26 +263,26 @@ 
             choice = ['local', 'other', 'unresolved'][index]
 
         if choice == 'other':
-            return _iother(repo, mynode, orig, fcd, fco, fca, toolconf,
+            return _iother(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
                            labels)
         elif choice == 'local':
-            return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf,
+            return _ilocal(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
                            labels)
         elif choice == 'unresolved':
-            return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
+            return _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
                           labels)
     except error.ResponseExpected:
         ui.write("\n")
-        return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
+        return _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
                       labels)
 
 @internaltool('local', nomerge)
-def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _ilocal(repo, wtcx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
     """Uses the local `p1()` version of files as the merged version."""
     return 0, fcd.isabsent()
 
 @internaltool('other', nomerge)
-def _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _iother(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
     """Uses the other `p2()` version of files as the merged version."""
     if fco.isabsent():
         # local changed, remote deleted -- 'deleted' picked
@@ -294,7 +294,7 @@ 
     return 0, deleted
 
 @internaltool('fail', nomerge)
-def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
+def _ifail(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, labels=None):
     """
     Rather than attempting to merge files that were modified on both
     branches, it marks them as unresolved. The resolve command must be
@@ -362,7 +362,8 @@ 
         return False
     return True
 
-def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode):
+def _merge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files, labels,
+           mode):
     """
     Uses the internal non-interactive simple merge algorithm for merging
     files. It will fail if there are any conflicts and leave markers in
@@ -380,32 +381,35 @@ 
               _("warning: conflicts while merging %s! "
                 "(edit, then use 'hg resolve --mark')\n"),
               precheck=_mergecheck)
-def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _iunion(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+            labels=None):
     """
     Uses the internal non-interactive simple merge algorithm for merging
     files. It will use both left and right sides for conflict regions.
     No markers are inserted."""
-    return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
+    return _merge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
                   files, labels, 'union')
 
 @internaltool('merge', fullmerge,
               _("warning: conflicts while merging %s! "
                 "(edit, then use 'hg resolve --mark')\n"),
               precheck=_mergecheck)
-def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _imerge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+            labels=None):
     """
     Uses the internal non-interactive simple merge algorithm for merging
     files. It will fail if there are any conflicts and leave markers in
     the partially merged file. Markers will have two sections, one for each side
     of merge."""
-    return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
+    return _merge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
                   files, labels, 'merge')
 
 @internaltool('merge3', fullmerge,
               _("warning: conflicts while merging %s! "
                 "(edit, then use 'hg resolve --mark')\n"),
               precheck=_mergecheck)
-def _imerge3(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _imerge3(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+             labels=None):
     """
     Uses the internal non-interactive simple merge algorithm for merging
     files. It will fail if there are any conflicts and leave markers in
@@ -415,9 +419,10 @@ 
         labels = _defaultconflictlabels
     if len(labels) < 3:
         labels.append('base')
-    return _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels)
+    return _imerge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+                   labels)
 
-def _imergeauto(repo, mynode, orig, fcd, fco, fca, toolconf, files,
+def _imergeauto(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
                 labels=None, localorother=None):
     """
     Generic driver for _imergelocal and _imergeother
@@ -450,15 +455,17 @@ 
               _("automatic tag merging of %s failed! "
                 "(use 'hg resolve --tool :merge' or another merge "
                 "tool of your choice)\n"))
-def _itagmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _itagmerge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+               labels=None):
     """
     Uses the internal tag merge algorithm (experimental).
     """
-    success, status = tagmerge.merge(repo, fcd, fco, fca)
+    success, status = tagmerge.merge(repo, wctx, fcd, fco, fca)
     return success, status, False
 
 @internaltool('dump', fullmerge)
-def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _idump(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+           labels=None):
     """
     Creates three versions of the files to merge, containing the
     contents of local, other and base. These files can then be used to
@@ -480,15 +487,16 @@ 
     return False, 1, False
 
 @internaltool('forcedump', mergeonly)
-def _forcedump(repo, mynode, orig, fcd, fco, fca, toolconf, files,
-                labels=None):
+def _forcedump(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+               labels=None):
     """
     Creates three versions of the files as same as :dump, but omits premerge.
     """
-    return _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files,
-                labels=labels)
+    return _idump(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+                  labels=labels)
 
-def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
+def _xmerge(repo, wctx, mynode, orig, fcd, fco, fca, toolconf, files,
+            labels=None):
     tool, toolpath, binary, symlink = toolconf
     if fcd.isabsent() or fco.isabsent():
         repo.ui.warn(_('warning: %s cannot merge change/delete conflict '
@@ -639,7 +647,8 @@ 
     toolconf = tool, toolpath, binary, symlink
 
     if mergetype == nomerge:
-        r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
+        r, deleted = func(repo, wctx, mynode, orig, fcd, fco, fca, toolconf,
+                          labels)
         return True, r, deleted
 
     if premerge:
@@ -680,7 +689,7 @@ 
             # complete if premerge successful (r is 0)
             return not r, r, False
 
-        needcheck, r, deleted = func(repo, mynode, orig, fcd, fco, fca,
+        needcheck, r, deleted = func(repo, wctx, mynode, orig, fcd, fco, fca,
                                      toolconf, files, labels=labels)
 
         if needcheck:
@@ -729,7 +738,8 @@ 
     return r
 
 def premerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
-    return _filemerge(True, repo, mynode, orig, fcd, fco, fca, labels=labels)
+    return _filemerge(True, repo, wctx, mynode, orig, fcd, fco, fca,
+                      labels=labels)
 
 def filemerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
     return _filemerge(False, repo, wctx, mynode, orig, fcd, fco, fca,