obsexc: add support for evoext_pushobsmarkers_0 on localpeer
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 27 Aug 2014 17:25:18 +0200
changeset 1081 dddb8a70437c
parent 1080 41d2555141ea
child 1082 74bc8a0c2c02
obsexc: add support for evoext_pushobsmarkers_0 on localpeer This will unify the behavior of exchange in the tests.
hgext/evolve.py
--- a/hgext/evolve.py	Wed Aug 27 17:24:40 2014 +0200
+++ b/hgext/evolve.py	Wed Aug 27 17:25:18 2014 +0200
@@ -2503,6 +2503,26 @@
             self.ui.status(_('remote: '), l)
     return ret
 
+@eh.wrapfunction(localrepo.localrepository, '_restrictcapabilities')
+def local_pushobsmarker_capabilities(orig, repo, caps):
+    caps = orig(repo, caps)
+    caps.add('_evoext_pushobsmarkers_0')
+    return caps
+
+@eh.addattr(localrepo.localpeer, 'evoext_pushobsmarkers_0')
+def local_pushobsmarkers(peer, obsfile):
+    data = obsfile.read()
+    lock = peer._repo.lock()
+    try:
+        tr = peer._repo.transaction('pushkey: obsolete markers')
+        try:
+            peer._repo.obsstore.mergemarkers(tr, data)
+            tr.close()
+        finally:
+            tr.release()
+    finally:
+        lock.release()
+    peer._repo.hook('evolve_pushobsmarkers')
 
 def srv_pushobsmarkers(repo, proto):
     """wireprotocol command"""