Patchwork D11209: fix: rewrite writeworkingdir() to explicitly not work with merges

login
register
mail settings
Submitter phabricator
Date July 23, 2021, 7:17 a.m.
Message ID <differential-rev-PHID-DREV-omv6lmrgpvtptne3stjb-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49523/
State Superseded
Headers show

Comments

phabricator - July 23, 2021, 7:17 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  `hg fix` errors out early if there is an unfinished merge, so we
  should have only one parent here. Making that explicit makes my next
  patches simpler.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/fix.py

CHANGE DETAILS




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

Patch

diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -133,6 +133,7 @@ 
 from mercurial.i18n import _
 from mercurial.node import (
     nullrev,
+    nullid,
     wdirrev,
 )
 
@@ -753,16 +754,18 @@ 
 
     Directly updates the dirstate for the affected files.
     """
+    assert repo.dirstate.p2() == nullid
+
     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)
 
-    oldparentnodes = repo.dirstate.parents()
-    newparentnodes = [replacements.get(n, n) for n in oldparentnodes]
-    if newparentnodes != oldparentnodes:
-        repo.setparents(*newparentnodes)
+    oldp1 = repo.dirstate.p1()
+    newp1 = replacements.get(oldp1, oldp1)
+    if newp1 != oldp1:
+        repo.setparents(newp1, nullid)
 
 
 def replacerev(ui, repo, ctx, filedata, replacements):