[Updated] D8888: mergeresult: introduce filemap() which yields filename based mapping

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Sat Aug 8 16:57:46 UTC 2020


Closed by commit rHG3c783ff08d40: mergeresult: introduce filemap() which yields filename based mapping (authored by pulkit).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8888?vs=22309&id=22346

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8888/new/

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

AFFECTED FILES
  hgext/convert/hg.py
  hgext/remotefilelog/__init__.py
  mercurial/merge.py
  mercurial/sparse.py

CHANGE DETAILS

diff --git a/mercurial/sparse.py b/mercurial/sparse.py
--- a/mercurial/sparse.py
+++ b/mercurial/sparse.py
@@ -388,7 +388,7 @@
         sparsematch = matcher(repo, [mctx.rev()])
 
     temporaryfiles = []
-    for file, action in pycompat.iteritems(mresult.actions):
+    for file, action in mresult.filemap():
         type, args, msg = action
         files.add(file)
         if sparsematch(file):
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -541,7 +541,7 @@
     }
     # We mutate the items in the dict during iteration, so iterate
     # over a copy.
-    for f, action in list(mresult.actions.items()):
+    for f, action in mresult.filemap():
         if narrowmatch(f):
             pass
         elif not branchmerge:
@@ -668,9 +668,13 @@
 
         return sum(len(self._actionmapping[a]) for a in actions)
 
-    @property
-    def actions(self):
-        return self._filemapping
+    def filemap(self, sort=False):
+        if sorted:
+            for key, val in sorted(pycompat.iteritems(self._filemapping)):
+                yield key, val
+        else:
+            for key, val in pycompat.iteritems(self._filemapping):
+                yield key, val
 
     @property
     def diverge(self):
@@ -1137,7 +1141,7 @@
             ):
                 renamedelete = mresult1.renamedelete
 
-            for f, a in sorted(pycompat.iteritems(mresult1.actions)):
+            for f, a in mresult1.filemap(sort=True):
                 m, args, msg = a
                 repo.ui.debug(b' %s: %s -> %s\n' % (f, msg, m))
                 if f in fbids:
diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py
--- a/hgext/remotefilelog/__init__.py
+++ b/hgext/remotefilelog/__init__.py
@@ -497,7 +497,7 @@
     if isenabled(repo):
         files = []
         sparsematch = repo.maybesparsematch(mctx.rev())
-        for f, (m, actionargs, msg) in pycompat.iteritems(mresult.actions):
+        for f, (m, actionargs, msg) in mresult.filemap():
             if sparsematch and not sparsematch(f):
                 continue
             if m in (
diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -229,7 +229,7 @@
             followcopies=False,
         )
 
-        for file, (action, info, msg) in pycompat.iteritems(mresult.actions):
+        for file, (action, info, msg) in mresult.filemap():
             if source.targetfilebelongstosource(file):
                 # If the file belongs to the source repo, ignore the p2
                 # since it will be covered by the existing fileset.



To: pulkit, #hg-reviewers, indygreg
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200808/0ccbeb3a/attachment-0002.html>


More information about the Mercurial-patches mailing list