Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.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 | bc2519513ae0 |
children | e2f7b2695ba1 |
comparison
equal
deleted
inserted
replaced
46779:49fd21f32695 | 46780:6266d19556ad |
---|---|
19 from .node import ( | 19 from .node import ( |
20 bin, | 20 bin, |
21 hex, | 21 hex, |
22 nullid, | 22 nullid, |
23 nullrev, | 23 nullrev, |
24 sha1nodeconstants, | |
24 short, | 25 short, |
25 ) | 26 ) |
26 from .pycompat import ( | 27 from .pycompat import ( |
27 delattr, | 28 delattr, |
28 getattr, | 29 getattr, |
1328 self.root = wdirvfs.base | 1329 self.root = wdirvfs.base |
1329 # vfs rooted at .hg/. Used to access most non-store paths. | 1330 # vfs rooted at .hg/. Used to access most non-store paths. |
1330 self.vfs = hgvfs | 1331 self.vfs = hgvfs |
1331 self.path = hgvfs.base | 1332 self.path = hgvfs.base |
1332 self.requirements = requirements | 1333 self.requirements = requirements |
1334 self.nodeconstants = sha1nodeconstants | |
1335 self.nullid = self.nodeconstants.nullid | |
1333 self.supported = supportedrequirements | 1336 self.supported = supportedrequirements |
1334 self.sharedpath = sharedpath | 1337 self.sharedpath = sharedpath |
1335 self.store = store | 1338 self.store = store |
1336 self.cachevfs = cachevfs | 1339 self.cachevfs = cachevfs |
1337 self.wcachevfs = wcachevfs | 1340 self.wcachevfs = wcachevfs |
1674 def _makedirstate(self): | 1677 def _makedirstate(self): |
1675 """Extension point for wrapping the dirstate per-repo.""" | 1678 """Extension point for wrapping the dirstate per-repo.""" |
1676 sparsematchfn = lambda: sparse.matcher(self) | 1679 sparsematchfn = lambda: sparse.matcher(self) |
1677 | 1680 |
1678 return dirstate.dirstate( | 1681 return dirstate.dirstate( |
1679 self.vfs, self.ui, self.root, self._dirstatevalidate, sparsematchfn | 1682 self.vfs, |
1683 self.ui, | |
1684 self.root, | |
1685 self._dirstatevalidate, | |
1686 sparsematchfn, | |
1687 self.nodeconstants, | |
1680 ) | 1688 ) |
1681 | 1689 |
1682 def _dirstatevalidate(self, node): | 1690 def _dirstatevalidate(self, node): |
1683 try: | 1691 try: |
1684 self.changelog.rev(node) | 1692 self.changelog.rev(node) |