##// END OF EJS Templates
revlog: move censor logic out of censor extension...
revlog: move censor logic out of censor extension The censor extension is doing very low-level things with revlogs. It is fundamentally impossible for this logic to remain in the censor extension while support multiple storage backends: we need each storage backend to implement censor in its own storage-specific way. This commit effectively moves the revlog-specific censoring code to be a method of revlogs themselves. We've defined a new API on the file storage interface for censoring an individual node. Even though the current censoring code doesn't use it, the API requires a transaction instance because it logically makes sense for storage backends to require an active transaction (which implies a held write lock) in order to rewrite storage. After this commit, the censor extension has been reduced to boilerplate precondition checking before invoking the generic storage API. I tried to keep the code as similar as possible. But some minor changes were made: * We use self._io instead of instantiating a new revlogio instance. * We compare self.version against REVLOGV0 instead of != REVLOGV1 because presumably all future revlog versions will support censoring. * We use self.opener instead of going through repo.svfs (we don't have a handle on the repo instance from a revlog). * "revlog" dropped * Replace "flog" with "self". Differential Revision: https://phab.mercurial-scm.org/D4656

File last commit:

r36490:d0d5eef5 default
r39814:a6b3c4c1 default
Show More
narrowcopies.py
34 lines | 1.1 KiB | text/x-python | PythonLexer
# narrowcopies.py - extensions to mercurial copies module to support narrow
# clones
#
# Copyright 2017 Google, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
from mercurial import (
copies,
extensions,
)
def setup(repo):
def _computeforwardmissing(orig, a, b, match=None):
missing = orig(a, b, match)
narrowmatch = repo.narrowmatch()
if narrowmatch.always():
return missing
missing = [f for f in missing if narrowmatch(f)]
return missing
def _checkcopies(orig, srcctx, dstctx, f, base, tca, remotebase, limit,
data):
narrowmatch = repo.narrowmatch()
if not narrowmatch(f):
return
orig(srcctx, dstctx, f, base, tca, remotebase, limit, data)
extensions.wrapfunction(copies, '_computeforwardmissing',
_computeforwardmissing)
extensions.wrapfunction(copies, '_checkcopies', _checkcopies)