changeset 48144:6f54afb094bd

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
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 30 Sep 2021 16:33:12 +0200
parents 21542d4cb568
children 180e8fa345cc
files hgext/largefiles/lfutil.py mercurial/dirstate.py mercurial/mergestate.py
diffstat 3 files changed, 13 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/lfutil.py	Fri Oct 01 04:07:21 2021 +0200
+++ b/hgext/largefiles/lfutil.py	Thu Sep 30 16:33:12 2021 +0200
@@ -558,24 +558,14 @@
     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):
--- a/mercurial/dirstate.py	Fri Oct 01 04:07:21 2021 +0200
+++ b/mercurial/dirstate.py	Thu Sep 30 16:33:12 2021 +0200
@@ -553,10 +553,7 @@
         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 @@
         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 @@
         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 @@
             filename,
             wc_tracked,
             p1_tracked,
-            p2_info=merged or clean_p2,
+            p2_info=p2_info,
             has_meaningful_mtime=not possibly_dirty,
             parentfiledata=parentfiledata,
         )
--- a/mercurial/mergestate.py	Fri Oct 01 04:07:21 2021 +0200
+++ b/mercurial/mergestate.py	Thu Sep 30 16:33:12 2021 +0200
@@ -801,10 +801,8 @@
             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 @@
             # 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: