diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -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):
diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -370,7 +370,6 @@
   M hello.whole
   $ hg fix -s . *
   $ hg st
-  M hello.whole (known-bad-output !)
   $ hg diff
 
   $ cd ..