comparison mercurial/filelog.py @ 47089:4c041c71ec01

revlog: introduce an explicit tracking of what the revlog is about Since the dawn of time, people have been forced to rely to lossy introspection of the index filename to determine what the purpose and role of the revlog they encounter is. This is hacky, error prone, inflexible, abstraction-leaky, <insert-your-own-complaints-here>. In f63299ee7e4d Rapha?l introduced a new attribute to track this information: `revlog_kind`. However it is initialized in an odd place and various instances end up not having it set. In addition is only tracking some of the information we end up having to introspect in various pieces of code. So we add a new attribute that holds more data and is more strictly enforced. This work is done in collaboration with Rapha?l. The `revlog_kind` one will be removed/adapted in the next changeset. We expect to be able to clean up various existing piece of code and to simplify coming work around the newer revlog format. Differential Revision: https://phab.mercurial-scm.org/D10352
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 06 Apr 2021 05:20:24 +0200
parents d55b71393907
children 64cd1496bb70
comparison
equal deleted inserted replaced
47088:3e381eb557f3 47089:4c041c71ec01
16 from .interfaces import ( 16 from .interfaces import (
17 repository, 17 repository,
18 util as interfaceutil, 18 util as interfaceutil,
19 ) 19 )
20 from .utils import storageutil 20 from .utils import storageutil
21 from .revlogutils import (
22 constants as revlog_constants,
23 )
21 24
22 25
23 @interfaceutil.implementer(repository.ifilestorage) 26 @interfaceutil.implementer(repository.ifilestorage)
24 class filelog(object): 27 class filelog(object):
25 def __init__(self, opener, path): 28 def __init__(self, opener, path):
26 self._revlog = revlog.revlog( 29 self._revlog = revlog.revlog(
27 opener, b'/'.join((b'data', path + b'.i')), censorable=True 30 opener,
31 # XXX should use the unencoded path
32 target=(revlog_constants.KIND_FILELOG, path),
33 indexfile=b'/'.join((b'data', path + b'.i')),
34 censorable=True,
28 ) 35 )
29 # Full name of the user visible file, relative to the repository root. 36 # Full name of the user visible file, relative to the repository root.
30 # Used by LFS. 37 # Used by LFS.
31 self._revlog.filename = path 38 self._revlog.filename = path
32 self._revlog.revlog_kind = b'filelog' 39 self._revlog.revlog_kind = b'filelog'