Mercurial > evolve
changeset 6077:c5cb95d677bc
rewriteutil: update revs_hascontentdivrisk() to return tuple instead of list
Added the func docstring and modified few bits around caller, to remove the
usage of indexes to access the response.
author | Sushil khanchi <sushilkhanchi97@gmail.com> |
---|---|
date | Wed, 27 Oct 2021 00:51:05 +0530 |
parents | be9c35a8501d |
children | 26ddbaa12ab4 |
files | hgext3rd/evolve/rewriteutil.py |
diffstat | 1 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/rewriteutil.py Wed Oct 27 00:20:24 2021 +0530 +++ b/hgext3rd/evolve/rewriteutil.py Wed Oct 27 00:51:05 2021 +0530 @@ -88,10 +88,11 @@ allowdivergence = compat.isenabled(repo, compat.allowdivergenceopt) if allowdivergence: return - divrisk = revs_hascontentdivrisk(repo, revs) - if divrisk: - localdiv = repo[divrisk[0]] - otherdiv, base = repo[divrisk[1][0]], repo[divrisk[1][1]] + divergence = revs_hascontentdivrisk(repo, revs) + if divergence: + local, other, common_prec = divergence + localdiv = repo[local] + otherdiv, base = repo[other], repo[common_prec] msg = _(b"%s of %s creates content-divergence " b"with %s") % (action, localdiv, otherdiv) if localdiv.rev() != base.rev(): @@ -124,12 +125,15 @@ return updatebookmarks def revs_hascontentdivrisk(repo, revs): + """Return a tuple (rev, divergent, common_precursor) if rewriting one of + the revs will create content-divergence. + """ obsrevs = repo.revs(b'%ld and obsolete()', revs) for r in obsrevs: - div = precheck_contentdiv(repo, repo[r]) - if div: - return [r, div] - return [] + div_prec = precheck_contentdiv(repo, repo[r]) + if div_prec: + divergent, common_prec = div_prec + return (r, divergent, common_prec) def disallowednewunstable(repo, revs): """Check that editing <revs> will not create disallowed unstable