[PATCH 7 of 7 ?] transaction: factorise append-only file registration
Augie Fackler
raf at durin42.com
Tue Nov 11 08:26:53 CST 2014
On Mon, Nov 10, 2014 at 04:31:52PM +0000, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at fb.com>
> # Date 1415182381 0
> # Wed Nov 05 10:13:01 2014 +0000
> # Node ID f7a9075b0999727f85493e9b61d9191f10111694
> # Parent 7a4e0a8524b5efbf8eb0c6848bf316bfdfaa325b
> transaction: factorise append-only file registration
Looks good, queued with some wording tweaks.
>
> The addition is done in two different places but differ slightly. We factorise
> this addition to ensure it consistent in all place.
>
> diff --git a/mercurial/transaction.py b/mercurial/transaction.py
> --- a/mercurial/transaction.py
> +++ b/mercurial/transaction.py
> @@ -128,29 +128,28 @@ class transaction(object):
> """apply delayed registration of file entry.
>
> This is used by strip to delay vision of strip offset. The transaction
> see either none or all strip action 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):
> """record the state of an append-only file before update"""
> if file in self.map or file in self._backupmap:
> return
> if self._queue:
> 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
> self.file.write("%s\0%d\n" % (file, offset))
> self.file.flush()
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list