hgext/simple4server.py
author Pierre-Yves David <pierre-yves.david@fb.com>
Fri, 28 Feb 2014 13:38:19 -0800
changeset 824 fed090e07621
parent 822 5f5d269278e9
child 826 bee5e1105e6c
permissions -rw-r--r--
exchange: pull markers relevant to the pulled subset only With the command recently introduced we can select to pull only markers relevant to some nodes. We are now pull all markers for all node in the relevant subset. We'll try to pull less (just markers for node where local and remote marker diverge) later, but we need some marker discovery mechanism for that. which are not easy.

'''enable experimental obsolescence feature of Mercurial

OBSOLESCENCE IS AN EXPERIMENTAL FEATURE MAKE SURE YOU UNDERSTOOD THE INVOLVED
CONCEPT BEFORE USING IT.

/!\ THIS EXTENSION IS INTENDED FOR SERVER SIDE ONLY USAGE /!\

For client side usages it is recommended to use the evolve extension for
improved user interface.'''

import mercurial.obsolete
mercurial.obsolete._enabled = True

from mercurial import wireproto
from mercurial import extension

def srv_pushobsmarkers(repo, proto):
    """wireprotocol command"""
    fp = StringIO()
    proto.redirect()
    proto.getfile(fp)
    data = fp.getvalue()
    fp.close()
    lock = repo.lock()
    try:
        tr = repo.transaction('pushkey: obsolete markers')
        try:
            repo.obsstore.mergemarkers(tr, data)
            tr.close()
        finally:
            tr.release()
    finally:
        lock.release()
    return wireproto.pushres(0)

def capabilities(orig, repo, proto):
    """wrapper to advertise new capability"""
    caps = orig(repo, proto)
    if obsolete._enabled:
        caps += ' _evoext_pushobsmarkers_0'
    return caps

def extsetup(ui):
    wireproto.commands['evoext_pushobsmarkers_0'] = (srv_pushobsmarkers, '')
    extensions.wrapfunction(wireproto, 'capabilities', capabilities)