Show More
@@ -2328,7 +2328,7 b' def remove(ui, repo, m, prefix, after, f' | |||||
2328 | % join(subpath)) |
|
2328 | % join(subpath)) | |
2329 |
|
2329 | |||
2330 | # warn about failure to delete explicit files/dirs |
|
2330 | # warn about failure to delete explicit files/dirs | |
2331 |
deleteddirs = |
|
2331 | deleteddirs = util.dirs(deleted) | |
2332 | for f in m.files(): |
|
2332 | for f in m.files(): | |
2333 | def insubrepo(): |
|
2333 | def insubrepo(): | |
2334 | for subpath in wctx.substate: |
|
2334 | for subpath in wctx.substate: |
@@ -139,7 +139,7 b' class dirstate(object):' | |||||
139 |
|
139 | |||
140 | @propertycache |
|
140 | @propertycache | |
141 | def _dirs(self): |
|
141 | def _dirs(self): | |
142 |
return |
|
142 | return util.dirs(self._map, 'r') | |
143 |
|
143 | |||
144 | def dirs(self): |
|
144 | def dirs(self): | |
145 | return self._dirs |
|
145 | return self._dirs | |
@@ -381,7 +381,7 b' class dirstate(object):' | |||||
381 | if f in self._dirs: |
|
381 | if f in self._dirs: | |
382 | raise util.Abort(_('directory %r already in dirstate') % f) |
|
382 | raise util.Abort(_('directory %r already in dirstate') % f) | |
383 | # shadows |
|
383 | # shadows | |
384 |
for d in |
|
384 | for d in util.finddirs(f): | |
385 | if d in self._dirs: |
|
385 | if d in self._dirs: | |
386 | break |
|
386 | break | |
387 | if d in self._map and self[d] != 'r': |
|
387 | if d in self._map and self[d] != 'r': | |
@@ -601,7 +601,7 b' class dirstate(object):' | |||||
601 | return False |
|
601 | return False | |
602 | if self._ignore(f): |
|
602 | if self._ignore(f): | |
603 | return True |
|
603 | return True | |
604 |
for p in |
|
604 | for p in util.finddirs(f): | |
605 | if self._ignore(p): |
|
605 | if self._ignore(p): | |
606 | return True |
|
606 | return True | |
607 | return False |
|
607 | return False | |
@@ -698,7 +698,7 b' class dirstate(object):' | |||||
698 | results[nf] = None |
|
698 | results[nf] = None | |
699 | else: # does it match a missing directory? |
|
699 | else: # does it match a missing directory? | |
700 | if alldirs is None: |
|
700 | if alldirs is None: | |
701 |
alldirs = |
|
701 | alldirs = util.dirs(dmap) | |
702 | if nf in alldirs: |
|
702 | if nf in alldirs: | |
703 | if matchedir: |
|
703 | if matchedir: | |
704 | matchedir(nf) |
|
704 | matchedir(nf) |
@@ -6,7 +6,7 b'' | |||||
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from i18n import _ |
|
8 | from i18n import _ | |
9 |
import mdiff, parsers, error, revlog, util |
|
9 | import mdiff, parsers, error, revlog, util | |
10 | import array, struct |
|
10 | import array, struct | |
11 | import os |
|
11 | import os | |
12 |
|
12 | |||
@@ -217,7 +217,7 b' class manifestdict(object):' | |||||
217 |
|
217 | |||
218 | @propertycache |
|
218 | @propertycache | |
219 | def _dirs(self): |
|
219 | def _dirs(self): | |
220 |
return |
|
220 | return util.dirs(self) | |
221 |
|
221 | |||
222 | def dirs(self): |
|
222 | def dirs(self): | |
223 | return self._dirs |
|
223 | return self._dirs | |
@@ -561,7 +561,7 b' class treemanifest(object):' | |||||
561 |
|
561 | |||
562 | @propertycache |
|
562 | @propertycache | |
563 | def _alldirs(self): |
|
563 | def _alldirs(self): | |
564 |
return |
|
564 | return util.dirs(self) | |
565 |
|
565 | |||
566 | def dirs(self): |
|
566 | def dirs(self): | |
567 | return self._alldirs |
|
567 | return self._alldirs |
@@ -7,7 +7,7 b'' | |||||
7 |
|
7 | |||
8 | from i18n import _ |
|
8 | from i18n import _ | |
9 | from mercurial.node import nullrev |
|
9 | from mercurial.node import nullrev | |
10 |
import util, error, osutil, revset, similar, encoding, phases |
|
10 | import util, error, osutil, revset, similar, encoding, phases | |
11 | import pathutil |
|
11 | import pathutil | |
12 | import match as matchmod |
|
12 | import match as matchmod | |
13 | import os, errno, re, glob, tempfile |
|
13 | import os, errno, re, glob, tempfile | |
@@ -1083,48 +1083,3 b' class filecache(object):' | |||||
1083 | del obj.__dict__[self.name] |
|
1083 | del obj.__dict__[self.name] | |
1084 | except KeyError: |
|
1084 | except KeyError: | |
1085 | raise AttributeError(self.name) |
|
1085 | raise AttributeError(self.name) | |
1086 |
|
||||
1087 | class dirs(object): |
|
|||
1088 | '''a multiset of directory names from a dirstate or manifest''' |
|
|||
1089 |
|
||||
1090 | def __init__(self, map, skip=None): |
|
|||
1091 | self._dirs = {} |
|
|||
1092 | addpath = self.addpath |
|
|||
1093 | if util.safehasattr(map, 'iteritems') and skip is not None: |
|
|||
1094 | for f, s in map.iteritems(): |
|
|||
1095 | if s[0] != skip: |
|
|||
1096 | addpath(f) |
|
|||
1097 | else: |
|
|||
1098 | for f in map: |
|
|||
1099 | addpath(f) |
|
|||
1100 |
|
||||
1101 | def addpath(self, path): |
|
|||
1102 | dirs = self._dirs |
|
|||
1103 | for base in finddirs(path): |
|
|||
1104 | if base in dirs: |
|
|||
1105 | dirs[base] += 1 |
|
|||
1106 | return |
|
|||
1107 | dirs[base] = 1 |
|
|||
1108 |
|
||||
1109 | def delpath(self, path): |
|
|||
1110 | dirs = self._dirs |
|
|||
1111 | for base in finddirs(path): |
|
|||
1112 | if dirs[base] > 1: |
|
|||
1113 | dirs[base] -= 1 |
|
|||
1114 | return |
|
|||
1115 | del dirs[base] |
|
|||
1116 |
|
||||
1117 | def __iter__(self): |
|
|||
1118 | return self._dirs.iterkeys() |
|
|||
1119 |
|
||||
1120 | def __contains__(self, d): |
|
|||
1121 | return d in self._dirs |
|
|||
1122 |
|
||||
1123 | if util.safehasattr(parsers, 'dirs'): |
|
|||
1124 | dirs = parsers.dirs |
|
|||
1125 |
|
||||
1126 | def finddirs(path): |
|
|||
1127 | pos = path.rfind('/') |
|
|||
1128 | while pos != -1: |
|
|||
1129 | yield path[:pos] |
|
|||
1130 | pos = path.rfind('/', 0, pos) |
|
@@ -15,7 +15,7 b' hide platform-specific details from the ' | |||||
15 |
|
15 | |||
16 | import i18n |
|
16 | import i18n | |
17 | _ = i18n._ |
|
17 | _ = i18n._ | |
18 | import error, osutil, encoding |
|
18 | import error, osutil, encoding, parsers | |
19 | import errno, shutil, sys, tempfile, traceback |
|
19 | import errno, shutil, sys, tempfile, traceback | |
20 | import re as remod |
|
20 | import re as remod | |
21 | import os, time, datetime, calendar, textwrap, signal, collections |
|
21 | import os, time, datetime, calendar, textwrap, signal, collections | |
@@ -2240,5 +2240,50 b" def debugstacktrace(msg='stacktrace', sk" | |||||
2240 | f.write(' %-*s in %s\n' % (fnmax, fnln, func)) |
|
2240 | f.write(' %-*s in %s\n' % (fnmax, fnln, func)) | |
2241 | f.flush() |
|
2241 | f.flush() | |
2242 |
|
2242 | |||
|
2243 | class dirs(object): | |||
|
2244 | '''a multiset of directory names from a dirstate or manifest''' | |||
|
2245 | ||||
|
2246 | def __init__(self, map, skip=None): | |||
|
2247 | self._dirs = {} | |||
|
2248 | addpath = self.addpath | |||
|
2249 | if safehasattr(map, 'iteritems') and skip is not None: | |||
|
2250 | for f, s in map.iteritems(): | |||
|
2251 | if s[0] != skip: | |||
|
2252 | addpath(f) | |||
|
2253 | else: | |||
|
2254 | for f in map: | |||
|
2255 | addpath(f) | |||
|
2256 | ||||
|
2257 | def addpath(self, path): | |||
|
2258 | dirs = self._dirs | |||
|
2259 | for base in finddirs(path): | |||
|
2260 | if base in dirs: | |||
|
2261 | dirs[base] += 1 | |||
|
2262 | return | |||
|
2263 | dirs[base] = 1 | |||
|
2264 | ||||
|
2265 | def delpath(self, path): | |||
|
2266 | dirs = self._dirs | |||
|
2267 | for base in finddirs(path): | |||
|
2268 | if dirs[base] > 1: | |||
|
2269 | dirs[base] -= 1 | |||
|
2270 | return | |||
|
2271 | del dirs[base] | |||
|
2272 | ||||
|
2273 | def __iter__(self): | |||
|
2274 | return self._dirs.iterkeys() | |||
|
2275 | ||||
|
2276 | def __contains__(self, d): | |||
|
2277 | return d in self._dirs | |||
|
2278 | ||||
|
2279 | if safehasattr(parsers, 'dirs'): | |||
|
2280 | dirs = parsers.dirs | |||
|
2281 | ||||
|
2282 | def finddirs(path): | |||
|
2283 | pos = path.rfind('/') | |||
|
2284 | while pos != -1: | |||
|
2285 | yield path[:pos] | |||
|
2286 | pos = path.rfind('/', 0, pos) | |||
|
2287 | ||||
2243 | # convenient shortcut |
|
2288 | # convenient shortcut | |
2244 | dst = debugstacktrace |
|
2289 | dst = debugstacktrace |
General Comments 0
You need to be logged in to leave comments.
Login now