changeset 45715:0428978bca22

mergestate: add `allextras()` to get all extras `extras()` can only be used for getting extra for a file. However at couple of places in code, we wanted to iterate over all the extras stored with the mergestate and they were accessing the private `_stateextras`. We add a new function for this. Differential Revision: https://phab.mercurial-scm.org/D9190
author Pulkit Goyal <7895pulkit@gmail.com>
date Sat, 10 Oct 2020 12:43:04 +0530
parents ecf6d7aa874b
children 9628d3cd9d13
files mercurial/commit.py mercurial/debugcommands.py mercurial/mergestate.py
diffstat 3 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commit.py	Tue Oct 06 19:11:34 2020 +0530
+++ b/mercurial/commit.py	Sat Oct 10 12:43:04 2020 +0530
@@ -155,7 +155,7 @@
     copy_sd = repo.filecopiesmode == b'changeset-sidedata'
     if copy_sd and len(ctx.parents()) > 1:
         if ms.active():
-            for fname in sorted(ms._stateextras.keys()):
+            for fname in sorted(ms.allextras().keys()):
                 might_removed = ms.extras(fname).get(b'merge-removal-candidate')
                 if might_removed == b'yes':
                     if fname in ctx:
--- a/mercurial/debugcommands.py	Tue Oct 06 19:11:34 2020 +0530
+++ b/mercurial/debugcommands.py	Sat Oct 10 12:43:04 2020 +0530
@@ -2107,7 +2107,7 @@
     fm_files.end()
 
     fm_extras = fm.nested(b'extras')
-    for f, d in sorted(pycompat.iteritems(ms._stateextras)):
+    for f, d in sorted(pycompat.iteritems(ms.allextras())):
         if f in ms:
             # If file is in mergestate, we have already processed it's extras
             continue
--- a/mercurial/mergestate.py	Tue Oct 06 19:11:34 2020 +0530
+++ b/mercurial/mergestate.py	Sat Oct 10 12:43:04 2020 +0530
@@ -306,7 +306,12 @@
             ):
                 yield f
 
+    def allextras(self):
+        """ return all extras information stored with the mergestate """
+        return self._stateextras
+
     def extras(self, filename):
+        """ return extras stored with the mergestate for the given filename """
         return self._stateextras[filename]
 
     def _resolve(self, preresolve, dfile, wctx):