mercurial/sshserver.py
author Boris Feld <boris.feld@octobus.net>
Thu, 18 Jan 2018 00:48:56 +0100
changeset 35756 cfdccd560b66
parent 35750 a39a9df7ecca
permissions -rw-r--r--
streamclone: define first iteration of version 2 of stream format (This patch is based on a first draft from Gregory Szorc, with deeper rework) Version 1 of the stream clone format was invented many years ago and suffers from a few deficiencies: 1) Filenames are stored in store-encoded (on filesystem) form rather than in their internal form. This makes future compatibility with new store filename encodings more difficult. 2) File entry "headers" consist of a newline of the file name followed by the string file size. Converting strings to integers is avoidable overhead. We can't store filenames with newlines (manifests have this limitation as well, so it isn't a major concern). But the big concern here is the necessity for readline(). Scanning for newlines means reading ahead and that means extra buffer allocations and slicing (in Python) and this makes performance suffer. 3) Filenames aren't compressed optimally. Filenames should be compressed well since there is a lot of repeated data. However, since they are scattered all over the stream (with revlog data in between), they typically fall outside the window size of the compressor and don't compress. 4) It can only exchange stored based content, being able to exchange caches too would be nice. 5) It is limited to a stream-based protocol and isn't suitable for an on-disk format for general repository reading because the offset of individual file entries requires scanning the entire file to find file records. As part of enabling streaming clones to work in bundle2, #2 proved to have a significant negative impact on performance. Since bundle2 provides the opportunity to start fresh, Gregory Szorc figured he would take the opportunity to invent a new streaming clone data format. The new format devised in this series addresses #1, #2, and #4. It punts on #3 because it was complex without yielding a significant gain and on #5 because devising a new store format that "packs" multiple revlogs into a single "packed revlog" is massive scope bloat. However, this v2 format might be suitable for streaming into a "packed revlog" with minimal processing. If it works, great. If not, we can always invent stream format when it is needed. This patch only introduces the bases of the format. We'll get it usable through bundle2 first, then we'll extend the format in future patches to bring it to its full potential (especially #4).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2399
cc90dcbdf053 fix comment.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2397
diff changeset
     1
# sshserver.py - ssh protocol server support for mercurial
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     2
#
4635
63b9d2deed48 Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4258
diff changeset
     3
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
2859
345bac2bc4ec update copyrights.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2673
diff changeset
     4
# Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     5
#
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 8109
diff changeset
     6
# This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 9742
diff changeset
     7
# GNU General Public License version 2 or any later version.
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     8
25976
72b36785d7f4 sshserver: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25692
diff changeset
     9
from __future__ import absolute_import
72b36785d7f4 sshserver: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25692
diff changeset
    10
72b36785d7f4 sshserver: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25692
diff changeset
    11
import sys
72b36785d7f4 sshserver: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25692
diff changeset
    12
29389
98e8313dcd9e i18n: translate abort messages
liscju <piotr.listkiewicz@gmail.com>
parents: 26587
diff changeset
    13
from .i18n import _
25976
72b36785d7f4 sshserver: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25692
diff changeset
    14
from . import (
30640
a150173da1c1 py3: replace os.environ with encoding.environ (part 2 of 5)
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30567
diff changeset
    15
    encoding,
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25976
diff changeset
    16
    error,
25976
72b36785d7f4 sshserver: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25692
diff changeset
    17
    hook,
72b36785d7f4 sshserver: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25692
diff changeset
    18
    util,
72b36785d7f4 sshserver: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25692
diff changeset
    19
    wireproto,
72b36785d7f4 sshserver: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25692
diff changeset
    20
)
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    21
20903
8d477543882b wireproto: introduce an abstractserverproto class
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 17563
diff changeset
    22
class sshserver(wireproto.abstractserverproto):
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    23
    def __init__(self, ui, repo):
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    24
        self.ui = ui
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    25
        self.repo = repo
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    26
        self.lock = None
14614
afccc64eea73 ui: use I/O descriptors internally
Idan Kamara <idankk86@gmail.com>
parents: 14233
diff changeset
    27
        self.fin = ui.fin
