# HG changeset patch # User Anton Shestakov # Date 1627429452 -10800 # Node ID ef73f0d2232d84fd3775b9d7ca646152dffc45de # Parent e97fbded40a506813b4655a4b19618cc6a3d6e66 evolve: use obsolete.isenabled() instead of ui.configbool() directly diff -r e97fbded40a5 -r ef73f0d2232d hgext3rd/evolve/compat.py --- a/hgext3rd/evolve/compat.py Fri Aug 06 00:04:46 2021 +0200 +++ b/hgext3rd/evolve/compat.py Wed Jul 28 02:44:12 2021 +0300 @@ -471,6 +471,20 @@ for other in others: check_at_most_one_arg(opts, first, other) +# allowdivergenceopt is a much newer addition to obsolete.py +# hg <= 5.8 (ba6881c6a178) +allowdivergenceopt = b'allowdivergence' +def isenabled(repo, option): + if option == allowdivergenceopt: + if obsolete._getoptionvalue(repo, obsolete.createmarkersopt): + return obsolete._getoptionvalue(repo, allowdivergenceopt) + else: + # note that we're not raising error.Abort when divergence is + # allowed, but creating markers is not, even on older hg versions + return False + else: + return obsolete.isenabled(repo, option) + if util.safehasattr(dirstate.dirstate, 'set_clean'): movedirstate = scmutil.movedirstate else: # hg <= 5.8 (8a50fb0784a9) diff -r e97fbded40a5 -r ef73f0d2232d hgext3rd/evolve/rewriteutil.py --- a/hgext3rd/evolve/rewriteutil.py Fri Aug 06 00:04:46 2021 +0200 +++ b/hgext3rd/evolve/rewriteutil.py Wed Jul 28 02:44:12 2021 +0300 @@ -85,8 +85,7 @@ hint = _(b"see 'hg help evolution.instability'") raise error.Abort(msg, hint=hint) divrisk = revs_hascontentdivrisk(repo, revs) - allowdivergence = repo.ui.configbool(b'experimental', - b'evolution.allowdivergence') + allowdivergence = compat.isenabled(repo, compat.allowdivergenceopt) if divrisk and not allowdivergence: localdiv = repo[divrisk[0]] otherdiv, base = repo[divrisk[1][0]], repo[divrisk[1][1]] @@ -155,9 +154,9 @@ if len(baseparents) > 2: raise error.Abort(_(b"cannot fold revisions that merge with more than " b"one external changeset (not in revisions)")) - if not repo.ui.configbool(b'experimental', b'evolution.allowdivergence'): - obsolete = repo.revs(b'%ld and obsolete()', revs) - if obsolete: + if not compat.isenabled(repo, compat.allowdivergenceopt): + obsoleterevs = repo.revs(b'%ld and obsolete()', revs) + if obsoleterevs: msg = _(b'folding obsolete revisions may cause divergence') hint = _(b'set experimental.evolution.allowdivergence=yes' b' to allow folding them')