# HG changeset patch # User Sushil khanchi # Date 1635276065 -19800 # Node ID c5cb95d677bc35cb03a587121d84286e08fd231e # Parent be9c35a8501d7b5a4c52e8d378e9af4dd2ae0a12 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. diff -r be9c35a8501d -r c5cb95d677bc hgext3rd/evolve/rewriteutil.py --- 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 will not create disallowed unstable