diff hgfastobs.py @ 799:a398478e8d86

adapt fastopt extension to mercurial.exchange module The push code have changed to be more modular. the fastop extension need to be rewritten. No backward compatibility preserved for mercurial <=2.9x.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 18 Feb 2014 15:32:31 -0800
parents eb0d18490c14
children ad2060da7ffa
line wrap: on
line diff
--- a/hgfastobs.py	Tue Feb 18 15:30:54 2014 -0800
+++ b/hgfastobs.py	Tue Feb 18 15:32:31 2014 -0800
@@ -26,11 +26,12 @@
 from mercurial import extensions
 from mercurial import node
 from mercurial import obsolete
+from mercurial import exchange
 from mercurial import revset
 from mercurial.i18n import _
 
 _strategies = {
-    'stock': obsolete.syncpush,
+    'stock': exchange._pushobsolete,
     }
 
 def _strategy(name, default=False):
@@ -41,16 +42,11 @@
         return func
     return inner
 
-def syncpushwrapper(orig, repo, remote):
-    stratfn = _strategies[repo.ui.config('obsolete', 'syncstrategy')]
-    return stratfn(repo, remote)
+def _pushobsoletewrapper(orig, pushop):
+    stratfn = _strategies[pushop.repo.ui.config('obsolete', 'syncstrategy')]
+    return stratfn(pushop)
 
-extensions.wrapfunction(obsolete, 'syncpush', syncpushwrapper)
-
-def _getoutgoing():
-    f = sys._getframe(4)
-    return f.f_locals['outgoing']
-
+extensions.wrapfunction(exchange, '_pushobsolete', _pushobsoletewrapper)
 
 def _precursors(repo, s):
     """Precursor of a changeset"""
@@ -73,7 +69,7 @@
 
 
 @_strategy('boxfill', default=True)
-def boxfill(repo, remote):
+def boxfill(pushop):
     """The "fill in the box" strategy from the 2.6 sprint.
 
     See the notes[0] from the 2.6 sprint for what "fill in the box"
@@ -83,8 +79,10 @@
 
     [0]: https://bitbucket.org/durin42/2.6sprint-notes/src/tip/mercurial26-obsstore-rev.1398.txt
     """
-    outgoing = _getoutgoing()
-    urepo = repo.unfiltered()
+    repo = pushop.repo
+    remote = pushop.remote
+    outgoing = pushop.outgoing
+    urepo = pushop.repo.unfiltered()
     # need to collect obsolete markers which list any of
     # outgoing.missing as a successor (transitively), as well as any
     # kill markers for dead nodes descended from any of the precursors