Patchwork [V2] mergestate: make filename argument optional in _mergestate_base.extras()

login
register
mail settings
Submitter Pulkit Goyal
Date Oct. 14, 2020, 8:15 a.m.
Message ID <16290c7c8eea7f859aad.1602663355@workspace>
Download mbox | patch
Permalink /patch/47454/
State New
Headers show

Comments

Pulkit Goyal - Oct. 14, 2020, 8:15 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1602313984 -19800
#      Sat Oct 10 12:43:04 2020 +0530
# Node ID 16290c7c8eea7f859aade5c8c2f9af357da97164
# Parent  04de8a1ec08f380fda794dda3b3f2ed1ccfd442b
# EXP-Topic merge-newnode-final
mergestate: make filename argument optional in _mergestate_base.extras()

Earlier `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`.

Now, if filename is not passed, we return all the extras.

Differential Revision: https://phab.mercurial-scm.org/D9190
Pulkit Goyal - Oct. 14, 2020, 8:18 a.m.
On Wed, Oct 14, 2020 at 1:46 PM Pulkit Goyal <7895pulkit@gmail.com> wrote:
>
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1602313984 -19800
> #      Sat Oct 10 12:43:04 2020 +0530
> # Node ID 16290c7c8eea7f859aade5c8c2f9af357da97164
> # Parent  04de8a1ec08f380fda794dda3b3f2ed1ccfd442b
> # EXP-Topic merge-newnode-final
> mergestate: make filename argument optional in _mergestate_base.extras()
>
> Earlier `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`.
>
> Now, if filename is not passed, we return all the extras.
>
> Differential Revision: https://phab.mercurial-scm.org/D9190

Kindly ignore this. Forgot to update commit message before sending.
Sent another one with updated commit message.

Patch

diff --git a/mercurial/commit.py b/mercurial/commit.py
--- a/mercurial/commit.py
+++ b/mercurial/commit.py
@@ -155,7 +155,7 @@  def _get_salvaged(repo, ms, ctx):
     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:
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2107,7 +2107,7 @@  def debugmergestate(ui, repo, *args, **o
     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
diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -305,7 +305,12 @@  class _mergestate_base(object):
             ):
                 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):