dirstate: move dirstate old id generation to before status

Summary:
A future diff will change filesystem.pendingchanges to actually update
the dirstate when lookup files are resolved. Because of this, we need to compute
the old dirstate id before pendingchanges is called. Let's do that, and pass it
down into the poststatusfixup for usage.

Reviewed By: quark-zju

Differential Revision: D17749372

fbshipit-source-id: a7698ff1ef4aab2805e19929ac2f70841dd0fc3c
This commit is contained in:
Durham Goode 2019-10-16 17:38:30 -07:00 committed by Facebook Github Bot
parent 66213fa0f2
commit 815b95c925
2 changed files with 5 additions and 6 deletions

View File

@ -866,6 +866,7 @@ class dirstate(object):
nonnormalset = dmap.nonnormalset
otherparentset = dmap.otherparentset
oldid = self.identity()
# Step 1: Get the files that are different from the clean checkedout p1 tree.
pendingchanges = self._fs.pendingchanges(match, listignored=listignored)
@ -1031,7 +1032,7 @@ class dirstate(object):
match.bad(path, encoding.strtolocal(ex.strerror))
if not getattr(self._repo, "_insidepoststatusfixup", False):
self._poststatusfixup(status, fixup, wctx)
self._poststatusfixup(status, fixup, wctx, oldid)
perftrace.tracevalue("A/M/R Files", len(modified) + len(added) + len(removed))
if len(unknown) > 0:
@ -1087,7 +1088,7 @@ class dirstate(object):
return modified, deleted, fixup
def _poststatusfixup(self, status, fixup, wctx):
def _poststatusfixup(self, status, fixup, wctx, oldid):
"""update dirstate for files that are actually clean"""
poststatusbefore = self._repo.postdsstatus(afterdirstatewrite=False)
poststatusafter = self._repo.postdsstatus(afterdirstatewrite=True)
@ -1097,8 +1098,6 @@ class dirstate(object):
# wctx.status()
self._repo._insidepoststatusfixup = True
try:
oldid = self.identity()
# Updating the dirstate is optional so we don't wait on the
# lock.
# wlock can invalidate the dirstate, so cache normal _after_

View File

@ -67,9 +67,9 @@ def fakewrite(ui, func):
dirstate._getfsnow = orig_dirstate_getfsnow
def _poststatusfixup(orig, self, status, fixup, workingctx):
def _poststatusfixup(orig, self, status, fixup, workingctx, oldid):
ui = workingctx.repo().ui
return fakewrite(ui, lambda: orig(self, status, fixup, workingctx))
return fakewrite(ui, lambda: orig(self, status, fixup, workingctx, oldid))
def markcommitted(orig, committablectx, node):