Mercurial > evolve
comparison hgext3rd/topic/discovery.py @ 3186:9d9ff55d1bb1 stable
compat: fix comp ability of the new phase logic for Mercurial < 4.4
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 14 Nov 2017 23:11:00 +0100 |
parents | bc09dd507c41 |
children | d725fe3e3989 |
comparison
equal
deleted
inserted
replaced
3185:0c64d0242ac2 | 3186:9d9ff55d1bb1 |
---|---|
14 wireproto, | 14 wireproto, |
15 ) | 15 ) |
16 | 16 |
17 def _headssummary(orig, *args): | 17 def _headssummary(orig, *args): |
18 # In mercurial < 4.2, we receive repo, remote and outgoing as arguments | 18 # In mercurial < 4.2, we receive repo, remote and outgoing as arguments |
19 pushop = None | |
19 if len(args) == 3: | 20 if len(args) == 3: |
20 pushoparg = False | 21 pushoparg = False |
21 repo, remote, outgoing = args | 22 repo, remote, outgoing = args |
22 | 23 |
23 # In mercurial > 4.3, we receive the pushop as arguments | 24 # In mercurial > 4.3, we receive the pushop as arguments |
31 raise TypeError(msg % len(args)) | 32 raise TypeError(msg % len(args)) |
32 | 33 |
33 publishing = ('phases' not in remote.listkeys('namespaces') | 34 publishing = ('phases' not in remote.listkeys('namespaces') |
34 or bool(remote.listkeys('phases').get('publishing', False))) | 35 or bool(remote.listkeys('phases').get('publishing', False))) |
35 if ((publishing or not remote.capable('topics')) | 36 if ((publishing or not remote.capable('topics')) |
36 and (pushoparg and not pushop.publish)): | 37 and not getattr(pushop, 'publish', False)): |
37 return orig(*args) | 38 return orig(*args) |
38 | 39 |
39 publishedset = () | 40 publishedset = () |
40 remotebranchmap = None | 41 remotebranchmap = None |
41 origremotebranchmap = remote.branchmap | 42 origremotebranchmap = remote.branchmap |
42 if pushoparg: # < hg-4.4 do not have a --publish flag anyway | 43 # < hg-4.4 do not have a --publish flag anyway |
44 if pushoparg and util.safehasattr(pushop, 'remotephases'): | |
43 publishednode = [c.node() for c in pushop.outdatedphases] | 45 publishednode = [c.node() for c in pushop.outdatedphases] |
44 publishedset = repo.revs('ancestors(%ln + %ln)', | 46 publishedset = repo.revs('ancestors(%ln + %ln)', |
45 publishednode, | 47 publishednode, |
46 pushop.remotephases.publicheads) | 48 pushop.remotephases.publicheads) |
47 | 49 |
101 return rbc | 103 return rbc |
102 | 104 |
103 oldrepocls = repo.__class__ | 105 oldrepocls = repo.__class__ |
104 try: | 106 try: |
105 repo.__class__ = repocls | 107 repo.__class__ = repocls |
106 remote.branchmap = remotebranchmap | 108 if remotebranchmap is not None: |
109 remote.branchmap = remotebranchmap | |
107 unxx = repo.filtered('unfiltered-topic') | 110 unxx = repo.filtered('unfiltered-topic') |
108 repo.unfiltered = lambda: unxx | 111 repo.unfiltered = lambda: unxx |
109 if pushoparg: | 112 if pushoparg: |
110 pushop.repo = repo | 113 pushop.repo = repo |
111 summary = orig(pushop) | 114 summary = orig(pushop) |
118 return summary | 121 return summary |
119 finally: | 122 finally: |
120 if 'unfiltered' in vars(repo): | 123 if 'unfiltered' in vars(repo): |
121 del repo.unfiltered | 124 del repo.unfiltered |
122 repo.__class__ = oldrepocls | 125 repo.__class__ = oldrepocls |
123 remote.branchmap = origremotebranchmap | 126 if remotebranchmap is not None: |
127 remote.branchmap = origremotebranchmap | |
124 | 128 |
125 def wireprotobranchmap(orig, repo, proto): | 129 def wireprotobranchmap(orig, repo, proto): |
126 oldrepo = repo.__class__ | 130 oldrepo = repo.__class__ |
127 try: | 131 try: |
128 class repocls(repo.__class__): | 132 class repocls(repo.__class__): |