Patchwork D10671: rewriteutil: say how many commits would become orphan if commit is rewritten

login
register
mail settings
Submitter phabricator
Date May 4, 2021, 5:59 p.m.
Message ID <differential-rev-PHID-DREV-vhlwpjkqi67sddfusdki-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48989/
State Superseded
Headers show

Comments

phabricator - May 4, 2021, 5:59 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10671

AFFECTED FILES
  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

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-unamend.t b/tests/test-unamend.t
--- a/tests/test-unamend.t
+++ b/tests/test-unamend.t
@@ -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]
 
diff --git a/tests/test-split.t b/tests/test-split.t
--- a/tests/test-split.t
+++ b/tests/test-split.t
@@ -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
diff --git a/tests/test-rebase-scenario-global.t b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -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
diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t
--- a/tests/test-rebase-collapse.t
+++ b/tests/test-rebase-collapse.t
@@ -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]
 
diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -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 '.^'
diff --git a/tests/test-branch-change.t b/tests/test-branch-change.t
--- a/tests/test-branch-change.t
+++ b/tests/test-branch-change.t
@@ -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]
 
diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -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]
 
diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py
--- a/mercurial/rewriteutil.py
+++ b/mercurial/rewriteutil.py
@@ -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):