strip: ignore orphaned internal changesets while computing safe strip roots
authorBoris Feld <boris.feld@octobus.net>
Wed, 19 Sep 2018 17:09:01 +0200
changeset 39745 b2ec79559a4b
parent 39744 52dfa1eb0ad4
child 39746 25cc5616adc9
strip: ignore orphaned internal changesets while computing safe strip roots Internal changeset can be safely garbage collected, so we can ignore them during safestrip. (Another phase for internal changeset that must be kept in the repository might be introduced later).
mercurial/repair.py
tests/test-shelve.t
--- a/mercurial/repair.py	Wed Jun 06 02:31:46 2018 +0200
+++ b/mercurial/repair.py	Wed Sep 19 17:09:01 2018 +0200
@@ -24,6 +24,7 @@
     exchange,
     obsolete,
     obsutil,
+    phases,
     pycompat,
     util,
 )
@@ -276,7 +277,8 @@
     # orphaned = affected - wanted
     # affected = descendants(roots(wanted))
     # wanted = revs
-    tostrip = set(repo.revs('%ld-(::((roots(%ld)::)-%ld))', revs, revs, revs))
+    revset = '%ld - ( ::( (roots(%ld):: and not _phase(%s)) -%ld) )'
+    tostrip = set(repo.revs(revset, revs, revs, phases.internal, revs))
     notstrip = revs - tostrip
     if notstrip:
         nodestr = ', '.join(sorted(short(repo[n].node()) for n in notstrip))
--- a/tests/test-shelve.t	Wed Jun 06 02:31:46 2018 +0200
+++ b/tests/test-shelve.t	Wed Sep 19 17:09:01 2018 +0200
@@ -669,19 +669,10 @@
   shelved as default
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
-#if phasebased
   $ hg rebase -d 6c103be8f4e4 --config extensions.rebase=
-  rebasing 2:323bfa07f744 "xyz"
+  rebasing 2:323bfa07f744 "xyz"( \(tip\))? (re)
   merging x
-  warning: orphaned descendants detected, not stripping 323bfa07f744 (?)
-#endif
-
-#if stripbased
-  $ hg rebase -d 6c103be8f4e4 --config extensions.rebase=
-  rebasing 2:323bfa07f744 "xyz" (tip)
-  merging x
-  saved backup bundle to $TESTTMP/shelverebase/.hg/strip-backup/323bfa07f744-78114325-rebase.hg
-#endif
+  saved backup bundle to \$TESTTMP/shelverebase/.hg/strip-backup/323bfa07f744-(78114325|7ae538ef)-rebase.hg (re)
   $ hg unshelve
   unshelving change 'default'
   rebasing shelved changes