rewriteutil: say how many commits would become orphan if commit is rewritten
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 04 May 2021 10:49:32 -0700
changeset 47070 d90f6237b3aa
parent 47069 5b6dd0d9171b
child 47071 3e381eb557f3
rewriteutil: say how many commits would become orphan if commit is rewritten This copies the message from the evolve extension, but modifies it a bit to work with the grammar (in particular with the use of "change branch of" as `action`). I don't know why it doesn't use the same `_formatrevs()` as for public commmits. Differential Revision: https://phab.mercurial-scm.org/D10671
mercurial/rewriteutil.py
tests/test-amend.t
tests/test-branch-change.t
tests/test-fix.t
tests/test-rebase-collapse.t
tests/test-rebase-scenario-global.t
tests/test-split.t
tests/test-unamend.t
--- a/mercurial/rewriteutil.py	Tue May 04 10:16:34 2021 -0700
+++ b/mercurial/rewriteutil.py	Tue May 04 10:49:32 2021 -0700
@@ -80,7 +80,9 @@
     if newunstable:
         hint = _(b"see 'hg help evolution.instability'")
         raise error.InputError(
-            _(b"cannot %s changeset with children") % action, hint=hint
+            _(b"cannot %s changeset, as that will orphan %d descendants")
+            % (action, len(newunstable)),
+            hint=hint,
         )
 
     if not obsolete.isenabled(repo, obsolete.allowdivergenceopt):
--- a/tests/test-amend.t	Tue May 04 10:16:34 2021 -0700
+++ b/tests/test-amend.t	Tue May 04 10:49:32 2021 -0700
@@ -196,7 +196,7 @@
   $ hg update -q B
   $ echo 2 >> B
   $ hg amend
-  abort: cannot amend changeset with children
+  abort: cannot amend changeset, as that will orphan 1 descendants
   (see 'hg help evolution.instability')
   [10]
 
--- a/tests/test-branch-change.t	Tue May 04 10:16:34 2021 -0700
+++ b/tests/test-branch-change.t	Tue May 04 10:49:32 2021 -0700
@@ -57,7 +57,7 @@
 Change in middle of the stack (linear commits)
 
   $ hg branch -r 1::3 foo
-  abort: cannot change branch of changeset with children
+  abort: cannot change branch of changeset, as that will orphan 1 descendants
   (see 'hg help evolution.instability')
   [10]
 
@@ -129,7 +129,7 @@
 Changing on a branch head which is not topological head
 
   $ hg branch -r 2 stable
-  abort: cannot change branch of changeset with children
+  abort: cannot change branch of changeset, as that will orphan 2 descendants
   (see 'hg help evolution.instability')
   [10]
 
--- a/tests/test-fix.t	Tue May 04 10:16:34 2021 -0700
+++ b/tests/test-fix.t	Tue May 04 10:49:32 2021 -0700
@@ -1172,7 +1172,7 @@
   $ printf "two\n" > foo.whole
   $ hg commit -m "second"
   $ hg --config experimental.evolution.allowunstable=False fix -r '.^'
-  abort: cannot fix changeset with children
+  abort: cannot fix changeset, as that will orphan 1 descendants
   (see 'hg help evolution.instability')
   [10]
   $ hg fix -r '.^'
--- a/tests/test-rebase-collapse.t	Tue May 04 10:16:34 2021 -0700
+++ b/tests/test-rebase-collapse.t	Tue May 04 10:49:32 2021 -0700
@@ -549,7 +549,7 @@
   o  0: f447d5abf5ea 'add'
   
   $ hg rebase --collapse -r 1 -d 0
-  abort: cannot rebase changeset with children
+  abort: cannot rebase changeset, as that will orphan 1 descendants
   (see 'hg help evolution.instability')
   [10]
 
--- a/tests/test-rebase-scenario-global.t	Tue May 04 10:16:34 2021 -0700
+++ b/tests/test-rebase-scenario-global.t	Tue May 04 10:49:32 2021 -0700
@@ -452,7 +452,7 @@
   $ hg clone -q -u . ah ah1
   $ cd ah1
   $ hg rebase -r '2::8' -d 1
-  abort: cannot rebase changeset with children
+  abort: cannot rebase changeset, as that will orphan 2 descendants
   (see 'hg help evolution.instability')
   [10]
   $ hg rebase -r '2::8' -d 1 -k
@@ -498,7 +498,7 @@
   $ hg clone -q -u . ah ah2
   $ cd ah2
   $ hg rebase -r '3::8' -d 1
-  abort: cannot rebase changeset with children
+  abort: cannot rebase changeset, as that will orphan 2 descendants
   (see 'hg help evolution.instability')
   [10]
   $ hg rebase -r '3::8' -d 1 --keep
@@ -541,7 +541,7 @@
   $ hg clone -q -u . ah ah3
   $ cd ah3
   $ hg rebase -r '3::7' -d 1
-  abort: cannot rebase changeset with children
+  abort: cannot rebase changeset, as that will orphan 3 descendants
   (see 'hg help evolution.instability')
   [10]
   $ hg rebase -r '3::7' -d 1 --keep
@@ -581,7 +581,7 @@
   $ hg clone -q -u . ah ah4
   $ cd ah4
   $ hg rebase -r '3::(7+5)' -d 1
-  abort: cannot rebase changeset with children
+  abort: cannot rebase changeset, as that will orphan 1 descendants
   (see 'hg help evolution.instability')
   [10]
   $ hg rebase -r '3::(7+5)' -d 1 --keep
--- a/tests/test-split.t	Tue May 04 10:16:34 2021 -0700
+++ b/tests/test-split.t	Tue May 04 10:49:32 2021 -0700
@@ -466,7 +466,7 @@
   $ cd $TESTTMP/d
 #if obsstore-off
   $ runsplit -r 1 --no-rebase
-  abort: cannot split changeset with children
+  abort: cannot split changeset, as that will orphan 3 descendants
   (see 'hg help evolution.instability')
   [10]
 #else
@@ -518,7 +518,7 @@
   $ eval `hg tags -T '{tag}={node}\n'`
   $ rm .hg/localtags
   $ hg split $B --config experimental.evolution=createmarkers
-  abort: cannot split changeset with children
+  abort: cannot split changeset, as that will orphan 4 descendants
   (see 'hg help evolution.instability')
   [10]
   $ cat > $TESTTMP/messages <<EOF
--- a/tests/test-unamend.t	Tue May 04 10:16:34 2021 -0700
+++ b/tests/test-unamend.t	Tue May 04 10:49:32 2021 -0700
@@ -284,7 +284,7 @@
   
 
   $ hg --config experimental.evolution=createmarkers unamend
-  abort: cannot unamend changeset with children
+  abort: cannot unamend changeset, as that will orphan 3 descendants
   (see 'hg help evolution.instability')
   [10]