Mercurial > evolve
changeset 6217:4466989cee8d
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.
author | Sushil khanchi <sushilkhanchi97@gmail.com> |
---|---|
date | Fri, 23 Jul 2021 00:34:29 +0530 |
parents | ce46b853d10e |
children | 635b95454cce |
files | hgext3rd/evolve/cmdrewrite.py hgext3rd/evolve/rewriteutil.py tests/test-prune.t |
diffstat | 3 files changed, 8 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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 = []
--- 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 <revs> can be rewritten <action> 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
--- 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 ..