diff mercurial/repair.py @ 32629:71eb6a098315

strip: strip obsmarkers exclusive to the stripped changeset This is it, `hg strip --rev X` will now also remove obsolescence markers exclusive to X. Since a previous changeset, the obsmarkers has been backed up in the strip backup bundle, so it is possible to restore them. Note: stripping obsmarkers means the precursors of the stripped changeset might no longer be obsolete after the strip. Stripping changeset without obsmarkers can be useful when building test case. So It is possible to disable the stripping of obsmarkers using the 'devel.strip-obsmarkers' config option. Test change have been carefully validated.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 20 May 2017 16:19:59 +0200
parents 5732e6d2b369
children 0a41902879d3
line wrap: on
line diff
--- a/mercurial/repair.py	Thu Jun 01 12:08:49 2017 +0200
+++ b/mercurial/repair.py	Sat May 20 16:19:59 2017 +0200
@@ -122,6 +122,13 @@
     savebases = [cl.node(r) for r in saverevs]
     stripbases = [cl.node(r) for r in tostrip]
 
+    stripobsidx = obsmarkers = ()
+    if repo.ui.configbool('devel', 'strip-obsmarkers', True):
+        obsmarkers = obsolete.exclusivemarkers(repo, stripbases)
+    if obsmarkers:
+        stripobsidx = [i for i, m in enumerate(repo.obsstore)
+                       if m in obsmarkers]
+
     # For a set s, max(parents(s) - s) is the same as max(heads(::s - s)), but
     # is much faster
     newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip)
@@ -185,6 +192,9 @@
                 if troffset == 0:
                     repo.store.markremoved(file)
 
+            deleteobsmarkers(repo.obsstore, stripobsidx)
+            del repo.obsstore
+
         if tmpbundlefile:
             ui.note(_("adding branch\n"))
             f = vfs.open(tmpbundlefile, "rb")