hgext3rd/topic/server.py
branchstable
changeset 5353 f32d4c7f8fb7
parent 5193 a4d081923c81
equal deleted inserted replaced
5298:a828c7a7ace1 5353:f32d4c7f8fb7
     8     wireprototypes,
     8     wireprototypes,
     9     wireprotov1peer,
     9     wireprotov1peer,
    10     wireprotov1server,
    10     wireprotov1server,
    11 )
    11 )
    12 
    12 
    13 
       
    14 try:
    13 try:
    15     from mercurial.utils import (
    14     from mercurial.utils import (
    16         repoviewutil,
    15         repoviewutil,
    17     )
    16     )
    18     repoviewutil.subsettable
    17     repoviewutil.subsettable
    19 except (AttributeError, ImportError):
    18 except (AttributeError, ImportError):
    20     # hg <= 4.8
    19     # hg <= 4.9 (caebe5e7f4bd)
    21     from mercurial import branchmap as repoviewutil
    20     from mercurial import branchmap as repoviewutil
    22 
    21 
    23 from . import (
    22 from . import (
    24     common,
    23     common,
    25     constants,
    24     constants,
    52     if extrafiltered:
    51     if extrafiltered:
    53         extrafiltered = set(repo.revs('%ld::%ld', extrafiltered, consider))
    52         extrafiltered = set(repo.revs('%ld::%ld', extrafiltered, consider))
    54         filteredrevs = frozenset(filteredrevs | extrafiltered)
    53         filteredrevs = frozenset(filteredrevs | extrafiltered)
    55     return filteredrevs
    54     return filteredrevs
    56 
    55 
    57 def wireprotocommand(name, args=b'', permission=b'pull'):
       
    58     try:
       
    59         from mercurial.wireprotov1server import wireprotocommand
       
    60     except (ImportError, AttributeError):
       
    61         # hg <= 4.6 (b4d85bc122bd)
       
    62         from mercurial.wireproto import wireprotocommand
       
    63     return wireprotocommand(name, args, permission=permission)
       
    64 
       
    65 def wrapheads(orig, repo, proto):
    56 def wrapheads(orig, repo, proto):
    66     """wrap head to hide topic^W draft changeset to old client"""
    57     """wrap head to hide topic^W draft changeset to old client"""
    67     hidetopics = repo.ui.configbool(b'experimental', b'topic.server-gate-topic-changesets')
    58     hidetopics = repo.ui.configbool(b'experimental', b'topic.server-gate-topic-changesets')
    68     if common.hastopicext(repo) and hidetopics:
    59     if common.hastopicext(repo) and hidetopics:
    69         h = repo.filtered(FILTERNAME).heads()
    60         h = repo.filtered(FILTERNAME).heads()
    83     return caps
    74     return caps
    84 
    75 
    85 def setupserver(ui):
    76 def setupserver(ui):
    86     extensions.wrapfunction(wireprotov1server, 'heads', wrapheads)
    77     extensions.wrapfunction(wireprotov1server, 'heads', wrapheads)
    87     wireprotov1server.commands.pop(b'heads')
    78     wireprotov1server.commands.pop(b'heads')
    88     wireprotocommand(b'heads', permission=b'pull')(wireprotov1server.heads)
    79     wireprotov1server.wireprotocommand(b'heads', permission=b'pull')(wireprotov1server.heads)
    89     wireprotocommand(b'_exttopics_heads', permission=b'pull')(topicheads)
    80     wireprotov1server.wireprotocommand(b'_exttopics_heads', permission=b'pull')(topicheads)
    90     extensions.wrapfunction(wireprotov1server, '_capabilities', wireprotocaps)
    81     extensions.wrapfunction(wireprotov1server, '_capabilities', wireprotocaps)
    91 
    82 
    92     class topicpeerexecutor(wireprotov1peer.peerexecutor):
    83     class topicpeerexecutor(wireprotov1peer.peerexecutor):
    93 
    84 
    94         def callcommand(self, command, args):
    85         def callcommand(self, command, args):