##// END OF EJS Templates
manifest: simplify cache handling, use a unique cache
Benoit Boissinot -
r9414:65dc5163 default
parent child Browse files
Show More
@@ -24,8 +24,7 b' class manifestdict(dict):'
24
24
25 class manifest(revlog.revlog):
25 class manifest(revlog.revlog):
26 def __init__(self, opener):
26 def __init__(self, opener):
27 self.mapcache = None
27 self._mancache = None
28 self.listcache = None
29 revlog.revlog.__init__(self, opener, "00manifest.i")
28 revlog.revlog.__init__(self, opener, "00manifest.i")
30
29
31 def parse(self, lines):
30 def parse(self, lines):
@@ -40,12 +39,12 b' class manifest(revlog.revlog):'
40 def read(self, node):
39 def read(self, node):
41 if node == revlog.nullid:
40 if node == revlog.nullid:
42 return manifestdict() # don't upset local cache
41 return manifestdict() # don't upset local cache
43 if self.mapcache and self.mapcache[0] == node:
42 if self._mancache and self._mancache[0] == node:
44 return self.mapcache[1]
43 return self._mancache[1]
45 text = self.revision(node)
44 text = self.revision(node)
46 self.listcache = array.array('c', text)
45 arraytext = array.array('c', text)
47 mapping = self.parse(text)
46 mapping = self.parse(text)
48 self.mapcache = (node, mapping)
47 self._mancache = (node, mapping, arraytext)
49 return mapping
48 return mapping
50
49
51 def _search(self, m, s, lo=0, hi=None):
50 def _search(self, m, s, lo=0, hi=None):
@@ -93,8 +92,8 b' class manifest(revlog.revlog):'
93 def find(self, node, f):
92 def find(self, node, f):
94 '''look up entry for a single file efficiently.
93 '''look up entry for a single file efficiently.
95 return (node, flags) pair if found, (None, None) if not.'''
94 return (node, flags) pair if found, (None, None) if not.'''
96 if self.mapcache and node == self.mapcache[0]:
95 if self._mancache and self._mancache[0] == node:
97 return self.mapcache[1].get(f), self.mapcache[1].flags(f)
96 return self._mancache[1].get(f), self._mancache[1].flags(f)
98 text = self.revision(node)
97 text = self.revision(node)
99 start, end = self._search(text, f)
98 start, end = self._search(text, f)
100 if start == end:
99 if start == end:
@@ -124,9 +123,9 b' class manifest(revlog.revlog):'
124 raise error.RevlogError(
123 raise error.RevlogError(
125 _("'\\n' and '\\r' disallowed in filenames: %r") % f)
124 _("'\\n' and '\\r' disallowed in filenames: %r") % f)
126
125
127 # if we're using the listcache, make sure it is valid and
126 # if we're using the cache, make sure it is valid and
128 # parented by the same node we're diffing against
127 # parented by the same node we're diffing against
129 if not (changed and self.listcache and p1 and self.mapcache[0] == p1):
128 if not (changed and self._mancache and p1 and self._mancache[0] == p1):
130 files = sorted(map)
129 files = sorted(map)
131 checkforbidden(files)
130 checkforbidden(files)
132
131
@@ -135,10 +134,10 b' class manifest(revlog.revlog):'
135 hex, flags = revlog.hex, map.flags
134 hex, flags = revlog.hex, map.flags
136 text = ["%s\000%s%s\n" % (f, hex(map[f]), flags(f))
135 text = ["%s\000%s%s\n" % (f, hex(map[f]), flags(f))
137 for f in files]
136 for f in files]
138 self.listcache = array.array('c', "".join(text))
137 arraytext = array.array('c', "".join(text))
139 cachedelta = None
138 cachedelta = None
140 else:
139 else:
141 addlist = self.listcache
140 addlist = self._mancache[2]
142
141
143 checkforbidden(changed[0])
142 checkforbidden(changed[0])
144 # combine the changed lists into one list for sorting
143 # combine the changed lists into one list for sorting
@@ -186,12 +185,12 b' class manifest(revlog.revlog):'
186 cachedelta = addlistdelta(addlist, delta)
185 cachedelta = addlistdelta(addlist, delta)
187
186
188 # the delta is only valid if we've been processing the tip revision
187 # the delta is only valid if we've been processing the tip revision
189 if self.mapcache[0] != self.tip():
188 if p1 != self.tip():
190 cachedelta = None
189 cachedelta = None
191 self.listcache = addlist
190 arraytext = addlist
192
191
193 n = self.addrevision(buffer(self.listcache), transaction, link,
192 n = self.addrevision(buffer(arraytext), transaction, link,
194 p1, p2, cachedelta)
193 p1, p2, cachedelta)
195 self.mapcache = (n, map)
194 self._mancache = (n, map, arraytext)
196
195
197 return n
196 return n
General Comments 0
You need to be logged in to leave comments. Login now