workingctx: factor out post-status dirstate fixup
We want to allow extensions to be able to add code to run inside the wlock.
--- a/mercurial/context.py Tue Jun 13 10:02:34 2017 -0400
+++ b/mercurial/context.py Mon Jun 12 13:54:59 2017 -0700
@@ -1738,7 +1738,10 @@
# it's in the dirstate.
deleted.append(f)
- # update dirstate for files that are actually clean
+ return modified, deleted, fixup
+
+ def _poststatusfixup(self, fixup):
+ """update dirstate for files that are actually clean"""
if fixup:
try:
oldid = self._repo.dirstate.identity()
@@ -1767,7 +1770,6 @@
'identity mismatch\n')
except error.LockError:
pass
- return modified, deleted, fixup
def _dirstatestatus(self, match=None, ignored=False, clean=False,
unknown=False):
@@ -1781,15 +1783,17 @@
listclean, listunknown)
# check for any possibly clean files
+ fixup = []
if cmp:
modified2, deleted2, fixup = self._checklookup(cmp)
s.modified.extend(modified2)
s.deleted.extend(deleted2)
- # update dirstate for files that are actually clean
if fixup and listclean:
s.clean.extend(fixup)
+ self._poststatusfixup(fixup)
+
if match.always():
# cache for performance
if s.unknown or s.ignored or s.clean:
--- a/tests/fakedirstatewritetime.py Tue Jun 13 10:02:34 2017 -0400
+++ b/tests/fakedirstatewritetime.py Mon Jun 12 13:54:59 2017 -0700
@@ -2,7 +2,7 @@
# specified by '[fakedirstatewritetime] fakenow', only when
# 'dirstate.write()' is invoked via functions below:
#
-# - 'workingctx._checklookup()' (= 'repo.status()')
+# - 'workingctx._poststatusfixup()' (= 'repo.status()')
# - 'committablectx.markcommitted()'
from __future__ import absolute_import
@@ -55,16 +55,16 @@
parsers.pack_dirstate = orig_pack_dirstate
dirstate._getfsnow = orig_dirstate_getfsnow
-def _checklookup(orig, workingctx, files):
+def _poststatusfixup(orig, workingctx, fixup):
ui = workingctx.repo().ui
- return fakewrite(ui, lambda : orig(workingctx, files))
+ return fakewrite(ui, lambda : orig(workingctx, fixup))
def markcommitted(orig, committablectx, node):
ui = committablectx.repo().ui
return fakewrite(ui, lambda : orig(committablectx, node))
def extsetup(ui):
- extensions.wrapfunction(context.workingctx, '_checklookup',
- _checklookup)
+ extensions.wrapfunction(context.workingctx, '_poststatusfixup',
+ _poststatusfixup)
extensions.wrapfunction(context.committablectx, 'markcommitted',
markcommitted)
--- a/tests/test-dirstate-race.t Tue Jun 13 10:02:34 2017 -0400
+++ b/tests/test-dirstate-race.t Mon Jun 12 13:54:59 2017 -0700
@@ -101,7 +101,7 @@
Test that dirstate changes aren't written out at the end of "hg
status", if .hg/dirstate is already changed simultaneously before
-acquisition of wlock in workingctx._checklookup().
+acquisition of wlock in workingctx._poststatusfixup().
This avoidance is important to keep consistency of dirstate in race
condition (see issue5584 for detail).