Mercurial > evolve
comparison hgext3rd/topic/discovery.py @ 3689:415c872d3308
topic: remove compatibility for older version in discovery wrapping
Support for 4.1 and 4.2 has been dropped.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 19 Apr 2018 14:14:34 +0200 |
parents | d725fe3e3989 |
children | ca7f02c9fa57 |
comparison
equal
deleted
inserted
replaced
3688:bda024010aed | 3689:415c872d3308 |
---|---|
17 from mercurial import wireproto | 17 from mercurial import wireproto |
18 wireproto.branchmap | 18 wireproto.branchmap |
19 except ImportError: # <= hg-4.5 | 19 except ImportError: # <= hg-4.5 |
20 from mercurial import wireprotov1server as wireproto | 20 from mercurial import wireprotov1server as wireproto |
21 | 21 |
22 def _headssummary(orig, *args): | 22 def _headssummary(orig, pushop, *args, **kwargs): |
23 # In mercurial < 4.2, we receive repo, remote and outgoing as arguments | |
24 pushop = None | |
25 if len(args) == 3: | |
26 pushoparg = False | |
27 repo, remote, outgoing = args | |
28 | |
29 # In mercurial > 4.3, we receive the pushop as arguments | 23 # In mercurial > 4.3, we receive the pushop as arguments |
30 elif len(args) == 1: | 24 repo = pushop.repo.unfiltered() |
31 pushoparg = True | 25 remote = pushop.remote |
32 pushop = args[0] | |
33 repo = pushop.repo.unfiltered() | |
34 remote = pushop.remote | |
35 else: | |
36 msg = 'topic-ext _headssummary() takes 1 or 3 arguments (%d given)' | |
37 raise TypeError(msg % len(args)) | |
38 | 26 |
39 publishing = ('phases' not in remote.listkeys('namespaces') | 27 publishing = ('phases' not in remote.listkeys('namespaces') |
40 or bool(remote.listkeys('phases').get('publishing', False))) | 28 or bool(remote.listkeys('phases').get('publishing', False))) |
41 if ((publishing or not remote.capable('topics')) | 29 if ((publishing or not remote.capable('topics')) |
42 and not getattr(pushop, 'publish', False)): | 30 and not getattr(pushop, 'publish', False)): |
43 return orig(*args) | 31 return orig(pushop, *args, **kwargs) |
44 | 32 |
45 publishedset = () | 33 publishedset = () |
46 remotebranchmap = None | 34 remotebranchmap = None |
47 origremotebranchmap = remote.branchmap | 35 origremotebranchmap = remote.branchmap |
48 # < hg-4.4 do not have a --publish flag anyway | 36 # < hg-4.4 do not have a --publish flag anyway |
49 if pushoparg and util.safehasattr(pushop, 'remotephases'): | 37 if util.safehasattr(pushop, 'remotephases'): |
50 publishednode = [c.node() for c in pushop.outdatedphases] | 38 publishednode = [c.node() for c in pushop.outdatedphases] |
51 publishedset = repo.revs('ancestors(%ln + %ln)', | 39 publishedset = repo.revs('ancestors(%ln + %ln)', |
52 publishednode, | 40 publishednode, |
53 pushop.remotephases.publicheads) | 41 pushop.remotephases.publicheads) |
54 | 42 |
112 repo.__class__ = repocls | 100 repo.__class__ = repocls |
113 if remotebranchmap is not None: | 101 if remotebranchmap is not None: |
114 remote.branchmap = remotebranchmap | 102 remote.branchmap = remotebranchmap |
115 unxx = repo.filtered('unfiltered-topic') | 103 unxx = repo.filtered('unfiltered-topic') |
116 repo.unfiltered = lambda: unxx | 104 repo.unfiltered = lambda: unxx |
117 if pushoparg: | 105 pushop.repo = repo |
118 pushop.repo = repo | 106 summary = orig(pushop) |
119 summary = orig(pushop) | |
120 else: | |
121 summary = orig(repo, remote, outgoing) | |
122 for key, value in summary.iteritems(): | 107 for key, value in summary.iteritems(): |
123 if ':' in key: # This is a topic | 108 if ':' in key: # This is a topic |
124 if value[0] is None and value[1]: | 109 if value[0] is None and value[1]: |
125 summary[key] = ([value[1][0]], ) + value[1:] | 110 summary[key] = ([value[1][0]], ) + value[1:] |
126 return summary | 111 return summary |