D1354: dirstate: change all writes to dirstatemap._map to go through one method

mbolin (Michael Bolin) phabricator at mercurial-scm.org
Mon Dec 11 14:06:57 EST 2017


mbolin added a comment.


  @durin42 Here's the implementation of this method we are using in Eden:
  
    def _insert_tuple(self, filename, state, mode, size, mtime):  # override
        if size != MERGE_STATE_BOTH_PARENTS and size != MERGE_STATE_OTHER_PARENT:
            merge_state = MERGE_STATE_NOT_APPLICABLE
        else:
            merge_state = size
    
        self._map[filename] = (state, mode, merge_state)
  
  As you can see, we want to do some conditional logic before doing the insert into `self._map` (and we end up dropping one of the tuple fields), so it seemed like the most straightforward thing for Eden to do is to intercept the writes. It's true that we could also redefine `dirstatetuple()`, but I think that's more confusing because there are places where we need to convert between Eden's internal tuples stored in `eden_dirstate_map` and the `dirstatetuple` type that Mercurial expects everywhere else, so I'm disinclined to conflate the two things.

REPOSITORY
  rHG Mercurial

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

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


More information about the Mercurial-devel mailing list