Patchwork D8878: mergeresult: add sort argument to getactions() method

login
register
mail settings
Submitter phabricator
Date Aug. 5, 2020, 8:52 a.m.
Message ID <differential-rev-PHID-DREV-jgexp6od4p2drfwbwqwy-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46976/
State Superseded
Headers show

Comments

phabricator - Aug. 5, 2020, 8:52 a.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This will be used in next patch.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -604,15 +604,23 @@ 
         del self._filemapping[filename]
         del self._actionmapping[action][filename]
 
-    def getactions(self, actions):
+    def getactions(self, actions, sort=False):
         """ get list of files which are marked with these actions
+        if sort is true, files for each action is sorted and then added
 
         Returns a list of tuple of form (filename, data, message)
         """
         res = []
         for a in actions:
-            for f, (args, msg) in pycompat.iteritems(self._actionmapping[a]):
-                res.append((f, args, msg))
+            if sort:
+                for f in sorted(self._actionmapping[a]):
+                    args, msg = self._actionmapping[a][f]
+                    res.append((f, args, msg))
+            else:
+                for f, (args, msg) in pycompat.iteritems(
+                    self._actionmapping[a]
+                ):
+                    res.append((f, args, msg))
         return res
 
     @property