[Updated] D8919: mergestate: use collections.defaultdict(dict) for _stateextras

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Sat Aug 22 23:32:32 UTC 2020


Closed by commit rHGede4c121239e: mergestate: use collections.defaultdict(dict) for _stateextras (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/D8919?vs=22391&id=22422

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

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

AFFECTED FILES
  mercurial/mergestate.py

CHANGE DETAILS

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -1,5 +1,6 @@
 from __future__ import absolute_import
 
+import collections
 import errno
 import shutil
 import struct
@@ -194,7 +195,7 @@
 
     def reset(self, node=None, other=None, labels=None):
         self._state = {}
-        self._stateextras = {}
+        self._stateextras = collections.defaultdict(dict)
         self._local = None
         self._other = None
         self._labels = labels
@@ -220,7 +221,7 @@
         of on disk file.
         """
         self._state = {}
-        self._stateextras = {}
+        self._stateextras = collections.defaultdict(dict)
         self._local = None
         self._other = None
         for var in ('localctx', 'otherctx'):
@@ -626,7 +627,7 @@
                 yield f
 
     def extras(self, filename):
-        return self._stateextras.setdefault(filename, {})
+        return self._stateextras[filename]
 
     def _resolve(self, preresolve, dfile, wctx):
         """rerun merge process for file path `dfile`.



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


More information about the Mercurial-patches mailing list