diff mercurial/util.py @ 43523:c21aca51b392

utils: move the `dirs` definition in pathutil (API) Before this change, the `dirs` class was accessible through the `mercurial.util` module. That module is expected to stay free of scm specific content. The `pathutil` destination has been selection by Martin von Zweigbergk. This work is part of a refactoring to unify the revlog index and the nodemap. This unification prepare the use of a persistent nodemap. Differential Revision: https://phab.mercurial-scm.org/D7311
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 06 Nov 2019 14:13:19 +0100
parents 9f70512ae2cf
children 0b7733719d21
line wrap: on
line diff
--- a/mercurial/util.py	Wed Oct 23 12:15:42 2019 -0700
+++ b/mercurial/util.py	Wed Nov 06 14:13:19 2019 +0100
@@ -57,11 +57,8 @@
     stringutil,
 )
 
-rustdirs = policy.importrust('dirstate', 'Dirs')
-
 base85 = policy.importmod('base85')
 osutil = policy.importmod('osutil')
-parsers = policy.importmod('parsers')
 
 b85decode = base85.b85decode
 b85encode = base85.b85encode
@@ -3494,58 +3491,6 @@
     f.flush()
 
 
-class dirs(object):
-    '''a multiset of directory names from a dirstate or manifest'''
-
-    def __init__(self, map, skip=None):
-        self._dirs = {}
-        addpath = self.addpath
-        if isinstance(map, dict) and skip is not None:
-            for f, s in pycompat.iteritems(map):
-                if s[0] != skip:
-                    addpath(f)
-        elif skip is not None:
-            raise error.ProgrammingError(
-                b"skip character is only supported with a dict source"
-            )
-        else:
-            for f in map:
-                addpath(f)
-
-    def addpath(self, path):
-        dirs = self._dirs
-        for base in finddirs(path):
-            if base.endswith(b'/'):
-                raise ValueError(
-                    "found invalid consecutive slashes in path: %r" % base
-                )
-            if base in dirs:
-                dirs[base] += 1
-                return
-            dirs[base] = 1
-
-    def delpath(self, path):
-        dirs = self._dirs
-        for base in finddirs(path):
-            if dirs[base] > 1:
-                dirs[base] -= 1
-                return
-            del dirs[base]
-
-    def __iter__(self):
-        return iter(self._dirs)
-
-    def __contains__(self, d):
-        return d in self._dirs
-
-
-if safehasattr(parsers, 'dirs'):
-    dirs = parsers.dirs
-
-if rustdirs is not None:
-    dirs = rustdirs
-
-
 def finddirs(path):
     pos = path.rfind(b'/')
     while pos != -1: