Show More
@@ -10,26 +10,39 b' from i18n import gettext as _' | |||
|
10 | 10 | from demandload import * |
|
11 | 11 | demandload(globals(), "array bisect struct") |
|
12 | 12 | |
|
13 |
class manifest |
|
|
13 | class manifestdict(dict): | |
|
14 | 14 | def __init__(self, mapping={}): |
|
15 | 15 | dict.__init__(self, mapping) |
|
16 | 16 | def __getitem__(self, f): |
|
17 | raise "oops" | |
|
17 | return self.node(f) | |
|
18 | def get(self, f, default=None): | |
|
19 | try: | |
|
20 | return dict.__getitem__(self, f)[:20] | |
|
21 | except KeyError: | |
|
22 | return default | |
|
23 | def __setitem__(self, f, node): | |
|
24 | fl = self.flags(f) | |
|
25 | dict.__setitem__(self, f, node + fl) | |
|
26 | def node(self, f): | |
|
27 | return dict.__getitem__(self, f)[:20] | |
|
18 | 28 | def flags(self, f): |
|
19 |
return dict. |
|
|
29 | return dict.get(self, f, "")[20:] | |
|
20 | 30 | def execf(self, f): |
|
21 | 31 | "test for executable in manifest flags" |
|
22 |
return "x" in self. |
|
|
32 | return "x" in self.flags(f) | |
|
23 | 33 | def linkf(self, f): |
|
24 | 34 | "test for symlink in manifest flags" |
|
25 |
return "l" in self. |
|
|
35 | return "l" in self.flags(f) | |
|
36 | def rawset(self, f, node, flags): | |
|
37 | dict.__setitem__(self, f, node + flags) | |
|
26 | 38 | def set(self, f, execf=False, linkf=False): |
|
39 | n = dict.get(self, f, nullid)[:20] | |
|
27 | 40 | fl = "" |
|
28 | 41 | if execf: fl = "x" |
|
29 | 42 | if linkf: fl = "l" |
|
30 | self[f] = fl | |
|
43 | dict.__setitem__(self, f, n + fl) | |
|
31 | 44 | def copy(self): |
|
32 |
return manifest |
|
|
45 | return manifestdict(dict.copy(self)) | |
|
33 | 46 | |
|
34 | 47 | class manifest(revlog): |
|
35 | 48 | def __init__(self, opener, defversion=REVLOGV0): |
@@ -39,26 +52,21 b' class manifest(revlog):' | |||
|
39 | 52 | defversion) |
|
40 | 53 | |
|
41 | 54 | def read(self, node): |
|
42 |
if node == nullid: return |
|
|
55 | if node == nullid: return manifestdict() # don't upset local cache | |
|
43 | 56 | if self.mapcache and self.mapcache[0] == node: |
|
44 | 57 | return self.mapcache[1] |
|
45 | 58 | text = self.revision(node) |
|
46 | map = {} | |
|
47 | flag = manifestflags() | |
|
48 | 59 | self.listcache = array.array('c', text) |
|
49 | 60 | lines = text.splitlines(1) |
|
61 | mapping = manifestdict() | |
|
50 | 62 | for l in lines: |
|
51 | 63 | (f, n) = l.split('\0') |
|
52 |
map |
|
|
53 | flag[f] = n[40:-1] | |
|
54 | self.mapcache = (node, map, flag) | |
|
55 | return map | |
|
64 | mapping.rawset(f, bin(n[:40]), n[40:-1]) | |
|
65 | self.mapcache = (node, mapping) | |
|
66 | return mapping | |
|
56 | 67 | |
|
57 | 68 | def readflags(self, node): |
|
58 | if node == nullid: return manifestflags() # don't upset local cache | |
|
59 | if not self.mapcache or self.mapcache[0] != node: | |
|
60 | self.read(node) | |
|
61 | return self.mapcache[2] | |
|
69 | return self.read(node) | |
|
62 | 70 | |
|
63 | 71 | def diff(self, a, b): |
|
64 | 72 | return mdiff.textdiff(str(a), str(b)) |
@@ -107,7 +115,7 b' class manifest(revlog):' | |||
|
107 | 115 | '''look up entry for a single file efficiently. |
|
108 | 116 | return (node, flag) pair if found, (None, None) if not.''' |
|
109 | 117 | if self.mapcache and node == self.mapcache[0]: |
|
110 |
return self.mapcache[1].get(f), self.mapcache[ |
|
|
118 | return self.mapcache[1].get(f), self.mapcache[1].flags(f) | |
|
111 | 119 | text = self.revision(node) |
|
112 | 120 | start, end = self._search(text, f) |
|
113 | 121 | if start == end: |
@@ -201,6 +209,6 b' class manifest(revlog):' | |||
|
201 | 209 | |
|
202 | 210 | n = self.addrevision(buffer(self.listcache), transaction, link, p1, \ |
|
203 | 211 | p2, cachedelta) |
|
204 |
self.mapcache = (n, map |
|
|
212 | self.mapcache = (n, map) | |
|
205 | 213 | |
|
206 | 214 | return n |
General Comments 0
You need to be logged in to leave comments.
Login now