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".
--- a/mercurial/dirstate.py Sat Oct 17 01:15:33 2015 +0900
+++ b/mercurial/dirstate.py Sat Oct 17 01:15:34 2015 +0900
@@ -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: