hgext/evolve.py
changeset 957 2cde59f3cb5d
parent 956 b107f3549ec2
child 958 6d18a1ab496c
equal deleted inserted replaced
956:b107f3549ec2 957:2cde59f3cb5d
    64 from mercurial.commands import walkopts, commitopts, commitopts2
    64 from mercurial.commands import walkopts, commitopts, commitopts2
    65 from mercurial.node import nullid
    65 from mercurial.node import nullid
    66 from mercurial import wireproto
    66 from mercurial import wireproto
    67 from mercurial import localrepo
    67 from mercurial import localrepo
    68 from mercurial.hgweb import hgweb_mod
    68 from mercurial.hgweb import hgweb_mod
       
    69 from mercurial import bundle2
    69 
    70 
    70 _pack = struct.pack
    71 _pack = struct.pack
    71 
    72 
    72 if gboptsmap is not None:
    73 if gboptsmap is not None:
    73     memfilectx = context.memfilectx
    74     memfilectx = context.memfilectx
  2273         else:
  2274         else:
  2274             repo.ui.status("OBSEXC: markers already in sync\n")
  2275             repo.ui.status("OBSEXC: markers already in sync\n")
  2275             markers = []
  2276             markers = []
  2276         if not markers:
  2277         if not markers:
  2277             repo.ui.status("OBSEXC: no marker to push\n")
  2278             repo.ui.status("OBSEXC: no marker to push\n")
       
  2279         elif remote.capable('_evoext_b2x_obsmarkers_0_pushonly'):
       
  2280             obsdata = StringIO()
       
  2281             _encodemarkersstream(obsdata, markers)
       
  2282             obsdata.seek(0)
       
  2283             repo.ui.status("OBSEXC: pushing %i markers (%i bytes)\n"
       
  2284                            % (len(markers), len(obsdata.getvalue())))
       
  2285             bundler = bundle2.bundle20(pushop.ui, {})
       
  2286             capsblob = bundle2.encodecaps(pushop.repo.bundle2caps)
       
  2287             bundler.addpart(bundle2.bundlepart('b2x:replycaps', data=capsblob))
       
  2288             cgpart = bundle2.bundlepart('EVOLVE:B2X:OBSMARKERV1', data=obsdata.getvalue())
       
  2289             bundler.addpart(cgpart)
       
  2290             stream = util.chunkbuffer(bundler.getchunks())
       
  2291             try:
       
  2292                 reply = pushop.remote.unbundle(stream, ['force'], 'push')
       
  2293             except bundle2.UnknownPartError, exc:
       
  2294                 raise util.Abort('missing support for %s' % exc)
       
  2295             try:
       
  2296                 op = bundle2.processbundle(pushop.repo, reply)
       
  2297             except bundle2.UnknownPartError, exc:
       
  2298                 raise util.Abort('missing support for %s' % exc)
  2278         elif remote.capable('_evoext_pushobsmarkers_0'):
  2299         elif remote.capable('_evoext_pushobsmarkers_0'):
  2279             obsdata = pushobsmarkerStringIO()
  2300             obsdata = pushobsmarkerStringIO()
  2280             _encodemarkersstream(obsdata, markers)
  2301             _encodemarkersstream(obsdata, markers)
  2281             obsdata.seek(0)
  2302             obsdata.seek(0)
  2282             obsdata.ui = repo.ui
  2303             obsdata.ui = repo.ui
  2345             tr.release()
  2366             tr.release()
  2346     finally:
  2367     finally:
  2347         lock.release()
  2368         lock.release()
  2348     repo.hook('evolve_pushobsmarkers')
  2369     repo.hook('evolve_pushobsmarkers')
  2349     return wireproto.pushres(0)
  2370     return wireproto.pushres(0)
       
  2371 
       
  2372 @bundle2.parthandler('evolve:b2x:obsmarkerv1')
       
  2373 def handleobsmarkerv1(op, inpart):
       
  2374     """add a stream of obsmarker to the repo"""
       
  2375     tr = op.gettransaction()
       
  2376     op.repo.obsstore.mergemarkers(tr, inpart.read())
  2350 
  2377 
  2351 def _buildpullobsmerkersboundaries(pullop):
  2378 def _buildpullobsmerkersboundaries(pullop):
  2352     """small funtion returning the argument for pull markers call
  2379     """small funtion returning the argument for pull markers call
  2353     may to contains 'heads' and 'common'. skip the key for None.
  2380     may to contains 'heads' and 'common'. skip the key for None.
  2354 
  2381 
  2580     caps = orig(repo, proto)
  2607     caps = orig(repo, proto)
  2581     if obsolete._enabled:
  2608     if obsolete._enabled:
  2582         caps += ' _evoext_pushobsmarkers_0'
  2609         caps += ' _evoext_pushobsmarkers_0'
  2583         caps += ' _evoext_pullobsmarkers_0'
  2610         caps += ' _evoext_pullobsmarkers_0'
  2584         caps += ' _evoext_obshash_0'
  2611         caps += ' _evoext_obshash_0'
       
  2612         caps += ' _evoext_b2x_obsmarkers_0_pushonly'
  2585     return caps
  2613     return caps
  2586 
  2614 
  2587 
  2615 
  2588 @eh.extsetup
  2616 @eh.extsetup
  2589 def _installwireprotocol(ui):
  2617 def _installwireprotocol(ui):
  2590     localrepo.moderncaps.add('_evoext_pullobsmarkers_0')
  2618     localrepo.moderncaps.add('_evoext_pullobsmarkers_0')
       
  2619     localrepo.moderncaps.add('_evoext_b2x_obsmarkers_0_pushonly')
  2591     hgweb_mod.perms['evoext_pushobsmarkers_0'] = 'push'
  2620     hgweb_mod.perms['evoext_pushobsmarkers_0'] = 'push'
  2592     hgweb_mod.perms['evoext_pullobsmarkers_0'] = 'pull'
  2621     hgweb_mod.perms['evoext_pullobsmarkers_0'] = 'pull'
  2593     hgweb_mod.perms['evoext_obshash'] = 'pull'
  2622     hgweb_mod.perms['evoext_obshash'] = 'pull'
  2594     wireproto.commands['evoext_pushobsmarkers_0'] = (srv_pushobsmarkers, '')
  2623     wireproto.commands['evoext_pushobsmarkers_0'] = (srv_pushobsmarkers, '')
  2595     wireproto.commands['evoext_pullobsmarkers_0'] = (srv_pullobsmarkers, '*')
  2624     wireproto.commands['evoext_pullobsmarkers_0'] = (srv_pullobsmarkers, '*')