Show More
@@ -891,6 +891,42 b' class filecache(object):' | |||||
891 | except KeyError: |
|
891 | except KeyError: | |
892 | raise AttributeError(self.name) |
|
892 | raise AttributeError(self.name) | |
893 |
|
893 | |||
|
894 | class dirs(object): | |||
|
895 | '''a multiset of directory names from a dirstate or manifest''' | |||
|
896 | ||||
|
897 | def __init__(self, map, skip=None): | |||
|
898 | self._dirs = {} | |||
|
899 | addpath = self.addpath | |||
|
900 | if util.safehasattr(map, 'iteritems') and skip is not None: | |||
|
901 | for f, s in map.iteritems(): | |||
|
902 | if s[0] != skip: | |||
|
903 | addpath(f) | |||
|
904 | else: | |||
|
905 | for f in map: | |||
|
906 | addpath(f) | |||
|
907 | ||||
|
908 | def addpath(self, path): | |||
|
909 | dirs = self._dirs | |||
|
910 | for base in finddirs(path): | |||
|
911 | if base in dirs: | |||
|
912 | dirs[base] += 1 | |||
|
913 | return | |||
|
914 | dirs[base] = 1 | |||
|
915 | ||||
|
916 | def delpath(self, path): | |||
|
917 | dirs = self._dirs | |||
|
918 | for base in finddirs(path): | |||
|
919 | if dirs[base] > 1: | |||
|
920 | dirs[base] -= 1 | |||
|
921 | return | |||
|
922 | del dirs[base] | |||
|
923 | ||||
|
924 | def __iter__(self): | |||
|
925 | return self._dirs.iterkeys() | |||
|
926 | ||||
|
927 | def __contains__(self, d): | |||
|
928 | return d in self._dirs | |||
|
929 | ||||
894 | def finddirs(path): |
|
930 | def finddirs(path): | |
895 | pos = path.rfind('/') |
|
931 | pos = path.rfind('/') | |
896 | while pos != -1: |
|
932 | while pos != -1: |
General Comments 0
You need to be logged in to leave comments.
Login now