From patchwork Sat Oct 10 08:41:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D9190: mergestate: make filename argument optional in _mergestate_base.extras() From: phabricator X-Patchwork-Id: 47431 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Sat, 10 Oct 2020 08:41:18 +0000 pulkit created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY 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. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D9190 AFFECTED FILES mercurial/commit.py mercurial/debugcommands.py mercurial/mergestate.py CHANGE DETAILS To: pulkit, #hg-reviewers Cc: mercurial-patches, mercurial-devel diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py --- a/mercurial/mergestate.py +++ b/mercurial/mergestate.py @@ -305,7 +305,12 @@ ): yield f - def extras(self, filename): + def extras(self, filename=None): + """ return extras stored with the mergestate + + if filename is passed, extras for that file is only returned """ + if filename is None: + return self._stateextras return self._stateextras[filename] def _resolve(self, preresolve, dfile, wctx): diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -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.extras())): if f in ms: # If file is in mergestate, we have already processed it's extras continue diff --git a/mercurial/commit.py b/mercurial/commit.py --- a/mercurial/commit.py +++ b/mercurial/commit.py @@ -147,7 +147,7 @@ # some cases. ms = mergestate.mergestate.read(repo) if ms.active(): - for fname in sorted(ms._stateextras.keys()): + for fname in sorted(ms.extras().keys()): might_removed = ms.extras(fname).get(b'merge-removal-candidate') if might_removed == b'yes': if fname in ctx: