# HG changeset patch # User Sushil khanchi # Date 1626980669 -19800 # Node ID 4466989cee8def5aaf1f9c4ea0256dfc8ae5a05f # Parent ce46b853d10ea9a3ef716fc9675264966c98a721 precheck: fix false warning about divergence creation, in hg prune In case of pruning with no successors, there is no chance for new divergence. It was happening becuase current precheck logic assumes that every revision being rewritten will be replaced with at least one successor. Changes in test file demonstrate the fixed bug. diff -r ce46b853d10e -r 4466989cee8d hgext3rd/evolve/cmdrewrite.py --- a/hgext3rd/evolve/cmdrewrite.py Fri Jul 23 00:48:50 2021 +0530 +++ b/hgext3rd/evolve/cmdrewrite.py Fri Jul 23 00:34:29 2021 +0530 @@ -941,7 +941,7 @@ try: wlock = repo.wlock() lock = repo.lock() - rewriteutil.precheck(repo, revs, b'prune') + rewriteutil.precheck(repo, revs, b'prune', check_divergence=bool(succs)) tr = repo.transaction(b'prune') # defines pruned changesets precs = [] diff -r ce46b853d10e -r 4466989cee8d hgext3rd/evolve/rewriteutil.py --- a/hgext3rd/evolve/rewriteutil.py Fri Jul 23 00:48:50 2021 +0530 +++ b/hgext3rd/evolve/rewriteutil.py Fri Jul 23 00:34:29 2021 +0530 @@ -54,7 +54,7 @@ summary %= (node.short(tonode(first)), numrevs - 1) return summary -def precheck(repo, revs, action=b'rewrite'): +def precheck(repo, revs, action=b'rewrite', check_divergence=True): """check if can be rewritten can be used to control the commit message. @@ -62,7 +62,8 @@ # 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) + return corerewriteutil.precheck(repo, revs, action, + check_divergence=check_divergence) # hg <= 5.8 (d90f6237) if node.nullrev in revs: @@ -88,6 +89,8 @@ msg %= (action, len(newunstable)) hint = _(b"see 'hg help evolution.instability'") raise compat.InputError(msg, hint=hint) + if not check_divergence: + return allowdivergence = compat.isenabled(repo, compat.allowdivergenceopt) if allowdivergence: return diff -r ce46b853d10e -r 4466989cee8d tests/test-prune.t --- a/tests/test-prune.t Fri Jul 23 00:48:50 2021 +0530 +++ b/tests/test-prune.t Fri Jul 23 00:34:29 2021 +0530 @@ -491,15 +491,13 @@ Test that pruning (without any successors) an already pruned revision doesn't give false warning about divergence creation: -XXX: it is a false warning and should be fixed in upcoming patch + $ hg init nofalsewarn $ cd nofalsewarn $ echo a > A $ hg ci -Aqm "added a" $ hg ci --amend -m "added A" $ hg prune 0 --hidden - abort: cannot prune b8e67c50f3e6, as that creates content-divergence with fd9fbba03735 - (add --verbose for details or see 'hg help evolution.instability') - [10] + 1 changesets pruned $ cd ..