# HG changeset patch # User Pierre-Yves David # Date 2023-02-20 13:05:19 # Node ID dae8dda6f5822cdcac61a24e78f7935de7af9618 # Parent 62158471d038915faf47d57192fdb00244e7680a debugrebuildstate: wrap the operation in a `changing_parents` context This ismaybe a "changing_files" case? However this would be the only usage of `rebuild` outside a `changing_parents` context and this is a debug command, so lets not make the code base more complex because of that one command. diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -3142,8 +3142,8 @@ def debugrebuilddirstate(ui, repo, rev, dsnotadded = {f for f in dsonly if not dirstate.get_entry(f).added} changedfiles = manifestonly | dsnotadded - dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles) - dirstate.write(repo.currenttransaction()) + with dirstate.changing_parents(repo): + dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles) @command(