Mercurial > evolve
changeset 5970:65d4e47d7f26
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.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 04 May 2021 09:40:18 -0700 |
parents | f8ab6ad1ffc0 |
children | 3f9a5c910131 |
files | hgext3rd/evolve/rewriteutil.py tests/test-amend-patch.t tests/test-amend.t tests/test-evolve.t tests/test-fold.t tests/test-metaedit.t tests/test-pick.t tests/test-prune.t tests/test-sharing.t tests/test-split.t tests/test-touch.t tests/test-uncommit.t |
diffstat | 12 files changed, 48 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/rewriteutil.py Sat Jun 19 22:33:38 2021 +0300 +++ b/hgext3rd/evolve/rewriteutil.py Tue May 04 09:40:18 2021 -0700 @@ -23,6 +23,7 @@ obsolete, obsutil, revset, + rewriteutil as corerewriteutil, util, ) @@ -56,6 +57,12 @@ <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")
--- a/tests/test-amend-patch.t Sat Jun 19 22:33:38 2021 +0300 +++ b/tests/test-amend-patch.t Tue May 04 09:40:18 2021 -0700 @@ -655,7 +655,7 @@ $ HGEDITOR=cat hg amend --patch abort: cannot amend public changesets: 36454bda1fdb (see 'hg help phases' for details) - [255] + [10] $ hg phase -r . --draft --force
--- a/tests/test-amend.t Sat Jun 19 22:33:38 2021 +0300 +++ b/tests/test-amend.t Tue May 04 09:40:18 2021 -0700 @@ -199,16 +199,16 @@ 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 @@ $ 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]
--- a/tests/test-evolve.t Sat Jun 19 22:33:38 2021 +0300 +++ b/tests/test-evolve.t Tue May 04 09:40:18 2021 -0700 @@ -148,7 +148,7 @@ $ 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 @@ $ 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 @@ $ 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::"
--- a/tests/test-fold.t Sat Jun 19 22:33:38 2021 +0300 +++ b/tests/test-fold.t Tue May 04 09:40:18 2021 -0700 @@ -47,7 +47,7 @@ $ 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 @@ $ 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 @@ > 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 @@ $ 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
--- a/tests/test-metaedit.t Sat Jun 19 22:33:38 2021 +0300 +++ b/tests/test-metaedit.t Tue May 04 09:40:18 2021 -0700 @@ -74,7 +74,7 @@ $ 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 @@ (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
--- a/tests/test-pick.t Sat Jun 19 22:33:38 2021 +0300 +++ b/tests/test-pick.t Tue May 04 09:40:18 2021 -0700 @@ -292,7 +292,7 @@ $ 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
--- a/tests/test-prune.t Sat Jun 19 22:33:38 2021 +0300 +++ b/tests/test-prune.t Tue May 04 09:40:18 2021 -0700 @@ -94,7 +94,7 @@ $ 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'}
--- a/tests/test-sharing.t Sat Jun 19 22:33:38 2021 +0300 +++ b/tests/test-sharing.t Tue May 04 09:40:18 2021 -0700 @@ -165,7 +165,7 @@ $ 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
--- a/tests/test-split.t Sat Jun 19 22:33:38 2021 +0300 +++ b/tests/test-split.t Tue May 04 09:40:18 2021 -0700 @@ -140,7 +140,7 @@ $ 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 @@ > 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
--- a/tests/test-touch.t Sat Jun 19 22:33:38 2021 +0300 +++ b/tests/test-touch.t Tue May 04 09:40:18 2021 -0700 @@ -179,7 +179,7 @@ $ hg touch 2 abort: cannot touch public changesets: * (glob) (see 'hg help phases' for details) - [255] + [10] $ hg touch --duplicate 2 Reviving merge commit
--- a/tests/test-uncommit.t Sat Jun 19 22:33:38 2021 +0300 +++ b/tests/test-uncommit.t Tue May 04 09:40:18 2021 -0700 @@ -17,7 +17,7 @@ $ hg uncommit abort: cannot uncommit the null revision (no changeset checked out) - [255] + [10] Cannot uncommit public changeset @@ -27,7 +27,7 @@ $ hg uncommit abort: cannot uncommit public changesets: 07f494440405 (see 'hg help phases' for details) - [255] + [10] $ hg phase --force --draft . Cannot uncommit merge