##// END OF EJS Templates
Switch to simpler manifestdict
Matt Mackall -
r2839:b4f05ecf default
parent child Browse files
Show More
@@ -11,38 +11,26 b' from demandload import *'
11 demandload(globals(), "array bisect struct")
11 demandload(globals(), "array bisect struct")
12
12
13 class manifestdict(dict):
13 class manifestdict(dict):
14 def __init__(self, mapping={}):
14 def __init__(self, mapping={}, flags={}):
15 dict.__init__(self, mapping)
15 dict.__init__(self, mapping)
16 def __getitem__(self, f):
16 self._flags = flags
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]
28 def flags(self, f):
17 def flags(self, f):
29 return dict.get(self, f, "")[20:]
18 return self._flags.get(f, "")
30 def execf(self, f):
19 def execf(self, f):
31 "test for executable in manifest flags"
20 "test for executable in manifest flags"
32 return "x" in self.flags(f)
21 return "x" in self.flags(f)
33 def linkf(self, f):
22 def linkf(self, f):
34 "test for symlink in manifest flags"
23 "test for symlink in manifest flags"
35 return "l" in self.flags(f)
24 return "l" in self.flags(f)
36 def rawset(self, f, node, flags):
25 def rawset(self, f, entry):
37 dict.__setitem__(self, f, node + flags)
26 self[f] = bin(entry[:40])
27 fl = entry[40:-1]
28 if fl: self._flags[f] = fl
38 def set(self, f, execf=False, linkf=False):
29 def set(self, f, execf=False, linkf=False):
39 n = dict.get(self, f, nullid)[:20]
30 if execf: self._flags[f] = "x"
40 fl = ""
31 if linkf: self._flags[f] = "x"
41 if execf: fl = "x"
42 if linkf: fl = "l"
43 dict.__setitem__(self, f, n + fl)
44 def copy(self):
32 def copy(self):
45 return manifestdict(dict.copy(self))
33 return manifestdict(dict.copy(self), dict.copy(self._flags))
46
34
47 class manifest(revlog):
35 class manifest(revlog):
48 def __init__(self, opener, defversion=REVLOGV0):
36 def __init__(self, opener, defversion=REVLOGV0):
@@ -61,7 +49,7 b' class manifest(revlog):'
61 mapping = manifestdict()
49 mapping = manifestdict()
62 for l in lines:
50 for l in lines:
63 (f, n) = l.split('\0')
51 (f, n) = l.split('\0')
64 mapping.rawset(f, bin(n[:40]), n[40:-1])
52 mapping.rawset(f, n)
65 self.mapcache = (node, mapping)
53 self.mapcache = (node, mapping)
66 return mapping
54 return mapping
67
55
General Comments 0
You need to be logged in to leave comments. Login now