# HG changeset patch # User Pierre-Yves David # Date 2021-09-30 14:33:12 # Node ID 6f54afb094bd843e76f44e225159bbc468d59105 # Parent 21542d4cb56829262b9856474accd50058687ed9 dirstate: align the dirstate's API to the lower level ones This conclude the refactoring of this API. We can now finalize the dirstate v2 on disk format. Differential Revision: https://phab.mercurial-scm.org/D11587 diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -558,24 +558,14 @@ def synclfdirstate(repo, lfdirstate, lfi if lfstandin not in repo.dirstate: lfdirstate.update_file(lfile, p1_tracked=False, wc_tracked=False) else: - stat = repo.dirstate.get_entry(lfstandin) - state, mtime = stat.state, stat.mtime - if state == b'n': - if normallookup or mtime < 0 or not repo.wvfs.exists(lfile): - # state 'n' doesn't ensure 'clean' in this case - lfdirstate.update_file( - lfile, p1_tracked=True, wc_tracked=True, possibly_dirty=True - ) - else: - lfdirstate.update_file(lfile, p1_tracked=True, wc_tracked=True) - elif state == b'm': - lfdirstate.update_file( - lfile, p1_tracked=True, wc_tracked=True, merged=True - ) - elif state == b'r': - lfdirstate.update_file(lfile, p1_tracked=True, wc_tracked=False) - elif state == b'a': - lfdirstate.update_file(lfile, p1_tracked=False, wc_tracked=True) + entry = repo.dirstate.get_entry(lfstandin) + lfdirstate.update_file( + lfile, + wc_tracked=entry.tracked, + p1_tracked=entry.p1_tracked, + p2_info=entry.p2_info, + possibly_dirty=True, + ) def markcommitted(orig, ctx, node): diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -553,10 +553,7 @@ class dirstate(object): filename, wc_tracked, p1_tracked, - p2_tracked=False, - merged=False, - clean_p1=False, - clean_p2=False, + p2_info=False, possibly_dirty=False, parentfiledata=None, ): @@ -571,9 +568,6 @@ class dirstate(object): depending of what information ends up being relevant and useful to other processing. """ - if merged and (clean_p1 or clean_p2): - msg = b'`merged` argument incompatible with `clean_p1`/`clean_p2`' - raise error.ProgrammingError(msg) # note: I do not think we need to double check name clash here since we # are in a update/merge case that should already have taken care of @@ -582,9 +576,7 @@ class dirstate(object): self._dirty = True need_parent_file_data = ( - not (possibly_dirty or clean_p2 or merged) - and wc_tracked - and p1_tracked + not possibly_dirty and not p2_info and wc_tracked and p1_tracked ) # this mean we are doing call for file we do not really care about the @@ -606,7 +598,7 @@ class dirstate(object): filename, wc_tracked, p1_tracked, - p2_info=merged or clean_p2, + p2_info=p2_info, has_meaningful_mtime=not possibly_dirty, parentfiledata=parentfiledata, ) diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py --- a/mercurial/mergestate.py +++ b/mercurial/mergestate.py @@ -801,10 +801,8 @@ def recordupdates(repo, actions, branchm repo.dirstate.update_file( f, p1_tracked=p1_tracked, - p2_tracked=True, wc_tracked=True, - clean_p2=not p1_tracked, - merged=p1_tracked, + p2_info=True, ) else: parentfiledata = getfiledata[f] if getfiledata else None @@ -822,14 +820,11 @@ def recordupdates(repo, actions, branchm # We've done a branch merge, mark this file as merged # so that we properly record the merger later p1_tracked = f1 == f - p2_tracked = f2 == f repo.dirstate.update_file( f, p1_tracked=p1_tracked, - p2_tracked=p2_tracked, wc_tracked=True, - merged=p1_tracked, - clean_p2=not p1_tracked, + p2_info=True, ) if f1 != f2: # copy/rename if move: