Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 20217:33394f2e331e
revlog: move file writing to a separate function
Moves the code that actually writes to a file to a separate function in
revlog.py. This allows extensions to intercept and use the data being written to
disk. For example, an extension might want to replicate these writes elsewhere.
When cloning the Mercurial repo on /dev/shm with --pull, I see about a 0.3% perf change.
It goes from 28.2 to 28.3 seconds.
author | Durham Goode <durham@fb.com> |
---|---|
date | Tue, 26 Nov 2013 12:58:27 -0800 |
parents | 969148b49fc6 |
children | 514d32de6646 469d949a7cb8 |
comparison
equal
deleted
inserted
replaced
20216:01bdccfeb9d9 | 20217:33394f2e331e |
---|---|
1204 base, link, p1r, p2r, node) | 1204 base, link, p1r, p2r, node) |
1205 self.index.insert(-1, e) | 1205 self.index.insert(-1, e) |
1206 self.nodemap[node] = curr | 1206 self.nodemap[node] = curr |
1207 | 1207 |
1208 entry = self._io.packentry(e, self.node, self.version, curr) | 1208 entry = self._io.packentry(e, self.node, self.version, curr) |
1209 self._writeentry(transaction, ifh, dfh, entry, data, link, offset) | |
1210 | |
1211 if type(text) == str: # only accept immutable objects | |
1212 self._cache = (node, curr, text) | |
1213 self._basecache = (curr, chainbase) | |
1214 return node | |
1215 | |
1216 def _writeentry(self, transaction, ifh, dfh, entry, data, link, offset): | |
1217 curr = len(self) - 1 | |
1209 if not self._inline: | 1218 if not self._inline: |
1210 transaction.add(self.datafile, offset) | 1219 transaction.add(self.datafile, offset) |
1211 transaction.add(self.indexfile, curr * len(entry)) | 1220 transaction.add(self.indexfile, curr * len(entry)) |
1212 if data[0]: | 1221 if data[0]: |
1213 dfh.write(data[0]) | 1222 dfh.write(data[0]) |
1219 transaction.add(self.indexfile, offset, curr) | 1228 transaction.add(self.indexfile, offset, curr) |
1220 ifh.write(entry) | 1229 ifh.write(entry) |
1221 ifh.write(data[0]) | 1230 ifh.write(data[0]) |
1222 ifh.write(data[1]) | 1231 ifh.write(data[1]) |
1223 self.checkinlinesize(transaction, ifh) | 1232 self.checkinlinesize(transaction, ifh) |
1224 | |
1225 if type(text) == str: # only accept immutable objects | |
1226 self._cache = (node, curr, text) | |
1227 self._basecache = (curr, chainbase) | |
1228 return node | |
1229 | 1233 |
1230 def addgroup(self, bundle, linkmapper, transaction): | 1234 def addgroup(self, bundle, linkmapper, transaction): |
1231 """ | 1235 """ |
1232 add a delta group | 1236 add a delta group |
1233 | 1237 |