/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzr-upload-pack

Better (but still incomplete) design for bogus servers.

* bzrlib/transport/http/_urllib2_wrappers.py:
(AbstractHTTPHandler): Add 'Accept: */*' again to default headers
until I fully understand why and when it's needed or not (curl add
it if no Accept header is present).

* bzrlib/transport/http/_pycurl.py:
(PyCurlTransport._curl_perform): CURLE_GOT_NOTHING may be
considered as a ConnectionError, inspection of curl code reveals
that the case is sufficiently rare and low level related to not be
considered an http error per se.

* bzrlib/transport/http/__init__.py:
(WallHttpServer): Deleted.

* bzrlib/tests/test_http.py:
(TestBogusServer): Factor out the tests common to the bogus
servers.

* bzrlib/tests/__init__.py:
(TestCaseWithTransport.create_transport_server,
TestCaseWithTransport.create_transport_readonly_server): New
methods, allows test cases to specify the transport servers
without defining useless classes.
(TestCaseWithTransport.get_readonly_server): Use
create_transport_readonly_server.
(TestCaseWithTransport.get_server): Use create_transport_server.

* bzrlib/tests/HTTPTestUtil.py:
(TestCaseWithWebserver): Fix typo in doc string.
(TestCaseWithWallserver): Deleted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
import bzrlib
3
 
from bzrlib.plugin import load_plugins
4
 
load_plugins ()
5
 
from bzrlib.plugins.git.server import BzrBackend
6
 
from dulwich.server import UploadPackHandler
7
 
import sys, os, optparse
8
 
 
9
 
parser = optparse.OptionParser(usage="usage: git-upload-pack [--strict] [--timeout=nn] <dir>")
10
 
parser.add_option("--strict", action="store_true", dest="strict", default=False)
11
 
parser.add_option("--timeout", type="int", dest="timeout", default=-1)
12
 
options, args = parser.parse_args()
13
 
 
14
 
if len(args) != 1 or not os.path.isdir(args[0]):
15
 
    print "usage: " + parser.usage
16
 
    sys.exit(1)
17
 
 
18
 
backend = BzrBackend(bzrlib.transport.get_transport(sys.argv[1]))
19
 
 
20
 
def write_fn(data):
21
 
    sys.stdout.write(data)
22
 
    sys.stdout.flush()
23
 
 
24
 
server = UploadPackHandler(backend, sys.stdin.read, write_fn)
25
 
server.handle()