topic: cleanup the repository wrapping logic in topic discovery
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sun, 02 Jul 2017 16:00:38 +0200
changeset 2695 b4824e169f18
parent 2694 8a222745a71c
child 2696 a32afe67e8a6
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.
hgext3rd/topic/discovery.py
--- a/hgext3rd/topic/discovery.py	Sun Jul 02 15:02:51 2017 +0200
+++ b/hgext3rd/topic/discovery.py	Sun Jul 02 16:00:38 2017 +0200
@@ -49,17 +49,14 @@
             ctx.branch = branch
             return ctx
 
-    oldrepo = repo.__class__
+    oldrepocls = repo.__class__
     try:
         repo.__class__ = repocls
         unxx = repo.filtered('unfiltered-topic')
         repo.unfiltered = lambda: unxx
         if pushoparg:
-            try:
-                pushop.repo = repo
-                summary = orig(pushop)
-            finally:
-                pushop.repo = repo
+            pushop.repo = repo
+            summary = orig(pushop)
         else:
             summary = orig(repo, remote, outgoing)
         for key, value in summary.iteritems():
@@ -70,7 +67,7 @@
     finally:
         if 'unfiltered' in vars(repo):
             del repo.unfiltered
-        repo.__class__ = oldrepo
+        repo.__class__ = oldrepocls
 
 def wireprotobranchmap(orig, repo, proto):
     oldrepo = repo.__class__