comparison mercurial/filelog.py @ 37441:a3202fa83aff

filelog: declare that filelog implements a storage interface Now that we have a declared interface, let's declare that filelog implements it. Tests have been added that confirm the object conforms to the interface. The existing interface checks verify there are no extra public attributes outside the declared interface. filelog has several extra attributes. So we added a mechanism to suppress this check. The goal is to modify the filelog class so we can drop this check. Differential Revision: https://phab.mercurial-scm.org/D3149
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 05 Apr 2018 15:18:23 -0700
parents 07769a04bc66
children 0596d27457c6
comparison
equal deleted inserted replaced
37440:4335a75f0bd0 37441:a3202fa83aff
8 from __future__ import absolute_import 8 from __future__ import absolute_import
9 9
10 import re 10 import re
11 import struct 11 import struct
12 12
13 from .thirdparty.zope import (
14 interface as zi,
15 )
13 from . import ( 16 from . import (
14 error, 17 error,
15 mdiff, 18 mdiff,
19 repository,
16 revlog, 20 revlog,
17 ) 21 )
18 22
19 _mdre = re.compile('\1\n') 23 _mdre = re.compile('\1\n')
20 def parsemeta(text): 24 def parsemeta(text):
37 41
38 def _censoredtext(text): 42 def _censoredtext(text):
39 m, offs = parsemeta(text) 43 m, offs = parsemeta(text)
40 return m and "censored" in m 44 return m and "censored" in m
41 45
46 @zi.implementer(repository.ifilestorage)
42 class filelog(revlog.revlog): 47 class filelog(revlog.revlog):
43 def __init__(self, opener, path): 48 def __init__(self, opener, path):
44 super(filelog, self).__init__(opener, 49 super(filelog, self).__init__(opener,
45 "/".join(("data", path + ".i"))) 50 "/".join(("data", path + ".i")))
46 # full name of the user visible file, relative to the repository root 51 # full name of the user visible file, relative to the repository root