Patchwork [2,of,2] safestrip: ignore orphaned internal changesets

login
register
mail settings
Submitter Boris Feld
Date Sept. 21, 2018, 11:49 a.m.
Message ID <96e9e9ad53fb5c44ee2d.1537530591@localhost.localdomain>
Download mbox | patch
Permalink /patch/34892/
State Accepted
Headers show

Comments

Boris Feld - Sept. 21, 2018, 11:49 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1537369741 -7200
#      Wed Sep 19 17:09:01 2018 +0200
# Node ID 96e9e9ad53fb5c44ee2d4ff92d193e69f80a14b7
# Parent  e47e45bd5fd68bec6e3bb9aa159d1ca9883117f3
# EXP-Topic internal-phase.shelve
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 96e9e9ad53fb
safestrip: ignore orphaned internal changesets

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).
Yuya Nishihara - Sept. 21, 2018, 12:39 p.m.
On Fri, 21 Sep 2018 13:49:51 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1537369741 -7200
> #      Wed Sep 19 17:09:01 2018 +0200
> # Node ID 96e9e9ad53fb5c44ee2d4ff92d193e69f80a14b7
> # Parent  e47e45bd5fd68bec6e3bb9aa159d1ca9883117f3
> # EXP-Topic internal-phase.shelve
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 96e9e9ad53fb
> safestrip: ignore orphaned internal changesets

Queued, thanks. I've rewritten the summary line as "strip: ignore orphaned
internal changesets while computing safe strip roots" since "safestrip" seemed
too specific to be a topic.

Patch

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -24,6 +24,7 @@  from . import (
     exchange,
     obsolete,
     obsutil,
+    phases,
     pycompat,
     util,
 )
@@ -276,7 +277,8 @@  def safestriproots(ui, repo, nodes):
     # 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))
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -669,19 +669,10 @@  shelve should leave dirstate clean (issu
   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