comparison mercurial/localrepo.py @ 47078:223b47235d1c

sidedata: enable sidedata computers to optionally rewrite flags Sidedata computers may want to influence the flags of the revision they touch. For example, the computer for changelog-based copytracing can add a flag to signify that this revision might affect copytracing, inversely removing said flag if the information is no longer applicable. See inline documentation in `storageutil` for more details. Differential Revision: https://phab.mercurial-scm.org/D10344
author Raphaël Gomès <rgomes@octobus.net>
date Thu, 08 Apr 2021 16:55:17 +0200
parents 5554aacd783f
children 81eb7091c494
comparison
equal deleted inserted replaced
47077:119790e1c67c 47078:223b47235d1c
3368 if requirementsmod.REVLOGV2_REQUIREMENT not in self.requirements: 3368 if requirementsmod.REVLOGV2_REQUIREMENT not in self.requirements:
3369 # Only revlogv2 repos can want sidedata. 3369 # Only revlogv2 repos can want sidedata.
3370 return 3370 return
3371 self._wanted_sidedata.add(pycompat.bytestr(category)) 3371 self._wanted_sidedata.add(pycompat.bytestr(category))
3372 3372
3373 def register_sidedata_computer(self, kind, category, keys, computer): 3373 def register_sidedata_computer(self, kind, category, keys, computer, flags):
3374 if kind not in revlogconst.ALL_KINDS: 3374 if kind not in revlogconst.ALL_KINDS:
3375 msg = _(b"unexpected revlog kind %r.") 3375 msg = _(b"unexpected revlog kind '%s'.")
3376 raise error.ProgrammingError(msg % kind) 3376 raise error.ProgrammingError(msg % kind)
3377 category = pycompat.bytestr(category) 3377 category = pycompat.bytestr(category)
3378 if category in self._sidedata_computers.get(kind, []): 3378 if category in self._sidedata_computers.get(kind, []):
3379 msg = _( 3379 msg = _(
3380 b"cannot register a sidedata computer twice for category '%s'." 3380 b"cannot register a sidedata computer twice for category '%s'."
3381 ) 3381 )
3382 raise error.ProgrammingError(msg % category) 3382 raise error.ProgrammingError(msg % category)
3383 self._sidedata_computers.setdefault(kind, {}) 3383 self._sidedata_computers.setdefault(kind, {})
3384 self._sidedata_computers[kind][category] = (keys, computer) 3384 self._sidedata_computers[kind][category] = (keys, computer, flags)
3385 3385
3386 3386
3387 # used to avoid circular references so destructors work 3387 # used to avoid circular references so destructors work
3388 def aftertrans(files): 3388 def aftertrans(files):
3389 renamefiles = [tuple(t) for t in files] 3389 renamefiles = [tuple(t) for t in files]