Mercurial > hg-stable
diff mercurial/bundlerepo.py @ 30745:c1b7b2285522
revlog: flag processor
Add the ability for revlog objects to process revision flags and apply
registered transforms on read/write operations.
This patch introduces:
- the 'revlog._processflags()' method that looks at revision flags and applies
flag processors registered on them. Due to the need to handle non-commutative
operations, flag transforms are applied in stable order but the order in which
the transforms are applied is reversed between read and write operations.
- the 'addflagprocessor()' method allowing to register processors on flags.
Flag processors are defined as a 3-tuple of (read, write, raw) functions to be
applied depending on the operation being performed.
- an update on 'revlog.addrevision()' behavior. The current flagprocessor design
relies on extensions to wrap around 'addrevision()' to set flags on revision
data, and on the flagprocessor to perform the actual transformation of its
contents. In the lfs case, this means we need to process flags before we meet
the 2GB size check, leading to performing some operations before it happens:
- if flags are set on the revision data, we assume some extensions might be
modifying the contents using the flag processor next, and we compute the
node for the original revision data (still allowing extension to override
the node by wrapping around 'addrevision()').
- we then invoke the flag processor to apply registered transforms (in lfs's
case, drastically reducing the size of large blobs).
- finally, we proceed with the 2GB size check.
Note: In the case a cachedelta is passed to 'addrevision()' and we detect the
flag processor modified the revision data, we chose to trust the flag processor
and drop the cachedelta.
author | Remi Chaintron <remi@fb.com> |
---|---|
date | Tue, 10 Jan 2017 16:15:21 +0000 |
parents | 2df983125d37 |
children | 48dea083f66d |
line wrap: on
line diff
--- a/mercurial/bundlerepo.py Thu Jan 05 17:16:07 2017 +0000 +++ b/mercurial/bundlerepo.py Tue Jan 10 16:15:21 2017 +0000 @@ -148,7 +148,10 @@ delta = self._chunk(chain.pop()) text = mdiff.patches(text, [delta]) - self.checkhash(text, node, rev=rev) + text, validatehash = self._processflags(text, self.flags(rev), + 'read', raw=raw) + if validatehash: + self.checkhash(text, node, rev=rev) self._cache = (node, rev, text) return text