[PATCH 3 of 3 V2] localrepo: use dirstate savebackup instead of handling dirstate file manually
Mateusz Kwapich
mitrandir at fb.com
Wed May 11 17:30:44 EDT 2016
# HG changeset patch
# User Mateusz Kwapich <mitrandir at fb.com>
# Date 1463001532 25200
# Wed May 11 14:18:52 2016 -0700
# Node ID e6344bfba71d3b82e84fe0fac77a6e07cb2e1def
# Parent ff880d9c73800358230da3a7ff447e12a5a91b3c
localrepo: use dirstate savebackup instead of handling dirstate file manually
This is one step towards having dirstate manage its own storage. It will
be useful for the implementation of sql dirstate [1].
This introduced a small test change: now we always write the dirstate before
saving backup so in some cases where dirstate file didn't exist yet
savebackup can create it.
[1] https://www.mercurial-scm.org/wiki/SQLDirstatePlan
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1011,9 +1011,6 @@ class localrepository(object):
_("abandoned transaction found"),
hint=_("run 'hg recover' to clean up transaction"))
- # make journal.dirstate contain in-memory changes at this point
- self.dirstate.write(None)
-
idbase = "%.40f#%f" % (random.random(), time.time())
txnid = 'TXN:' + util.sha1(idbase).hexdigest()
self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid)
@@ -1102,8 +1099,7 @@ class localrepository(object):
return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
def _writejournal(self, desc):
- self.vfs.write("journal.dirstate",
- self.vfs.tryread("dirstate"))
+ self.dirstate.savebackup(None, prefix='journal.')
self.vfs.write("journal.branch",
encoding.fromlocal(self.dirstate.branch()))
self.vfs.write("journal.desc",
diff --git a/tests/test-inherit-mode.t b/tests/test-inherit-mode.t
--- a/tests/test-inherit-mode.t
+++ b/tests/test-inherit-mode.t
@@ -117,6 +117,7 @@ group can still write everything
00660 ../push/.hg/cache/branch2-base
00660 ../push/.hg/cache/rbc-names-v1
00660 ../push/.hg/cache/rbc-revs-v1
+ 00660 ../push/.hg/dirstate
00660 ../push/.hg/requires
00770 ../push/.hg/store/
00660 ../push/.hg/store/00changelog.i
More information about the Mercurial-devel
mailing list