Mercurial > evolve
comparison hgext3rd/topic/discovery.py @ 2695:b4824e169f18
topic: cleanup the repository wrapping logic in topic discovery
We are know overriding the class so we do not need to update and restore the
pushop itself.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 02 Jul 2017 16:00:38 +0200 |
parents | 10dedac0d82e |
children | a32afe67e8a6 |
comparison
equal
deleted
inserted
replaced
2694:8a222745a71c | 2695:b4824e169f18 |
---|---|
47 return branch | 47 return branch |
48 | 48 |
49 ctx.branch = branch | 49 ctx.branch = branch |
50 return ctx | 50 return ctx |
51 | 51 |
52 oldrepo = repo.__class__ | 52 oldrepocls = repo.__class__ |
53 try: | 53 try: |
54 repo.__class__ = repocls | 54 repo.__class__ = repocls |
55 unxx = repo.filtered('unfiltered-topic') | 55 unxx = repo.filtered('unfiltered-topic') |
56 repo.unfiltered = lambda: unxx | 56 repo.unfiltered = lambda: unxx |
57 if pushoparg: | 57 if pushoparg: |
58 try: | 58 pushop.repo = repo |
59 pushop.repo = repo | 59 summary = orig(pushop) |
60 summary = orig(pushop) | |
61 finally: | |
62 pushop.repo = repo | |
63 else: | 60 else: |
64 summary = orig(repo, remote, outgoing) | 61 summary = orig(repo, remote, outgoing) |
65 for key, value in summary.iteritems(): | 62 for key, value in summary.iteritems(): |
66 if ':' in key: # This is a topic | 63 if ':' in key: # This is a topic |
67 if value[0] is None and value[1]: | 64 if value[0] is None and value[1]: |
68 summary[key] = ([value[1][0]], ) + value[1:] | 65 summary[key] = ([value[1][0]], ) + value[1:] |
69 return summary | 66 return summary |
70 finally: | 67 finally: |
71 if 'unfiltered' in vars(repo): | 68 if 'unfiltered' in vars(repo): |
72 del repo.unfiltered | 69 del repo.unfiltered |
73 repo.__class__ = oldrepo | 70 repo.__class__ = oldrepocls |
74 | 71 |
75 def wireprotobranchmap(orig, repo, proto): | 72 def wireprotobranchmap(orig, repo, proto): |
76 oldrepo = repo.__class__ | 73 oldrepo = repo.__class__ |
77 try: | 74 try: |
78 class repocls(repo.__class__): | 75 class repocls(repo.__class__): |