changeset 50394:7a017cd07a1e

strip: explicitly compute the boundary of the backup bundle We want to make change to the set of backed up revision in a future changeset, we start with a change of the computation without any changes in the semantic to clarify later changeset. The could of costly assert are here to testify that the result is still correct. They will be removed in the next changesets, but I wanted them in this changeset to help in case someone bisect a regression to this changeset in the future.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 09 Mar 2023 15:06:59 +0100
parents f95ab2c53303
children 71a2c061865d
files mercurial/repair.py
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/repair.py	Fri Mar 10 04:04:10 2023 +0100
+++ b/mercurial/repair.py	Thu Mar 09 15:06:59 2023 +0100
@@ -349,8 +349,25 @@
 def _createstripbackup(repo, stripbases, node, topic):
     # backup the changeset we are about to strip
     vfs = repo.vfs
-    cl = repo.changelog
-    backupfile = backupbundle(repo, stripbases, cl.heads(), node, topic)
+    unfi = repo.unfiltered()
+    to_node = unfi.changelog.node
+    all_backup = unfi.revs(
+        b"(%ln)::(%ld)", stripbases, unfi.changelog.headrevs()
+    )
+    if not all_backup:
+        return None
+
+    def to_nodes(revs):
+        return [to_node(r) for r in revs]
+
+    simpler_bases = to_nodes(
+        unfi.revs("roots(%ln::%ln)", stripbases, stripbases)
+    )
+    bases = to_nodes(unfi.revs("roots(%ld)", all_backup))
+    heads = to_nodes(unfi.revs("heads(%ld)", all_backup))
+    assert bases == simpler_bases
+    assert set(heads).issubset(set(repo.changelog.heads()))
+    backupfile = backupbundle(repo, bases, heads, node, topic)
     repo.ui.status(_(b"saved backup bundle to %s\n") % vfs.join(backupfile))
     repo.ui.log(
         b"backupbundle", b"saved backup bundle to %s\n", vfs.join(backupfile)