comparison mercurial/obsolete.py @ 46780:6266d19556ad

node: introduce nodeconstants class In preparing for moving from SHA1 hashes to a modern hash function, place nullid and other constant magic vules in a class. Provide the active set of constants in the repository and push it down. Provide nullid directly in strategic places like the repository as it is accessed very often. This changeset introduces the API change, but not the mechanical replacement of the node.py attributes itself. Differential Revision: https://phab.mercurial-scm.org/D9750
author Joerg Sonnenberger <joerg@bec.de>
date Wed, 13 Jan 2021 16:14:58 +0100
parents 59fa3890d40a
children d55b71393907
comparison
equal deleted inserted replaced
46779:49fd21f32695 46780:6266d19556ad
558 # meta: binary blob in UTF-8, encoded metadata dictionary 558 # meta: binary blob in UTF-8, encoded metadata dictionary
559 # date: (float, int) tuple, date of marker creation 559 # date: (float, int) tuple, date of marker creation
560 # parents: (tuple of nodeid) or None, parents of predecessors 560 # parents: (tuple of nodeid) or None, parents of predecessors
561 # None is used when no data has been recorded 561 # None is used when no data has been recorded
562 562
563 def __init__(self, svfs, defaultformat=_fm1version, readonly=False): 563 def __init__(self, repo, svfs, defaultformat=_fm1version, readonly=False):
564 # caches for various obsolescence related cache 564 # caches for various obsolescence related cache
565 self.caches = {} 565 self.caches = {}
566 self.svfs = svfs 566 self.svfs = svfs
567 self.repo = repo
567 self._defaultformat = defaultformat 568 self._defaultformat = defaultformat
568 self._readonly = readonly 569 self._readonly = readonly
569 570
570 def __iter__(self): 571 def __iter__(self):
571 return iter(self._all) 572 return iter(self._all)
804 # rely on obsstore class default when possible. 805 # rely on obsstore class default when possible.
805 kwargs = {} 806 kwargs = {}
806 if defaultformat is not None: 807 if defaultformat is not None:
807 kwargs['defaultformat'] = defaultformat 808 kwargs['defaultformat'] = defaultformat
808 readonly = not isenabled(repo, createmarkersopt) 809 readonly = not isenabled(repo, createmarkersopt)
809 store = obsstore(repo.svfs, readonly=readonly, **kwargs) 810 store = obsstore(repo, repo.svfs, readonly=readonly, **kwargs)
810 if store and readonly: 811 if store and readonly:
811 ui.warn( 812 ui.warn(
812 _(b'obsolete feature not enabled but %i markers found!\n') 813 _(b'obsolete feature not enabled but %i markers found!\n')
813 % len(list(store)) 814 % len(list(store))
814 ) 815 )