Patchwork [6,of,7] journal: ensure that dirstate is instantiated via own wrapdirstate()

login
register
mail settings
Submitter Katsunori FUJIWARA
Date July 2, 2017, 5:53 p.m.
Message ID <0dcbaa178353e32b23e1.1499018000@speaknoevil>
Download mbox | patch
Permalink /patch/21923/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - July 2, 2017, 5:53 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1499017960 -32400
#      Mon Jul 03 02:52:40 2017 +0900
# Node ID 0dcbaa178353e32b23e13bc8655a6a90978b639d
# Parent  9fd405b51136176f2498561bbd0a0c485a1f2eac
journal: ensure that dirstate is instantiated via own wrapdirstate()

If dirstate is instantiated before reposetup() of journal extension,
it doesn't have "journalstorage" property, even if it is instantiated
by wrapdirstate() wrapping repo.dirstate, because wrapdirstate() works
as normal repo.dirstate before marking repo as journal-ed in
reposetup().

To ensure that dirstate is instantiated via own wrapdirstate(), this
patch completely discards already instantiated dirstate, like as
previous patch for fsmonitor.

Patch

diff --git a/hgext/journal.py b/hgext/journal.py
--- a/hgext/journal.py
+++ b/hgext/journal.py
@@ -70,6 +70,18 @@  def reposetup(ui, repo):
     if repo.local():
         repo.journal = journalstorage(repo)
 
+        # Completely discard dirstate, in order to ensure that
+        # dirstate is instantiated via wrapdirstate() after this
+        # reposetup(). Otherwise, recorddirstateparents() omits
+        # recording, because repo.dirstate already instantiated at
+        # this point doesn't have "journalstorage" property.
+        if 'dirstate' in repo._filecache:
+            del repo._filecache['dirstate']
+            try:
+                delattr(repo.unfiltered(), 'dirstate')
+            except AttributeError:
+                pass
+
 def runcommand(orig, lui, repo, cmd, fullargs, *args):
     """Track the command line options for recording in the journal"""
     journalstorage.recordcommand(*fullargs)