Mercurial > public > mercurial-scm > hg
comparison mercurial/manifest.py @ 9420:d0db168136dc
manifest/revlog: do not let the revlog cache mutable objects
If a buffer of an mutable object is passed to revlog.addrevision(), the revlog
will happily store it in its cache. Later when the revlog reuses the cached
entry, if the manifest modified the object in-between, all kind of bugs
appears.
We fix it by:
- passing immutable objects to addrevision() if they are already available
- only storing the text in the cache if it's of str type
Then we can remove the conversion of the cache entry to str() during
retrieval. That was probably just there hiding the bug for the common cases
but not really fixing it.
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Fri, 04 Sep 2009 10:47:55 +0200 |
parents | eecbaac5ca88 |
children | 25e572394f5c |
comparison
equal
deleted
inserted
replaced
9419:3516a4e877c1 | 9420:d0db168136dc |
---|---|
130 checkforbidden(files) | 130 checkforbidden(files) |
131 | 131 |
132 # if this is changed to support newlines in filenames, | 132 # if this is changed to support newlines in filenames, |
133 # be sure to check the templates/ dir again (especially *-raw.tmpl) | 133 # be sure to check the templates/ dir again (especially *-raw.tmpl) |
134 hex, flags = revlog.hex, map.flags | 134 hex, flags = revlog.hex, map.flags |
135 text = ["%s\000%s%s\n" % (f, hex(map[f]), flags(f)) | 135 text = ''.join("%s\000%s%s\n" % (f, hex(map[f]), flags(f)) |
136 for f in files] | 136 for f in files) |
137 arraytext = array.array('c', "".join(text)) | 137 arraytext = array.array('c', text) |
138 cachedelta = None | 138 cachedelta = None |
139 else: | 139 else: |
140 added, removed = changed | 140 added, removed = changed |
141 addlist = self._mancache[2] | 141 addlist = self._mancache[2] |
142 | 142 |
188 | 188 |
189 # the delta is only valid if we've been processing the tip revision | 189 # the delta is only valid if we've been processing the tip revision |
190 if p1 != self.tip(): | 190 if p1 != self.tip(): |
191 cachedelta = None | 191 cachedelta = None |
192 arraytext = addlist | 192 arraytext = addlist |
193 text = buffer(arraytext) | |
193 | 194 |
194 n = self.addrevision(buffer(arraytext), transaction, link, | 195 n = self.addrevision(text, transaction, link, p1, p2, cachedelta) |
195 p1, p2, cachedelta) | |
196 self._mancache = (n, map, arraytext) | 196 self._mancache = (n, map, arraytext) |
197 | 197 |
198 return n | 198 return n |