# HG changeset patch # User Martin von Zweigbergk # Date 1563002223 25200 # Node ID 92e3db149d7da1c60bebdf8f90bd71e16ac0aebd # Parent db3e7f6b5ceb739d6b8c96d4e1e551fb0fe9eef7 py3: call branchmap.items() on py3 and continue to call iteritems() on py2 Mercurial's source transformer also replaces the 'def iteritems(' in branchmap by 'def items(', so we need to call whichever version is there. diff -r db3e7f6b5ceb -r 92e3db149d7d hgext3rd/topic/compat.py --- a/hgext3rd/topic/compat.py Fri Jul 12 23:24:04 2019 -0700 +++ b/hgext3rd/topic/compat.py Sat Jul 13 00:17:03 2019 -0700 @@ -9,6 +9,7 @@ from mercurial import ( obsolete, + pycompat, ) getmarkers = None @@ -24,3 +25,10 @@ getmarkers = obsolete.getmarkers if successorssets is None: successorssets = obsolete.successorssets + +if pycompat.ispy3: + def branchmapitems(branchmap): + return branchmap.items() +else: + def branchmapitems(branchmap): + return branchmap.iteritems() diff -r db3e7f6b5ceb -r 92e3db149d7d hgext3rd/topic/discovery.py --- a/hgext3rd/topic/discovery.py Fri Jul 12 23:24:04 2019 -0700 +++ b/hgext3rd/topic/discovery.py Sat Jul 13 00:17:03 2019 -0700 @@ -14,6 +14,7 @@ ) from . import ( common, + compat, ) try: @@ -49,7 +50,7 @@ def remotebranchmap(): # drop topic information from changeset about to be published result = collections.defaultdict(list) - for branch, heads in origremotebranchmap().iteritems(): + for branch, heads in compat.branchmapitems(origremotebranchmap()): if ':' not in branch: result[branch].extend(heads) else: diff -r db3e7f6b5ceb -r 92e3db149d7d hgext3rd/topic/flow.py --- a/hgext3rd/topic/flow.py Fri Jul 12 23:24:04 2019 -0700 +++ b/hgext3rd/topic/flow.py Sat Jul 13 00:17:03 2019 -0700 @@ -11,8 +11,13 @@ from mercurial.i18n import _ +from . import ( + compat, +) + def enforcesinglehead(repo, tr): - for name, heads in repo.filtered('visible').branchmap().iteritems(): + branchmap = repo.filtered('visible').branchmap() + for name, heads in compat.branchmapitems(branchmap): if len(heads) > 1: hexs = [node.short(n) for n in heads] raise error.Abort(_('%d heads on "%s"') % (len(heads), name),