[PATCH 2 of 7 V2] dirstate: remove layering violation around writing dirstate out

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Oct 16 11:22:32 CDT 2015


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1445012134 -32400
#      Sat Oct 17 01:15:34 2015 +0900
# Node ID f4f6af8376490aa4d46996a9ad9ea4d9aaeefcad
# Parent  6c9502c865e33eb9c1d29a21a35de2425b99805d
dirstate: remove layering violation around writing dirstate out

This violation, which passes repo object to dirstate, was introduced
by 09bb1ee7e73e.

This patch uses 'False' instead of 'None' as default value of 'tr'
argument, to distinguish "None as repo.currenttransaction() result"
from "legacy invocation without explicit tr passing".

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -648,7 +648,7 @@
         self._pl = (parent, nullid)
         self._dirty = True
 
-    def write(self, repo=None):
+    def write(self, tr=False):
         if not self._dirty:
             return
 
@@ -660,17 +660,13 @@
             time.sleep(delaywrite)
 
         filename = self._filename
-        if not repo:
-            tr = None
+        if tr is False: # not explicitly specified
             if self._opener.lexists(self._pendingfilename):
                 # if pending file already exists, in-memory changes
                 # should be written into it, because it has priority
                 # to '.hg/dirstate' at reading under HG_PENDING mode
                 filename = self._pendingfilename
-        else:
-            tr = repo.currenttransaction()
-
-        if tr:
+        elif tr:
             # 'dirstate.write()' is not only for writing in-memory
             # changes out, but also for dropping ambiguous timestamp.
             # delayed writing re-raise "ambiguous timestamp issue".
@@ -678,7 +674,7 @@
             # https://www.mercurial-scm.org/wiki/DirstateTransactionPlan
 
             # emulate dropping timestamp in 'parsers.pack_dirstate'
-            now = _getfsnow(repo.vfs)
+            now = _getfsnow(self._opener)
             dmap = self._map
             for f, e in dmap.iteritems():
                 if e[0] == 'n' and e[3] == now:


More information about the Mercurial-devel mailing list