hgext3rd/topic/discovery.py
branchstable
changeset 3186 9d9ff55d1bb1
parent 3182 bc09dd507c41
child 3678 d725fe3e3989
--- 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__