Mercurial > hg
comparison mercurial/repair.py @ 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 | d44e3c45f0e4 |
children | 71a2c061865d |
comparison
equal
deleted
inserted
replaced
50393:f95ab2c53303 | 50394:7a017cd07a1e |
---|---|
347 | 347 |
348 | 348 |
349 def _createstripbackup(repo, stripbases, node, topic): | 349 def _createstripbackup(repo, stripbases, node, topic): |
350 # backup the changeset we are about to strip | 350 # backup the changeset we are about to strip |
351 vfs = repo.vfs | 351 vfs = repo.vfs |
352 cl = repo.changelog | 352 unfi = repo.unfiltered() |
353 backupfile = backupbundle(repo, stripbases, cl.heads(), node, topic) | 353 to_node = unfi.changelog.node |
354 all_backup = unfi.revs( | |
355 b"(%ln)::(%ld)", stripbases, unfi.changelog.headrevs() | |
356 ) | |
357 if not all_backup: | |
358 return None | |
359 | |
360 def to_nodes(revs): | |
361 return [to_node(r) for r in revs] | |
362 | |
363 simpler_bases = to_nodes( | |
364 unfi.revs("roots(%ln::%ln)", stripbases, stripbases) | |
365 ) | |
366 bases = to_nodes(unfi.revs("roots(%ld)", all_backup)) | |
367 heads = to_nodes(unfi.revs("heads(%ld)", all_backup)) | |
368 assert bases == simpler_bases | |
369 assert set(heads).issubset(set(repo.changelog.heads())) | |
370 backupfile = backupbundle(repo, bases, heads, node, topic) | |
354 repo.ui.status(_(b"saved backup bundle to %s\n") % vfs.join(backupfile)) | 371 repo.ui.status(_(b"saved backup bundle to %s\n") % vfs.join(backupfile)) |
355 repo.ui.log( | 372 repo.ui.log( |
356 b"backupbundle", b"saved backup bundle to %s\n", vfs.join(backupfile) | 373 b"backupbundle", b"saved backup bundle to %s\n", vfs.join(backupfile) |
357 ) | 374 ) |
358 return backupfile | 375 return backupfile |