comparison mercurial/revlog.py @ 42746:05c80f9ef100

flagutil: move the `flagprocessors` mapping in the new module This module is meant to host most of the flag processing logic. We start with the mapping between flag and processors.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 08 Aug 2019 01:04:48 +0200
parents ca5ca3badd3c
children 92ac6b1697a7
comparison
equal deleted inserted replaced
42745:ca5ca3badd3c 42746:05c80f9ef100
70 templatefilters, 70 templatefilters,
71 util, 71 util,
72 ) 72 )
73 from .revlogutils import ( 73 from .revlogutils import (
74 deltas as deltautil, 74 deltas as deltautil,
75 flagutil,
75 ) 76 )
76 from .utils import ( 77 from .utils import (
77 interfaceutil, 78 interfaceutil,
78 storageutil, 79 storageutil,
79 stringutil, 80 stringutil,
108 109
109 # max size of revlog with inline data 110 # max size of revlog with inline data
110 _maxinline = 131072 111 _maxinline = 131072
111 _chunksize = 1048576 112 _chunksize = 1048576
112 113
113 # Store flag processors (cf. 'addflagprocessor()' to register)
114 _flagprocessors = {
115 REVIDX_ISCENSORED: None,
116 }
117
118 # Flag processors for REVIDX_ELLIPSIS. 114 # Flag processors for REVIDX_ELLIPSIS.
119 def ellipsisreadprocessor(rl, text): 115 def ellipsisreadprocessor(rl, text):
120 return text, False 116 return text, False
121 117
122 def ellipsiswriteprocessor(rl, text): 118 def ellipsiswriteprocessor(rl, text):
154 150
155 Note: The 'raw' transform is used for changegroup generation and in some 151 Note: The 'raw' transform is used for changegroup generation and in some
156 debug commands. In this case the transform only indicates whether the 152 debug commands. In this case the transform only indicates whether the
157 contents can be used for hash integrity checks. 153 contents can be used for hash integrity checks.
158 """ 154 """
159 _insertflagprocessor(flag, processor, _flagprocessors) 155 _insertflagprocessor(flag, processor, flagutil.flagprocessors)
160 156
161 def _insertflagprocessor(flag, processor, flagprocessors): 157 def _insertflagprocessor(flag, processor, flagprocessors):
162 if not flag & REVIDX_KNOWN_FLAGS: 158 if not flag & REVIDX_KNOWN_FLAGS:
163 msg = _("cannot register processor on unknown flag '%#x'.") % (flag) 159 msg = _("cannot register processor on unknown flag '%#x'.") % (flag)
164 raise error.ProgrammingError(msg) 160 raise error.ProgrammingError(msg)
384 self._srdensitythreshold = 0.50 380 self._srdensitythreshold = 0.50
385 self._srmingapsize = 262144 381 self._srmingapsize = 262144
386 382
387 # Make copy of flag processors so each revlog instance can support 383 # Make copy of flag processors so each revlog instance can support
388 # custom flags. 384 # custom flags.
389 self._flagprocessors = dict(_flagprocessors) 385 self._flagprocessors = dict(flagutil.flagprocessors)
390 386
391 # 2-tuple of file handles being used for active writing. 387 # 2-tuple of file handles being used for active writing.
392 self._writinghandles = None 388 self._writinghandles = None
393 389
394 self._loadindex() 390 self._loadindex()