Show More
@@ -0,0 +1,11 b'' | |||||
|
1 | #!/bin/sh | |||
|
2 | ||||
|
3 | # test dirstate._dirs refcounting | |||
|
4 | hg init t | |||
|
5 | cd t | |||
|
6 | mkdir -p a/b/c/d | |||
|
7 | touch a/b/c/d/x | |||
|
8 | touch a/b/c/d/y | |||
|
9 | touch a/b/c/d/z | |||
|
10 | hg ci -Am m | |||
|
11 | hg mv a z |
@@ -0,0 +1,6 b'' | |||||
|
1 | adding a/b/c/d/x | |||
|
2 | adding a/b/c/d/y | |||
|
3 | adding a/b/c/d/z | |||
|
4 | moving a/b/c/d/x to z/b/c/d/x | |||
|
5 | moving a/b/c/d/y to z/b/c/d/y | |||
|
6 | moving a/b/c/d/z to z/b/c/d/z |
@@ -21,6 +21,20 b' def _finddirs(path):' | |||||
21 | yield path[:pos] |
|
21 | yield path[:pos] | |
22 | pos = path.rfind('/', 0, pos) |
|
22 | pos = path.rfind('/', 0, pos) | |
23 |
|
23 | |||
|
24 | def _incdirs(dirs, path): | |||
|
25 | for base in _finddirs(path): | |||
|
26 | if base in dirs: | |||
|
27 | dirs[base] += 1 | |||
|
28 | return | |||
|
29 | dirs[base] = 1 | |||
|
30 | ||||
|
31 | def _decdirs(dirs, path): | |||
|
32 | for base in _finddirs(path): | |||
|
33 | if dirs[base] > 1: | |||
|
34 | dirs[base] -= 1 | |||
|
35 | return | |||
|
36 | del dirs[base] | |||
|
37 | ||||
24 | class dirstate(object): |
|
38 | class dirstate(object): | |
25 |
|
39 | |||
26 | def __init__(self, opener, ui, root): |
|
40 | def __init__(self, opener, ui, root): | |
@@ -65,14 +79,7 b' class dirstate(object):' | |||||
65 | dirs = {} |
|
79 | dirs = {} | |
66 | for f,s in self._map.iteritems(): |
|
80 | for f,s in self._map.iteritems(): | |
67 | if s[0] != 'r': |
|
81 | if s[0] != 'r': | |
68 |
|
|
82 | _incdirs(dirs, f) | |
69 | while pos != -1: |
|
|||
70 | f = f[:pos] |
|
|||
71 | if f in dirs: |
|
|||
72 | dirs[f] += 1 |
|
|||
73 | break |
|
|||
74 | dirs[f] = 1 |
|
|||
75 | pos = f.rfind('/') |
|
|||
76 | self._dirs = dirs |
|
83 | self._dirs = dirs | |
77 | return self._dirs |
|
84 | return self._dirs | |
78 | elif name == '_ignore': |
|
85 | elif name == '_ignore': | |
@@ -222,12 +229,7 b' class dirstate(object):' | |||||
222 |
|
229 | |||
223 | def _droppath(self, f): |
|
230 | def _droppath(self, f): | |
224 | if self[f] not in "?r" and "_dirs" in self.__dict__: |
|
231 | if self[f] not in "?r" and "_dirs" in self.__dict__: | |
225 |
|
|
232 | _decdirs(self._dirs, f) | |
226 | for base in _finddirs(f): |
|
|||
227 | if dirs[base] == 1: |
|
|||
228 | del dirs[base] |
|
|||
229 | return |
|
|||
230 | dirs[base] -= 1 |
|
|||
231 |
|
233 | |||
232 | def _addpath(self, f, check=False): |
|
234 | def _addpath(self, f, check=False): | |
233 | oldstate = self[f] |
|
235 | oldstate = self[f] | |
@@ -245,9 +247,7 b' class dirstate(object):' | |||||
245 | raise util.Abort( |
|
247 | raise util.Abort( | |
246 | _('file %r in dirstate clashes with %r') % (d, f)) |
|
248 | _('file %r in dirstate clashes with %r') % (d, f)) | |
247 | if oldstate in "?r" and "_dirs" in self.__dict__: |
|
249 | if oldstate in "?r" and "_dirs" in self.__dict__: | |
248 |
|
|
250 | _incdirs(self._dirs, f) | |
249 | for base in _finddirs(f): |
|
|||
250 | dirs[base] = dirs.get(base, 0) + 1 |
|
|||
251 |
|
251 | |||
252 | def normal(self, f): |
|
252 | def normal(self, f): | |
253 | 'mark a file normal and clean' |
|
253 | 'mark a file normal and clean' |
General Comments 0
You need to be logged in to leave comments.
Login now