equal
deleted
inserted
replaced
30 from .node import ( |
30 from .node import ( |
31 bin, |
31 bin, |
32 hex, |
32 hex, |
33 nullrev, |
33 nullrev, |
34 short, |
34 short, |
35 ) |
|
36 from .pycompat import ( |
|
37 open, |
|
38 ) |
35 ) |
39 from . import ( |
36 from . import ( |
40 bundle2, |
37 bundle2, |
41 bundlerepo, |
38 bundlerepo, |
42 changegroup, |
39 changegroup, |
1382 """download a resource using Mercurial logic and config""" |
1379 """download a resource using Mercurial logic and config""" |
1383 fh = urlmod.open(ui, url, output) |
1380 fh = urlmod.open(ui, url, output) |
1384 |
1381 |
1385 dest = ui |
1382 dest = ui |
1386 if output: |
1383 if output: |
1387 dest = open(output, b"wb", _chunksize) |
1384 dest = open(output, "wb", _chunksize) |
1388 try: |
1385 try: |
1389 data = fh.read(_chunksize) |
1386 data = fh.read(_chunksize) |
1390 while data: |
1387 while data: |
1391 dest.write(data) |
1388 dest.write(data) |
1392 data = fh.read(_chunksize) |
1389 data = fh.read(_chunksize) |
3441 if e.errno != errno.ESPIPE: |
3438 if e.errno != errno.ESPIPE: |
3442 raise |
3439 raise |
3443 # can't seek a pipe, so `ab` mode fails on py3 |
3440 # can't seek a pipe, so `ab` mode fails on py3 |
3444 logfh = os.fdopen(int(opts['logiofd']), 'wb', 0) |
3441 logfh = os.fdopen(int(opts['logiofd']), 'wb', 0) |
3445 elif opts['logiofile']: |
3442 elif opts['logiofile']: |
3446 logfh = open(opts['logiofile'], b'ab', 0) |
3443 logfh = open(opts['logiofile'], 'ab', 0) |
3447 |
3444 |
3448 s = wireprotoserver.sshserver(ui, repo, logfh=logfh) |
3445 s = wireprotoserver.sshserver(ui, repo, logfh=logfh) |
3449 s.serve_forever() |
3446 s.serve_forever() |
3450 |
3447 |
3451 |
3448 |
4697 value = pycompat.strurl(m.group(2)) |
4694 value = pycompat.strurl(m.group(2)) |
4698 headers[key] = value |
4695 headers[key] = value |
4699 continue |
4696 continue |
4700 |
4697 |
4701 if line.startswith(b'BODYFILE '): |
4698 if line.startswith(b'BODYFILE '): |
4702 with open(line.split(b' ', 1), b'rb') as fh: |
4699 with open(line.split(b' ', 1), 'rb') as fh: |
4703 body = fh.read() |
4700 body = fh.read() |
4704 elif line.startswith(b'frame '): |
4701 elif line.startswith(b'frame '): |
4705 frame = wireprotoframing.makeframefromhumanstring( |
4702 frame = wireprotoframing.makeframefromhumanstring( |
4706 line[len(b'frame ') :] |
4703 line[len(b'frame ') :] |
4707 ) |
4704 ) |