Mercurial > hg
changeset 48120:fe6617715464
dirstatemap: use a common __init__ for dirstatemap
This is the first and simplest things to put in common.
Differential Revision: https://phab.mercurial-scm.org/D11565
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 01 Oct 2021 16:52:44 +0200 |
parents | aec5b0981c26 |
children | 5fc2dfb073d6 |
files | mercurial/dirstatemap.py |
diffstat | 1 files changed, 24 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dirstatemap.py Fri Oct 01 16:14:29 2021 +0200 +++ b/mercurial/dirstatemap.py Fri Oct 01 16:52:44 2021 +0200 @@ -41,6 +41,20 @@ class, with and without Rust extensions enabled. """ + def __init__(self, ui, opener, root, nodeconstants, use_dirstate_v2): + self._use_dirstate_v2 = use_dirstate_v2 + self._nodeconstants = nodeconstants + self._ui = ui + self._opener = opener + self._root = root + self._filename = b'dirstate' + self._nodelen = 20 # Also update Rust code when changing this! + self._parents = None + self._dirtyparents = False + + # for consistent view between _pl() and _read() invocations + self._pendingmode = None + class dirstatemap(_dirstatemapcommon): """Map encapsulating the dirstate's contents. @@ -77,21 +91,13 @@ """ def __init__(self, ui, opener, root, nodeconstants, use_dirstate_v2): - self._ui = ui - self._opener = opener - self._root = root - self._filename = b'dirstate' - self._nodelen = 20 - self._nodeconstants = nodeconstants - assert ( - not use_dirstate_v2 - ), "should have detected unsupported requirement" - - self._parents = None - self._dirtyparents = False - - # for consistent view between _pl() and _read() invocations - self._pendingmode = None + super(dirstatemap, self).__init__( + ui, opener, root, nodeconstants, use_dirstate_v2 + ) + if self._use_dirstate_v2: + msg = "Dirstate V2 not supportedi" + msg += "(should have detected unsupported requirement)" + raise error.ProgrammingError(msg) @propertycache def _map(self): @@ -469,20 +475,11 @@ class dirstatemap(_dirstatemapcommon): def __init__(self, ui, opener, root, nodeconstants, use_dirstate_v2): - self._use_dirstate_v2 = use_dirstate_v2 - self._nodeconstants = nodeconstants - self._ui = ui - self._opener = opener - self._root = root - self._filename = b'dirstate' - self._nodelen = 20 # Also update Rust code when changing this! - self._parents = None - self._dirtyparents = False + super(dirstatemap, self).__init__( + ui, opener, root, nodeconstants, use_dirstate_v2 + ) self._docket = None - # for consistent view between _pl() and _read() invocations - self._pendingmode = None - def addfile( self, f,