# HG changeset patch # User Pierre-Yves David # Date 1522434414 -7200 # Node ID f6d62951460730a90b1bba3a764b2b6afe6bf08a # Parent 1ff7ff53d81f41bdc4a7b95e9f78ef9ad369093f compat: use updateresult API if available The status return is no longer a tuple, we access attribute instead. diff -r 1ff7ff53d81f -r f6d629514607 hgext3rd/evolve/cmdrewrite.py --- a/hgext3rd/evolve/cmdrewrite.py Fri Mar 30 20:13:06 2018 +0200 +++ b/hgext3rd/evolve/cmdrewrite.py Fri Mar 30 20:26:54 2018 +0200 @@ -1200,7 +1200,7 @@ origctx.description().split("\n", 1)[0])) stats = merge.graft(repo, origctx, origctx.p1(), ['local', 'destination']) - if stats[3]: + if compat.hasconflict(stats): grabstate.addopts({'orignode': origctx.node(), 'oldpctx': pctx.node()}) grabstate.save() diff -r 1ff7ff53d81f -r f6d629514607 hgext3rd/evolve/compat.py --- a/hgext3rd/evolve/compat.py Fri Mar 30 20:13:06 2018 +0200 +++ b/hgext3rd/evolve/compat.py Fri Mar 30 20:26:54 2018 +0200 @@ -293,3 +293,14 @@ hgweb_mod.perms[name] = permission wireproto.commands[name] = (func, args) return decorator + +# mercurial <= 4.5 do not have the updateresult object +try: + from mercurial.merge import updateresult +except (ImportError, AttributeError): + updateresult = None + +def hasconflict(upres): + if updateresult is None: + return bool(upres[-1]) + return bool(upres.unresolvedcount) diff -r 1ff7ff53d81f -r f6d629514607 hgext3rd/evolve/evolvecmd.py --- a/hgext3rd/evolve/evolvecmd.py Fri Mar 30 20:13:06 2018 +0200 +++ b/hgext3rd/evolve/evolvecmd.py Fri Mar 30 20:26:54 2018 +0200 @@ -382,10 +382,9 @@ ancestor=base.node(), mergeancestor=True) hg._showstats(repo, stats) - if stats[3]: + if compat.hasconflict(stats): repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " "or 'hg update -C .' to abort\n")) - if stats[3] > 0: raise error.Abort('merge conflict between several amendments ' '(this is not automated yet)', hint="""/!\ You can try: @@ -504,7 +503,7 @@ assert tr is not None try: r = _evolvemerge(repo, orig, dest, pctx, keepbranch) - if r[-1]: # some conflict + if compat.hasconflict(r): # some conflict raise error.Abort(_('unresolved merge conflicts ' '(see hg help resolve)')) nodenew = _relocatecommit(repo, orig, commitmsg)