evolve: refactoring of code related to pushing obs markers
This removes duplicated code for the pushobsmarkers logic
--- a/hgext/evolve.py Mon May 04 10:56:06 2015 -0700
+++ b/hgext/evolve.py Thu Apr 30 14:55:04 2015 -0700
@@ -2674,28 +2674,7 @@
caps.add('_evoext_pushobsmarkers_0')
return caps
-@eh.addattr(localrepo.localpeer, 'evoext_pushobsmarkers_0')
-def local_pushobsmarkers(peer, obsfile):
- data = obsfile.read()
- tr = lock = None
- try:
- lock = peer._repo.lock()
- tr = peer._repo.transaction('pushkey: obsolete markers')
- new = peer._repo.obsstore.mergemarkers(tr, data)
- if new is not None:
- obsexcmsg(peer._repo.ui, "%i obsolescence markers added\n" % new, True)
- tr.close()
- finally:
- lockmod.release(tr, lock)
- peer._repo.hook('evolve_pushobsmarkers')
-
-def srv_pushobsmarkers(repo, proto):
- """wireprotocol command"""
- fp = StringIO()
- proto.redirect()
- proto.getfile(fp)
- data = fp.getvalue()
- fp.close()
+def _pushobsmarkers(repo, data):
tr = lock = None
try:
lock = repo.lock()
@@ -2707,6 +2686,20 @@
finally:
lockmod.release(tr, lock)
repo.hook('evolve_pushobsmarkers')
+
+@eh.addattr(localrepo.localpeer, 'evoext_pushobsmarkers_0')
+def local_pushobsmarkers(peer, obsfile):
+ data = obsfile.read()
+ _pushobsmarkers(peer._repo, data)
+
+def srv_pushobsmarkers(repo, proto):
+ """wireprotocol command"""
+ fp = StringIO()
+ proto.redirect()
+ proto.getfile(fp)
+ data = fp.getvalue()
+ fp.close()
+ _pushobsmarkers(repo, data)
return wireproto.pushres(0)
def _buildpullobsmarkersboundaries(pullop):