Mercurial > hg-git
comparison dulwich/server.py @ 87:babc85201dc4
merge of upstream work from dulwich project
author | Scott Chacon <schacon@gmail.com> |
---|---|
date | Fri, 08 May 2009 16:12:38 -0700 |
parents | c43c02cc803a |
children |
comparison
equal
deleted
inserted
replaced
86:3ce739f2bd7e | 87:babc85201dc4 |
---|---|
14 # You should have received a copy of the GNU General Public License | 14 # You should have received a copy of the GNU General Public License |
15 # along with this program; if not, write to the Free Software | 15 # along with this program; if not, write to the Free Software |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
17 # MA 02110-1301, USA. | 17 # MA 02110-1301, USA. |
18 | 18 |
19 | |
20 """Git smart network protocol server implementation.""" | |
21 | |
22 | |
19 import SocketServer | 23 import SocketServer |
20 import tempfile | 24 import tempfile |
21 | 25 |
22 from protocol import ( | 26 from protocol import ( |
23 Protocol, | 27 Protocol, |
86 | 90 |
87 print "pack applied" | 91 print "pack applied" |
88 | 92 |
89 | 93 |
90 class Handler(object): | 94 class Handler(object): |
95 """Smart protocol command handler base class.""" | |
91 | 96 |
92 def __init__(self, backend, read, write): | 97 def __init__(self, backend, read, write): |
93 self.backend = backend | 98 self.backend = backend |
94 self.proto = Protocol(read, write) | 99 self.proto = Protocol(read, write) |
95 | 100 |
96 def capabilities(self): | 101 def capabilities(self): |
97 return " ".join(self.default_capabilities()) | 102 return " ".join(self.default_capabilities()) |
98 | 103 |
99 | 104 |
100 class UploadPackHandler(Handler): | 105 class UploadPackHandler(Handler): |
106 """Protocol handler for uploading a pack to the server.""" | |
101 | 107 |
102 def default_capabilities(self): | 108 def default_capabilities(self): |
103 return ("multi_ack", "side-band-64k", "thin-pack", "ofs-delta") | 109 return ("multi_ack", "side-band-64k", "thin-pack", "ofs-delta") |
104 | 110 |
105 def handle(self): | 111 def handle(self): |
168 # we are done | 174 # we are done |
169 self.proto.write("0000") | 175 self.proto.write("0000") |
170 | 176 |
171 | 177 |
172 class ReceivePackHandler(Handler): | 178 class ReceivePackHandler(Handler): |
179 """Protocol handler for downloading a pack to the client.""" | |
173 | 180 |
174 def default_capabilities(self): | 181 def default_capabilities(self): |
175 return ("report-status", "delete-refs") | 182 return ("report-status", "delete-refs") |
176 | 183 |
177 def handle(self): | 184 def handle(self): |
202 ref = self.proto.read_pkt_line() | 209 ref = self.proto.read_pkt_line() |
203 | 210 |
204 # backend can now deal with this refs and read a pack using self.read | 211 # backend can now deal with this refs and read a pack using self.read |
205 self.backend.apply_pack(client_refs, self.proto.read) | 212 self.backend.apply_pack(client_refs, self.proto.read) |
206 | 213 |
207 # when we have read all the pack from the client, it assumes everything worked OK | 214 # when we have read all the pack from the client, it assumes |
215 # everything worked OK. | |
208 # there is NO ack from the server before it reports victory. | 216 # there is NO ack from the server before it reports victory. |
209 | 217 |
210 | 218 |
211 class TCPGitRequestHandler(SocketServer.StreamRequestHandler): | 219 class TCPGitRequestHandler(SocketServer.StreamRequestHandler): |
212 | 220 |