Mercurial > hg
changeset 23253:8d84b7a2dd91
transaction: factorise append-only file registration
The addition is done in two different places but differs slightly. We factorise
this addition to ensure it is consistent in all places.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 05 Nov 2014 10:13:01 +0000 |
parents | 70809438c644 |
children | d23834b871ac |
files | mercurial/transaction.py |
diffstat | 1 files changed, 8 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/transaction.py Wed Nov 05 13:00:48 2014 +0000 +++ b/mercurial/transaction.py Wed Nov 05 10:13:01 2014 +0000 @@ -130,15 +130,8 @@ This is used by strip to delay vision of strip offset. The transaction sees either none or all of the strip actions to be done.""" q = self._queue.pop() - self.entries.extend(q) - - offsets = [] - for f, o, _data in q: - offsets.append((f, o)) - - d = ''.join(['%s\0%d\n' % (f, o) for f, o in offsets]) - self.file.write(d) - self.file.flush() + for f, o, data in q: + self._addentry(f, o, data) @active def add(self, file, offset, data=None): @@ -149,6 +142,12 @@ self._queue[-1].append((file, offset, data)) return + self._addentry(file, offset, data) + + def _addentry(self, file, offset, data): + """add a append-only entry to memory and on-disk state""" + if file in self.map or file in self._backupmap: + return self.entries.append((file, offset, data)) self.map[file] = len(self.entries) - 1 # add enough data to the journal to do the truncate