afccc64eea73 ui: use I/O descriptors internally
Idan Kamara <idankk86@gmail.com>
parents: 14233
diff changeset
    28
        self.fout = ui.fout
30567
b3a9ef3d30e8 protocol: declare transport protocol name
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30475
diff changeset
    29
        self.name = 'ssh'
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    30
5833
323b9c55b328 hook: redirect stdout to stderr for ssh and http servers
Matt Mackall <mpm@selenic.com>
parents: 4635
diff changeset
    31
        hook.redirect(True)
14614
afccc64eea73 ui: use I/O descriptors internally
Idan Kamara <idankk86@gmail.com>
parents: 14233
diff changeset
    32
        ui.fout = repo.ui.fout = ui.ferr
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    33
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    34
        # Prevent insertion/deletion of CRs
14233
659f34b833b9 rename util.set_binary to setbinary
Adrian Buehlmann <adrian@cadifra.com>
parents: 13721
diff changeset
    35
        util.setbinary(self.fin)
659f34b833b9 rename util.set_binary to setbinary
Adrian Buehlmann <adrian@cadifra.com>
parents: 13721
diff changeset
    36
        util.setbinary(self.fout)
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    37
11579
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    38
    def getargs(self, args):
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    39
        data = {}
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    40
        keys = args.split()
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    41
        for n in xrange(len(keys)):
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    42
            argline = self.fin.readline()[:-1]
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    43
            arg, l = argline.split()
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    44
            if arg not in keys:
29389
98e8313dcd9e i18n: translate abort messages
liscju <piotr.listkiewicz@gmail.com>
parents: 26587
diff changeset
    45
                raise error.Abort(_("unexpected parameter %r") % arg)
11579
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    46
            if arg == '*':
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    47
                star = {}
13721
3458c15ab2f0 wireproto: fix handling of '*' args for HTTP and SSH
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 13719
diff changeset
    48
                for k in xrange(int(l)):
3458c15ab2f0 wireproto: fix handling of '*' args for HTTP and SSH
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 13719
diff changeset
    49
                    argline = self.fin.readline()[:-1]
11579
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    50
                    arg, l = argline.split()
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    51
                    val = self.fin.read(int(l))
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    52
                    star[arg] = val
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    53
                data['*'] = star
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    54
            else:
13721
3458c15ab2f0 wireproto: fix handling of '*' args for HTTP and SSH
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 13719
diff changeset
    55
                val = self.fin.read(int(l))
11579
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    56
                data[arg] = val
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    57
        return [data[k] for k in keys]
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    58
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    59
    def getarg(self, name):
c19d7e91cc46 protocol: add ssh getargs
Matt Mackall <mpm@selenic.com>
parents: 11442
diff changeset
    60
        return self.getargs(name)[0]
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    61
11621
e46a8b2331a6 protocol: shuffle server methods to group send methods
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11618
diff changeset
    62
    def getfile(self, fpout):
11622
1d48681b17a4 protocol: rename send methods to get grouping by prefix
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11621
diff changeset
    63
        self.sendresponse('')
11621
e46a8b2331a6 protocol: shuffle server methods to group send methods
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11618
diff changeset
    64
        count = int(self.fin.readline())
e46a8b2331a6 protocol: shuffle server methods to group send methods
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11618
diff changeset
    65
        while count:
e46a8b2331a6 protocol: shuffle server methods to group send methods
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11618
diff changeset
    66
            fpout.write(self.fin.read(count))
e46a8b2331a6 protocol: shuffle server methods to group send methods
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11618
diff changeset
    67
            count = int(self.fin.readline())
e46a8b2331a6 protocol: shuffle server methods to group send methods
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11618
diff changeset
    68
e46a8b2331a6 protocol: shuffle server methods to group send methods
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11618
diff changeset
    69
    def redirect(self):
e46a8b2331a6 protocol: shuffle server methods to group send methods
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11618
diff changeset
    70
        pass
e46a8b2331a6 protocol: shuffle server methods to group send methods
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11618
diff changeset
    71
