keyword: use `update_file_p1` instead of `normallookup`
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 19 Jul 2021 02:05:29 +0200
changeset 47736 b9086ec4d28b
parent 47735 20c2a15cd47a
child 47737 e0e69a7d7af8
keyword: use `update_file_p1` instead of `normallookup` This is the newer, more semantic API. Differential Revision: https://phab.mercurial-scm.org/D11178
hgext/keyword.py
--- a/hgext/keyword.py	Mon Jul 19 05:41:32 2021 +0200
+++ b/hgext/keyword.py	Mon Jul 19 02:05:29 2021 +0200
@@ -358,7 +358,7 @@
                 if kwcmd:
                     self.repo.dirstate.set_clean(f)
                 elif self.postcommit:
-                    self.repo.dirstate.normallookup(f)
+                    self.repo.dirstate.update_file_p1(f, p1_tracked=True)
 
     def shrink(self, fname, text):
         '''Returns text with all keyword substitutions removed.'''
@@ -691,7 +691,7 @@
     kwt = getattr(repo, '_keywordkwt', None)
     if kwt is None:
         return orig(ui, repo, old, extra, pats, opts)
-    with repo.wlock():
+    with repo.wlock(), repo.dirstate.parentchange():
         kwt.postcommit = True
         newid = orig(ui, repo, old, extra, pats, opts)
         if newid != old.node():
@@ -757,8 +757,9 @@
         if ctx != recctx:
             modified, added = _preselect(wstatus, recctx.files())
             kwt.restrict = False
-            kwt.overwrite(recctx, modified, False, True)
-            kwt.overwrite(recctx, added, False, True, True)
+            with repo.dirstate.parentchange():
+                kwt.overwrite(recctx, modified, False, True)
+                kwt.overwrite(recctx, added, False, True, True)
             kwt.restrict = True
         return ret