changeset 42926:34ed651ba7e4

cleanup: fix leakage of dirstate._map to client code We already had proper accessors for most of the behavior of dirstate._map that callers cared about exposed in the actual dirstate class as public methods. Sigh. There are two remaining privacy violations in the codebase after this change: 1) In the perf extension, which I suspect has to stick around because it's really testing the dirstate implementation directly 2) In largefiles, where we deal with standins and mutating status. Looking at this, I _strongly_ suspect a formal dirstate interface would allow this to work via composition instead of inheritance and monkeypatching. Fortunately, such wins are a part of my motivation for this work. I anticipate we'll come back to this in due time. Differential Revision: https://phab.mercurial-scm.org/D6837
author Augie Fackler <augie@google.com>
date Tue, 10 Sep 2019 09:41:58 -0400
parents 9fd7710d9ae2
children d459cd8ea42d
files hgext/largefiles/reposetup.py mercurial/debugcommands.py mercurial/scmutil.py
diffstat 3 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/reposetup.py	Sun Sep 08 20:26:36 2019 -0400
+++ b/hgext/largefiles/reposetup.py	Tue Sep 10 09:41:58 2019 -0400
@@ -234,7 +234,7 @@
                     result[2] = [f for f in result[2]
                                  if f not in lfdirstate]
 
-                    lfiles = set(lfdirstate._map)
+                    lfiles = set(lfdirstate)
                     # Unknown files
                     result[4] = set(result[4]).difference(lfiles)
                     # Ignored files
--- a/mercurial/debugcommands.py	Sun Sep 08 20:26:36 2019 -0400
+++ b/mercurial/debugcommands.py	Tue Sep 10 09:41:58 2019 -0400
@@ -751,7 +751,7 @@
         keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
     else:
         keyfunc = None # sort by filename
-    for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
+    for file_, ent in sorted(repo.dirstate.iteritems(), key=keyfunc):
         if ent[3] == -1:
             timestr = 'unset               '
         elif nodates:
--- a/mercurial/scmutil.py	Sun Sep 08 20:26:36 2019 -0400
+++ b/mercurial/scmutil.py	Tue Sep 10 09:41:58 2019 -0400
@@ -319,7 +319,7 @@
     def __init__(self, ui, abort, dirstate):
         self._ui = ui
         self._abort = abort
-        allfiles = '\0'.join(dirstate._map)
+        allfiles = '\0'.join(dirstate)
         self._loweredfiles = set(encoding.lower(allfiles).split('\0'))
         self._dirstate = dirstate
         # The purpose of _newfiles is so that we don't complain about