Comments
Patch
@@ -119,3 +119,39 @@ def pack_dirstate(dmap, copymap, pl, now
write(e)
write(f)
return cs.getvalue()
+
+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 util.safehasattr(map, 'iteritems') and skip is not None:
+ for f, s in map.iteritems():
+ if s[0] != skip:
+ addpath(f)
+ else:
+ for f in map:
+ addpath(f)
+
+ def addpath(self, path):
+ dirs = self._dirs
+ for base in util.finddirs(path):
+ if base in dirs:
+ dirs[base] += 1
+ return
+ dirs[base] = 1
+
+ def delpath(self, path):
+ dirs = self._dirs
+ for base in util.finddirs(path):
+ if dirs[base] > 1:
+ dirs[base] -= 1
+ return
+ del dirs[base]
+
+ def __iter__(self):
+ return self._dirs.iterkeys()
+
+ def __contains__(self, d):
+ return d in self._dirs
@@ -924,41 +924,4 @@ class filecache(object):
except KeyError:
raise AttributeError(self.name)
-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 util.safehasattr(map, 'iteritems') and skip is not None:
- for f, s in map.iteritems():
- if s[0] != skip:
- addpath(f)
- else:
- for f in map:
- addpath(f)
-
- def addpath(self, path):
- dirs = self._dirs
- for base in util.finddirs(path):
- if base in dirs:
- dirs[base] += 1
- return
- dirs[base] = 1
-
- def delpath(self, path):
- dirs = self._dirs
- for base in util.finddirs(path):
- if dirs[base] > 1:
- dirs[base] -= 1
- return
- del dirs[base]
-
- def __iter__(self):
- return self._dirs.iterkeys()
-
- def __contains__(self, d):
- return d in self._dirs
-
-if util.safehasattr(parsers, 'dirs'):
- dirs = parsers.dirs
+dirs = parsers.dirs