Patchwork D1347: dirstate: make map implementation overridable

login
register
mail settings
Submitter phabricator
Date Nov. 8, 2017, 5:31 p.m.
Message ID <differential-rev-PHID-DREV-7avkf6gzszjxyiswfhp4-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/25431/
State Superseded
Headers show

Comments

phabricator - Nov. 8, 2017, 5:31 p.m.
mbthomas created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Other implementations of dirstate will want to replace the class used for the
  dirstate map.  Allow this to happen by making the class an attribute of the
  dirstate.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1347

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS




To: mbthomas, #hg-reviewers
Cc: mercurial-devel
phabricator - Nov. 13, 2017, 10:36 p.m.
durin42 added subscribers: mbolin, durin42.
durin42 accepted this revision as: durin42.
durin42 added a comment.


  I'd prefer this as a class attr, but would like to hear from @mbolin as to whether or not that solves the problem(s) that inspired https://phab.mercurial-scm.org/D1354.

INLINE COMMENTS

> dirstate.py:83
>          self._updatedfiles = set()
> +        self._mapcls = dirstatemap
>  

Could you set this at class-level, rather than in __init__? I think then @mbolin would be able to make his subclass replace the class attribute and that'd be sufficient?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1347

To: mbthomas, #hg-reviewers, durin42
Cc: durin42, mbolin, mercurial-devel
phabricator - Nov. 14, 2017, 7:32 p.m.
mbthomas added a comment.


  I think I need it to be an instance attribute, as for treedirstate it depends on the repo as to whether I want a normal dirstatemap or a treedirstatemap.  See https://phab.mercurial-scm.org/D1401 for where I override this in treedirstate.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1347

To: mbthomas, #hg-reviewers, durin42
Cc: durin42, mbolin, mercurial-devel

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -80,6 +80,7 @@ 
         self._plchangecallbacks = {}
         self._origpl = None
         self._updatedfiles = set()
+        self._mapcls = dirstatemap
 
     @contextlib.contextmanager
     def parentchange(self):
@@ -128,7 +129,7 @@ 
     @propertycache
     def _map(self):
         '''Returns the dirstate map.'''
-        self._map = dirstatemap(self._ui, self._opener, self._root)
+        self._map = self._mapcls(self._ui, self._opener, self._root)
         return self._map
 
     @property