# HG changeset patch # User Pierre-Yves David # Date 1510697460 -3600 # Node ID 9d9ff55d1bb1d48a994784f7e5d242f3d6e882b9 # Parent 0c64d0242ac2ab5801f37942e6874518a6dffdcb compat: fix comp ability of the new phase logic for Mercurial < 4.4 diff -r 0c64d0242ac2 -r 9d9ff55d1bb1 hgext3rd/topic/discovery.py --- a/hgext3rd/topic/discovery.py Thu Nov 02 19:08:36 2017 +0100 +++ b/hgext3rd/topic/discovery.py Tue Nov 14 23:11:00 2017 +0100 @@ -16,6 +16,7 @@ def _headssummary(orig, *args): # In mercurial < 4.2, we receive repo, remote and outgoing as arguments + pushop = None if len(args) == 3: pushoparg = False repo, remote, outgoing = args @@ -33,13 +34,14 @@ publishing = ('phases' not in remote.listkeys('namespaces') or bool(remote.listkeys('phases').get('publishing', False))) if ((publishing or not remote.capable('topics')) - and (pushoparg and not pushop.publish)): + and not getattr(pushop, 'publish', False)): return orig(*args) publishedset = () remotebranchmap = None origremotebranchmap = remote.branchmap - if pushoparg: # < hg-4.4 do not have a --publish flag anyway + # < hg-4.4 do not have a --publish flag anyway + if pushoparg and util.safehasattr(pushop, 'remotephases'): publishednode = [c.node() for c in pushop.outdatedphases] publishedset = repo.revs('ancestors(%ln + %ln)', publishednode, @@ -103,7 +105,8 @@ oldrepocls = repo.__class__ try: repo.__class__ = repocls - remote.branchmap = remotebranchmap + if remotebranchmap is not None: + remote.branchmap = remotebranchmap unxx = repo.filtered('unfiltered-topic') repo.unfiltered = lambda: unxx if pushoparg: @@ -120,7 +123,8 @@ if 'unfiltered' in vars(repo): del repo.unfiltered repo.__class__ = oldrepocls - remote.branchmap = origremotebranchmap + if remotebranchmap is not None: + remote.branchmap = origremotebranchmap def wireprotobranchmap(orig, repo, proto): oldrepo = repo.__class__