Patchwork D11172: record: use `update_file` instead of `normallookup`

login
register
mail settings
Submitter phabricator
Date July 19, 2021, 2:11 p.m.
Message ID <differential-rev-PHID-DREV-qu7gpwgtemhlh4bu2pq2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49489/
State Superseded
Headers show

Comments

phabricator - July 19, 2021, 2:11 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We are cheating a bit to enforce we are in a pending change context. This will
  have to be cleaned up later.
  
  The end goal is reached, we are now using the newer, more semantic API.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/dirstate.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -507,7 +507,7 @@ 
         self._normal(filename, parentfiledata=parentfiledata)
 
     @requires_no_parents_change
-    def set_possibly_dirty(self, filename):
+    def set_possibly_dirty(self, filename, disregard_size=False):
         """record that the current state of the file on disk is unknown"""
         self._dirty = True
         self._updatedfiles.add(filename)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -630,7 +630,19 @@ 
                         # without normallookup, restoring timestamp
                         # may cause partially committed files
                         # to be treated as unmodified
-                        dirstate.normallookup(realname)
+
+                        # XXX-PENDINGCHANGE: We should clarify the context in
+                        # which this function is called  to make sure it
+                        # already called within a `pendingchange`, However we
+                        # are taking a shortcut here in order to be able to
+                        # quickly deprecated the older API.
+                        with dirstate.parentchange():
+                            dirstate.update_file(
+                                realname,
+                                p1_tracked=True,
+                                wc_tracked=True,
+                                possibly_dirty=True,
+                            )
 
                     # copystat=True here and above are a hack to trick any
                     # editors that have f open that we haven't modified them.