mq: wrap the dirstate's rebuild in a `changing_parents` context
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sun, 19 Feb 2023 02:47:28 +0100
changeset 50160 0ca8dc8a135f
parent 50159 a860298776f0
child 50161 62158471d038
mq: wrap the dirstate's rebuild in a `changing_parents` context This code is dealing with `qreshesh` failure. In that case the working copy will be left on the parent of the refreshed patch, so the parents are changing and `changing_parents` make sens.
hgext/mq.py
--- a/hgext/mq.py	Mon Feb 20 11:37:05 2023 +0100
+++ b/hgext/mq.py	Sun Feb 19 02:47:28 2023 +0100
@@ -2121,9 +2121,9 @@
                 finally:
                     lockmod.release(tr, lock)
             except:  # re-raises
-                ctx = repo[cparents[0]]
-                repo.dirstate.rebuild(ctx.node(), ctx.manifest())
-                repo.dirstate.write(repo.currenttransaction())
+                with repo.dirstate.changing_parents(repo):
+                    ctx = repo[cparents[0]]
+                    repo.dirstate.rebuild(ctx.node(), ctx.manifest())
                 self.savedirty()
                 self.ui.warn(
                     _(