# HG changeset patch # User Martin von Zweigbergk # Date 1552327016 25200 # Node ID 3feda1e779d48c0e66c28a4697f765b6c283fdff # Parent 184d83ef2e5977414b4b0af8a1b3958e9c4c8ad4 fix: rewrite writeworkingdir() to explicitly not work with merges `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. Differential Revision: https://phab.mercurial-scm.org/D11209 diff -r 184d83ef2e59 -r 3feda1e779d4 hgext/fix.py --- a/hgext/fix.py Thu Jul 22 17:12:56 2021 -0700 +++ b/hgext/fix.py Mon Mar 11 10:56:56 2019 -0700 @@ -132,6 +132,7 @@ from mercurial.i18n import _ from mercurial.node import ( + nullid, nullrev, 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):