Patchwork D11587: dirstate: align the dirstate's API to the lower level ones

login
register
mail settings
Submitter phabricator
Date Oct. 3, 2021, 12:26 a.m.
Message ID <differential-rev-PHID-DREV-s3rsnvkwvxqhschit3ll-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49912/
State Superseded
Headers show

Comments

phabricator - Oct. 3, 2021, 12:26 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This conclude the refactoring of this API. We can now finalize the dirstate v2
  on disk format.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11587

AFFECTED FILES
  hgext/largefiles/lfutil.py
  mercurial/dirstate.py
  mercurial/mergestate.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -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:
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -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,
         )
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 @@ 
     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):