11623
31d0a6d50ee2 protocol: extract compression from streaming mechanics
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11622
diff changeset
    72
    def sendresponse(self, v):
31d0a6d50ee2 protocol: extract compression from streaming mechanics
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11622
diff changeset
    73
        self.fout.write("%d\n" % len(v))
31d0a6d50ee2 protocol: extract compression from streaming mechanics
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11622
diff changeset
    74
        self.fout.write(v)
11584
1af96b090116 protocol: unify changegroup commands
Matt Mackall <mpm@selenic.com>
parents: 11581
diff changeset
    75
        self.fout.flush()
1af96b090116 protocol: unify changegroup commands
Matt Mackall <mpm@selenic.com>
parents: 11581
diff changeset
    76
11585
5d907fbb9703 protocol: unify stream_out command
Matt Mackall <mpm@selenic.com>
parents: 11584
diff changeset
    77
    def sendstream(self, source):
17563
46db0ec640f3 sshserver: avoid a multi-dot attribute lookup in a hot loop
Bryan O'Sullivan <bryano@fb.com>
parents: 15585
diff changeset
    78
        write = self.fout.write
35705
8cdb671dbd0b wireproto: drop support for reader interface from streamres (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34436
diff changeset
    79
        for chunk in source.gen:
17563
46db0ec640f3 sshserver: avoid a multi-dot attribute lookup in a hot loop
Bryan O'Sullivan <bryano@fb.com>
parents: 15585
diff changeset
    80
            write(chunk)
11585
5d907fbb9703 protocol: unify stream_out command
Matt Mackall <mpm@selenic.com>
parents: 11584
diff changeset
    81
        self.fout.flush()
5d907fbb9703 protocol: unify stream_out command
Matt Mackall <mpm@selenic.com>
parents: 11584
diff changeset
    82
11625
cdeb861335d5 protocol: wrap non-string protocol responses in classes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11623
diff changeset
    83
    def sendpushresponse(self, rsp):
11622
1d48681b17a4 protocol: rename send methods to get grouping by prefix
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11621
diff changeset
    84
        self.sendresponse('')
11625
cdeb861335d5 protocol: wrap non-string protocol responses in classes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11623
diff changeset
    85
        self.sendresponse(str(rsp.res))
11593
d054cc5c7737 protocol: unify unbundle on the server side
Matt Mackall <mpm@selenic.com>
parents: 11585
diff changeset
    86
12703
40bb5853fc4b wireproto: introduce pusherr() to deal with "unsynced changes" error
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 12337
diff changeset
    87
    def sendpusherror(self, rsp):
40bb5853fc4b wireproto: introduce pusherr() to deal with "unsynced changes" error
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 12337
diff changeset
    88
        self.sendresponse(rsp.res)
40bb5853fc4b wireproto: introduce pusherr() to deal with "unsynced changes" error
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 12337
diff changeset
    89
15017
f4522df38c65 wireproto: add out-of-band error class to allow remote repo to report errors
Andrew Pritchard <andrewp@fogcreek.com>
parents: 14614
diff changeset
    90
    def sendooberror(self, rsp):
f4522df38c65 wireproto: add out-of-band error class to allow remote repo to report errors
Andrew Pritchard <andrewp@fogcreek.com>
parents: 14614
diff changeset
    91
        self.ui.ferr.write('%s\n-\n' % rsp.message)
f4522df38c65 wireproto: add out-of-band error class to allow remote repo to report errors
Andrew Pritchard <andrewp@fogcreek.com>
parents: 14614
diff changeset
    92
        self.ui.ferr.flush()
f4522df38c65 wireproto: add out-of-band error class to allow remote repo to report errors
Andrew Pritchard <andrewp@fogcreek.com>
parents: 14614
diff changeset
    93
        self.fout.write('\n')
f4522df38c65 wireproto: add out-of-band error class to allow remote repo to report errors
Andrew Pritchard <andrewp@fogcreek.com>
parents: 14614
diff changeset
    94
        self.fout.flush()
f4522df38c65 wireproto: add out-of-band error class to allow remote repo to report errors
Andrew Pritchard <andrewp@fogcreek.com>
parents: 14614
diff changeset
    95
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    96
    def serve_forever(self):
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 7875
diff changeset
    97
        try:
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
    98
            while self.serve_one():
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
    99
                pass
8109
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 7875
diff changeset
   100
        finally:
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 7875
diff changeset
   101
            if self.lock is not None:
496ae1ea4698 switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents: 7875
diff changeset
   102
                self.lock.release()
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   103
        sys.exit(0)
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   104
11625
cdeb861335d5 protocol: wrap non-string protocol responses in classes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11623
diff changeset
   105
    handlers = {
cdeb861335d5 protocol: wrap non-string protocol responses in classes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11623
diff changeset
   106
        str: sendresponse,
cdeb861335d5 protocol: wrap non-string protocol responses in classes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11623
diff changeset
   107
        wireproto.streamres: sendstream,
35750
a39a9df7ecca wireproto: split streamres into legacy and modern case
Joerg Sonnenberger <joerg@bec.de>
parents: 35705
diff changeset
   108
        wireproto.streamres_legacy: sendstream,
11625
cdeb861335d5 protocol: wrap non-string protocol responses in classes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11623
diff changeset
   109
        wireproto.pushres: sendpushresponse,
12703
40bb5853fc4b wireproto: introduce pusherr() to deal with "unsynced changes" error
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 12337
diff changeset
   110
        wireproto.pusherr: sendpusherror,
15017
f4522df38c65 wireproto: add out-of-band error class to allow remote repo to report errors
Andrew Pritchard <andrewp@fogcreek.com>
parents: 14614
diff changeset
   111
        wireproto.ooberror: sendooberror,
11625
cdeb861335d5 protocol: wrap non-string protocol responses in classes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11623
diff changeset
   112
    }
cdeb861335d5 protocol: wrap non-string protocol responses in classes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11623
diff changeset
   113
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   114
    def serve_one(self):
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   115
        cmd = self.fin.readline()[:-1]
11618
83070a9cd526 protocol: command must be checked before passing in
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11596
diff changeset
   116
        if cmd and cmd in wireproto.commands:
11625
cdeb861335d5 protocol: wrap non-string protocol responses in classes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11623
diff changeset
   117
            rsp = wireproto.dispatch(self.repo, self, cmd)
cdeb861335d5 protocol: wrap non-string protocol responses in classes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11623
diff changeset
   118
            self.handlers[rsp.__class__](self, rsp)
11618
83070a9cd526 protocol: command must be checked before passing in
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11596
diff changeset
   119
        elif cmd:
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   120
            impl = getattr(self, 'do_' + cmd, None)
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
   121
            if impl:
11580
69248b5add46 protocol: move most ssh responses to returns
Matt Mackall <mpm@selenic.com>
parents: 11579
diff changeset
   122
                r = impl()
69248b5add46 protocol: move most ssh responses to returns
Matt Mackall <mpm@selenic.com>
parents: 11579
diff changeset
   123
                if r is not None:
11622
1d48681b17a4 protocol: rename send methods to get grouping by prefix
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 11621
diff changeset
   124
                    self.sendresponse(r)
34436
5326e4ef1dab style: never put multiple statements on one line
Alex Gaynor <agaynor@mozilla.com>
parents: 30640
diff changeset
   125
            else:
5326e4ef1dab style: never put multiple statements on one line
Alex Gaynor <agaynor@mozilla.com>
parents: 30640
diff changeset
   126
                self.sendresponse("")
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   127
        return cmd != ''
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
   128
11593
d054cc5c7737 protocol: unify unbundle on the server side
Matt Mackall <mpm@selenic.com>
parents: 11585
diff changeset
   129
    def _client(self):
30640
a150173da1c1 py3: replace os.environ with encoding.environ (part 2 of 5)
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30567
diff changeset
   130
        client = encoding.environ.get('SSH_CLIENT', '').split(' ', 1)[0]
2673
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2622
diff changeset
   131
        return 'remote:ssh:' + client