changeset 47767:66ad7e32011f stable

fix: use scmutil.movedirstate() instead of reimplementing I wrote this patch 2 years ago as a little cleanup. I wanted to generally used `scmutil.movedirstate()` instead of manually updating the dirstate because that is easy to get wrong. I didn't know until today that the current code had a bug. So I added the test case two patches before this one and dusted off this one patch. This is a little slower than the previous code, as it diffs two manifests. However, it fixes the bug and I don't think it's going to be noticeably slower anyway. Differential Revision: https://phab.mercurial-scm.org/D11210
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 11 Mar 2019 10:59:35 -0700
parents 3feda1e779d4
children c2b8ad34d245
files hgext/fix.py tests/test-fix.t
diffstat 2 files changed, 2 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/fix.py	Mon Mar 11 10:56:56 2019 -0700
+++ b/hgext/fix.py	Mon Mar 11 10:59:35 2019 -0700
@@ -759,13 +759,12 @@
     for path, data in pycompat.iteritems(filedata):
         fctx = ctx[path]
         fctx.write(data, fctx.flags())
-        if repo.dirstate[path] == b'n':
-            repo.dirstate.set_possibly_dirty(path)
 
     oldp1 = repo.dirstate.p1()
     newp1 = replacements.get(oldp1, oldp1)
     if newp1 != oldp1:
-        repo.setparents(newp1, nullid)
+        with repo.dirstate.parentchange():
+            scmutil.movedirstate(repo, repo[newp1])
 
 
 def replacerev(ui, repo, ctx, filedata, replacements):
--- a/tests/test-fix.t	Mon Mar 11 10:56:56 2019 -0700
+++ b/tests/test-fix.t	Mon Mar 11 10:59:35 2019 -0700
@@ -370,7 +370,6 @@
   M hello.whole
   $ hg fix -s . *
   $ hg st
-  M hello.whole (known-bad-output !)
   $ hg diff
 
   $ cd ..