Commit 50d97c76 authored by Martin von Zweigbergk's avatar Martin von Zweigbergk
Browse files

rewriteutil: use precheck from core if recent enough

This commit makes the evolve extension's `rewriteutil.precheck()`
simply delegate to the same function from Mercurial core, if that
function is deemed recent enough. The way I made that check is by
looking for `rewriteutil.find_new_divergence_from()`. That means that
there's a range of commits (ba6881c6::8125bcd2^) where the user would
see less detailed error messages if they are running with an hg
version from that range (there are no released versions in that
range).

As you can see in the tests, switching to core's version of the
function mostly affects error messages and exit codes.
parent f8ab6ad1ffc0
Pipeline #23359 passed with stage
in 5 minutes and 37 seconds
......@@ -23,6 +23,7 @@ from mercurial import (
obsolete,
obsutil,
revset,
rewriteutil as corerewriteutil,
util,
)
......@@ -56,6 +57,12 @@ def precheck(repo, revs, action=b'rewrite'):
<action> can be used to control the commit message.
"""
# If this attribute exists, then core's rewriteutil is recent enough
# that it has all the features from our own implementation.
if util.safehasattr(corerewriteutil, 'find_new_divergence_from'):
return corerewriteutil.precheck(repo, revs, action)
# hg <= 5.8 (d90f6237)
if node.nullrev in revs:
msg = _(b"cannot %s the null revision") % (action)
hint = _(b"no changeset checked out")
......
......@@ -655,7 +655,7 @@ Trying to amend --patch a public changeset
$ HGEDITOR=cat hg amend --patch
abort: cannot amend public changesets: 36454bda1fdb
(see 'hg help phases' for details)
[255]
[10]
$ hg phase -r . --draft --force
......
......@@ -199,16 +199,16 @@ Check the pre-check logic for content-divergence
when rewritting an already rewritten changeset (i.e cset being rewritten will
be the base of divergence)
$ hg amend -m "i am gonna create divergence"
abort: amend of 9092f1db7931 creates content-divergence with aafaf407b00d
abort: cannot amend 9092f1db7931, as that creates content-divergence with aafaf407b00d
(add --verbose for details or see 'hg help evolution.instability')
[255]
[10]
$ hg amend -m "i am gonna create divergence" --verbose
abort: amend of 9092f1db7931 creates content-divergence with aafaf407b00d
changeset 9092f1db7931 already have a successors as changeset aafaf407b00d
abort: cannot amend 9092f1db7931, as that creates content-divergence with aafaf407b00d
changeset 9092f1db7931 already has a successor in changeset aafaf407b00d
rewriting changeset 9092f1db7931 would create "content-divergence"
set experimental.evolution.allowdivergence=True to overwrite this check
set experimental.evolution.allowdivergence=True to skip this check
(see 'hg help evolution.instability' for details on content-divergence)
[255]
[10]
when rewritting a cset which has a predecessor with non-obsolete successor
......@@ -229,14 +229,14 @@ remove divergence by pruning one side of divergenence
$ hg evolve -l
$ hg amend -m "i am gonna create divergence"
abort: amend of f8c05838af90 creates content-divergence with aafaf407b00d, from 9092f1db7931
abort: cannot amend f8c05838af90, as that creates content-divergence with aafaf407b00d, from 9092f1db7931
(add --verbose for details or see 'hg help evolution.instability')
[255]
[10]
$ hg amend -m "i am gonna create divergence" --verbose
abort: amend of f8c05838af90 creates content-divergence with aafaf407b00d, from 9092f1db7931
changeset f8c05838af90 is an evolution of changeset 9092f1db7931
changeset 9092f1db7931 already have a successors as changeset aafaf407b00d
abort: cannot amend f8c05838af90, as that creates content-divergence with aafaf407b00d, from 9092f1db7931
changeset f8c05838af90 is a successor of changeset 9092f1db7931
changeset 9092f1db7931 already has a successor in changeset aafaf407b00d
rewriting changeset f8c05838af90 would create "content-divergence"
set experimental.evolution.allowdivergence=True to overwrite this check
set experimental.evolution.allowdivergence=True to skip this check
(see 'hg help evolution.instability' for details on content-divergence)
[255]
[10]
......@@ -148,7 +148,7 @@ test kill and immutable changeset
$ hg prune 1
abort: cannot prune public changesets: 7c3bad9141dc
(see 'hg help phases' for details)
[255]
[10]
$ hg log -r 1 --template '{rev} {phase} {obsolete}\n'
1 public
......@@ -1261,9 +1261,9 @@ With only createmarkers we can only uncommit on a head
$ hg up 274b6cd0c101^
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
$ hg uncommit --all
abort: uncommit will orphan 4 descendants
abort: cannot uncommit changeset, as that will orphan 4 descendants
(see 'hg help evolution.instability')
[255]
[10]
$ hg up 274b6cd0c101
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg uncommit --all
......@@ -1318,13 +1318,13 @@ Check that prune respects the allowunstable option
$ mkcommit c5_
created new head
$ hg prune '0ef9ff75f8e2 + f1b85956c48c'
abort: prune will orphan 1 descendants
abort: cannot prune changeset, as that will orphan 1 descendants
(see 'hg help evolution.instability')
[255]
[10]
$ hg prune '98e171e2f272::0d9203b74542'
abort: prune will orphan 1 descendants
abort: cannot prune changeset, as that will orphan 1 descendants
(see 'hg help evolution.instability')
[255]
[10]
$ hg prune '0ef9ff75f8e2::'
3 changesets pruned
$ glog -r "0cf3707e8971::"
......
......@@ -47,7 +47,7 @@ Test various error case
$ hg fold --exact null::
abort: cannot fold the null revision
(no changeset checked out)
[255]
[10]
$ hg fold
abort: no revisions specified
[255]
......@@ -81,7 +81,7 @@ Test various error case
$ hg fold --from -r 0
abort: cannot fold public changesets: 1ea73414a91b
(see 'hg help phases' for details)
[255]
[10]
Test actual folding
......@@ -222,13 +222,13 @@ Test allow unstable
> evolution = createmarkers, allnewcommands
> EOF
$ hg fold --from 'desc("r4")'
abort: fold will orphan 1 descendants
abort: cannot fold changeset, as that will orphan 1 descendants
(see 'hg help evolution.instability')
[255]
[10]
$ hg fold --from 'desc("r3")::desc("r11")'
abort: fold will orphan 1 descendants
abort: cannot fold changeset, as that will orphan 1 descendants
(see 'hg help evolution.instability')
[255]
[10]
test --user variant
......@@ -430,9 +430,9 @@ fold aborts here because divergence is not allowed
$ hg fold --exact -r 'desc("A")::desc("B")' -m 'second fold' \
> --config experimental.evolution.allowdivergence=no
abort: fold of 4b34ecfb0d56 creates content-divergence with fcfd42a7fa46
abort: cannot fold 4b34ecfb0d56, as that creates content-divergence with fcfd42a7fa46
(add --verbose for details or see 'hg help evolution.instability')
[255]
[10]
but if we allow divergence, this should work and should create new content-divergent changesets
......
......@@ -74,7 +74,7 @@ Test
$ hg metaedit -r 0 --fold
abort: cannot fold public changesets: ea207398892e
(see 'hg help phases' for details)
[255]
[10]
$ hg metaedit 'desc(C) + desc(F)' --fold
abort: cannot fold non-linear revisions (multiple roots given)
[255]
......@@ -87,9 +87,9 @@ check that metaedit respects allowunstable
(587528abfffe will become unstable and new unstable changes are not allowed)
[255]
$ hg metaedit 'desc(A)::desc(B)' --fold --config 'experimental.evolution=createmarkers, allnewcommands'
abort: fold will orphan 4 descendants
abort: cannot fold changeset, as that will orphan 4 descendants
(see 'hg help evolution.instability')
[255]
[10]
$ hg metaedit --user foobar
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg log --template '{rev}: {author}\n' -r 'desc(F):' --hidden
......
......@@ -292,7 +292,7 @@ Trying to pick a public changeset
$ hg pick -r 7c15c05db6fa
abort: cannot pick public changesets: 7c15c05db6fa
(see 'hg help phases' for details)
[255]
[10]
$ hg glog
@ 10:c437988de89f foo to b
......
......@@ -94,7 +94,7 @@ cannot prune public changesets
$ hg prune 0
abort: cannot prune public changesets: 1f0dee641bb7
(see 'hg help phases' for details)
[255]
[10]
$ hg debugobsolete
9d206ffc875e1bc304590549be293be36821e66c 0 {47d2a3944de8b013de3be9578e8e344ea2e6c097} (Sat Dec 15 00:00:00 1979 +0000) {'ef1': '0', 'operation': 'prune', 'user': 'blah'}
7c3bad9141dcb46ff89abf5f61856facd56e476c 0 {1f0dee641bb7258c56bd60e93edfa2405381c41e} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'prune', 'user': 'test'}
......
......@@ -165,7 +165,7 @@ Now that the fix is public, we cannot amend it any more.
$ hg amend -m 'fix bug 37'
abort: cannot amend public changesets: 7b49f864d655
(see 'hg help phases' for details)
[255]
[10]
Figure SG05
$ hg -R ../public shortlog -G
......
......@@ -140,7 +140,7 @@ Cannot split public changeset
$ hg split --rev 'desc("_a")'
abort: cannot split public changesets: 135f39f4bd78
(see 'hg help phases' for details)
[255]
[10]
$ hg phase --rev 'desc("_a")' --draft --force
Split a revision specified with -r
......@@ -352,9 +352,9 @@ Cannot split a commit that is not a head if instability is not allowed
> evolutioncommands=split
> EOF
$ hg split -r "desc(split3)"
abort: split will orphan 4 descendants
abort: cannot split changeset, as that will orphan 4 descendants
(see 'hg help evolution.instability')
[255]
[10]
Changing evolution level to createmarkers
$ echo "[experimental]" >> $HGRCPATH
......
......@@ -179,7 +179,7 @@ Public phase
$ hg touch 2
abort: cannot touch public changesets: * (glob)
(see 'hg help phases' for details)
[255]
[10]
$ hg touch --duplicate 2
Reviving merge commit
......
......@@ -17,7 +17,7 @@ Cannot uncommit null changeset
$ hg uncommit
abort: cannot uncommit the null revision
(no changeset checked out)
[255]
[10]
Cannot uncommit public changeset
......@@ -27,7 +27,7 @@ Cannot uncommit public changeset
$ hg uncommit
abort: cannot uncommit public changesets: 07f494440405
(see 'hg help phases' for details)
[255]
[10]
$ hg phase --force --draft .
Cannot uncommit merge
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment