|
@@ -79,10 +79,10 @@ def _fileno_can_read(fileno):
|
|
"""Check if a file descriptor is readable."""
|
|
"""Check if a file descriptor is readable."""
|
|
return len(select.select([fileno], [], [], 0)[0]) > 0
|
|
return len(select.select([fileno], [], [], 0)[0]) > 0
|
|
|
|
|
|
-COMMON_CAPABILITIES = ['ofs-delta', 'side-band-64k']
|
|
|
|
-FETCH_CAPABILITIES = (['thin-pack', 'multi_ack', 'multi_ack_detailed'] +
|
|
|
|
|
|
+COMMON_CAPABILITIES = [b'ofs-delta', b'side-band-64k']
|
|
|
|
+FETCH_CAPABILITIES = ([b'thin-pack', b'multi_ack', b'multi_ack_detailed'] +
|
|
COMMON_CAPABILITIES)
|
|
COMMON_CAPABILITIES)
|
|
-SEND_CAPABILITIES = ['report-status'] + COMMON_CAPABILITIES
|
|
|
|
|
|
+SEND_CAPABILITIES = [b'report-status'] + COMMON_CAPABILITIES
|
|
|
|
|
|
|
|
|
|
class ReportStatusParser(object):
|
|
class ReportStatusParser(object):
|
|
@@ -101,26 +101,26 @@ class ReportStatusParser(object):
|
|
:raise SendPackError: Raised when the server could not unpack
|
|
:raise SendPackError: Raised when the server could not unpack
|
|
:raise UpdateRefsError: Raised when refs could not be updated
|
|
:raise UpdateRefsError: Raised when refs could not be updated
|
|
"""
|
|
"""
|
|
- if self._pack_status not in ('unpack ok', None):
|
|
|
|
|
|
+ if self._pack_status not in (b'unpack ok', None):
|
|
raise SendPackError(self._pack_status)
|
|
raise SendPackError(self._pack_status)
|
|
if not self._ref_status_ok:
|
|
if not self._ref_status_ok:
|
|
ref_status = {}
|
|
ref_status = {}
|
|
ok = set()
|
|
ok = set()
|
|
for status in self._ref_statuses:
|
|
for status in self._ref_statuses:
|
|
- if ' ' not in status:
|
|
|
|
|
|
+ if b' ' not in status:
|
|
# malformed response, move on to the next one
|
|
# malformed response, move on to the next one
|
|
continue
|
|
continue
|
|
- status, ref = status.split(' ', 1)
|
|
|
|
|
|
+ status, ref = status.split(b' ', 1)
|
|
|
|
|
|
- if status == 'ng':
|
|
|
|
- if ' ' in ref:
|
|
|
|
- ref, status = ref.split(' ', 1)
|
|
|
|
|
|
+ if status == b'ng':
|
|
|
|
+ if b' ' in ref:
|
|
|
|
+ ref, status = ref.split(b' ', 1)
|
|
else:
|
|
else:
|
|
ok.add(ref)
|
|
ok.add(ref)
|
|
ref_status[ref] = status
|
|
ref_status[ref] = status
|
|
- raise UpdateRefsError('%s failed to update' %
|
|
|
|
- ', '.join([ref for ref in ref_status
|
|
|
|
- if ref not in ok]),
|
|
|
|
|
|
+ raise UpdateRefsError(b', '.join([ref for ref in ref_status
|
|
|
|
+ if ref not in ok]) +
|
|
|
|
+ b' failed to update',
|
|
ref_status=ref_status)
|
|
ref_status=ref_status)
|
|
|
|
|
|
def handle_packet(self, pkt):
|
|
def handle_packet(self, pkt):
|
|
@@ -139,7 +139,7 @@ class ReportStatusParser(object):
|
|
else:
|
|
else:
|
|
ref_status = pkt.strip()
|
|
ref_status = pkt.strip()
|
|
self._ref_statuses.append(ref_status)
|
|
self._ref_statuses.append(ref_status)
|
|
- if not ref_status.startswith('ok '):
|
|
|
|
|
|
+ if not ref_status.startswith(b'ok '):
|
|
self._ref_status_ok = False
|
|
self._ref_status_ok = False
|
|
|
|
|
|
|
|
|
|
@@ -148,8 +148,8 @@ def read_pkt_refs(proto):
|
|
refs = {}
|
|
refs = {}
|
|
# Receive refs from server
|
|
# Receive refs from server
|
|
for pkt in proto.read_pkt_seq():
|
|
for pkt in proto.read_pkt_seq():
|
|
- (sha, ref) = pkt.rstrip('\n').split(None, 1)
|
|
|
|
- if sha == 'ERR':
|
|
|
|
|
|
+ (sha, ref) = pkt.rstrip(b'\n').split(None, 1)
|
|
|
|
+ if sha == b'ERR':
|
|
raise GitProtocolError(ref)
|
|
raise GitProtocolError(ref)
|
|
if server_capabilities is None:
|
|
if server_capabilities is None:
|
|
(ref, server_capabilities) = extract_capabilities(ref)
|
|
(ref, server_capabilities) = extract_capabilities(ref)
|
|
@@ -180,7 +180,7 @@ class GitClient(object):
|
|
self._fetch_capabilities = set(FETCH_CAPABILITIES)
|
|
self._fetch_capabilities = set(FETCH_CAPABILITIES)
|
|
self._send_capabilities = set(SEND_CAPABILITIES)
|
|
self._send_capabilities = set(SEND_CAPABILITIES)
|
|
if not thin_packs:
|
|
if not thin_packs:
|
|
- self._fetch_capabilities.remove('thin-pack')
|
|
|
|
|
|
+ self._fetch_capabilities.remove(b'thin-pack')
|
|
|
|
|
|
def send_pack(self, path, determine_wants, generate_pack_contents,
|
|
def send_pack(self, path, determine_wants, generate_pack_contents,
|
|
progress=None, write_pack=write_pack_objects):
|
|
progress=None, write_pack=write_pack_objects):
|
|
@@ -236,7 +236,7 @@ class GitClient(object):
|
|
|
|
|
|
def _parse_status_report(self, proto):
|
|
def _parse_status_report(self, proto):
|
|
unpack = proto.read_pkt_line().strip()
|
|
unpack = proto.read_pkt_line().strip()
|
|
- if unpack != 'unpack ok':
|
|
|
|
|
|
+ if unpack != b'unpack ok':
|
|
st = True
|
|
st = True
|
|
# flush remaining error data
|
|
# flush remaining error data
|
|
while st is not None:
|
|
while st is not None:
|
|
@@ -248,7 +248,7 @@ class GitClient(object):
|
|
while ref_status:
|
|
while ref_status:
|
|
ref_status = ref_status.strip()
|
|
ref_status = ref_status.strip()
|
|
statuses.append(ref_status)
|
|
statuses.append(ref_status)
|
|
- if not ref_status.startswith('ok '):
|
|
|
|
|
|
+ if not ref_status.startswith(b'ok '):
|
|
errs = True
|
|
errs = True
|
|
ref_status = proto.read_pkt_line()
|
|
ref_status = proto.read_pkt_line()
|
|
|
|
|
|
@@ -256,20 +256,20 @@ class GitClient(object):
|
|
ref_status = {}
|
|
ref_status = {}
|
|
ok = set()
|
|
ok = set()
|
|
for status in statuses:
|
|
for status in statuses:
|
|
- if ' ' not in status:
|
|
|
|
|
|
+ if b' ' not in status:
|
|
# malformed response, move on to the next one
|
|
# malformed response, move on to the next one
|
|
continue
|
|
continue
|
|
- status, ref = status.split(' ', 1)
|
|
|
|
|
|
+ status, ref = status.split(b' ', 1)
|
|
|
|
|
|
- if status == 'ng':
|
|
|
|
- if ' ' in ref:
|
|
|
|
- ref, status = ref.split(' ', 1)
|
|
|
|
|
|
+ if status == b'ng':
|
|
|
|
+ if b' ' in ref:
|
|
|
|
+ ref, status = ref.split(b' ', 1)
|
|
else:
|
|
else:
|
|
ok.add(ref)
|
|
ok.add(ref)
|
|
ref_status[ref] = status
|
|
ref_status[ref] = status
|
|
- raise UpdateRefsError('%s failed to update' %
|
|
|
|
- ', '.join([ref for ref in ref_status
|
|
|
|
- if ref not in ok]),
|
|
|
|
|
|
+ raise UpdateRefsError(b', '.join([ref for ref in ref_status
|
|
|
|
+ if ref not in ok]) +
|
|
|
|
+ b' failed to update',
|
|
ref_status=ref_status)
|
|
ref_status=ref_status)
|
|
|
|
|
|
def _read_side_band64k_data(self, proto, channel_callbacks):
|
|
def _read_side_band64k_data(self, proto, channel_callbacks):
|
|
@@ -282,7 +282,7 @@ class GitClient(object):
|
|
handlers to use. None for a callback discards channel data.
|
|
handlers to use. None for a callback discards channel data.
|
|
"""
|
|
"""
|
|
for pkt in proto.read_pkt_seq():
|
|
for pkt in proto.read_pkt_seq():
|
|
- channel = ord(pkt[0])
|
|
|
|
|
|
+ channel = ord(pkt[:1])
|
|
pkt = pkt[1:]
|
|
pkt = pkt[1:]
|
|
try:
|
|
try:
|
|
cb = channel_callbacks[channel]
|
|
cb = channel_callbacks[channel]
|
|
@@ -306,18 +306,18 @@ class GitClient(object):
|
|
have = [x for x in old_refs.values() if not x == ZERO_SHA]
|
|
have = [x for x in old_refs.values() if not x == ZERO_SHA]
|
|
sent_capabilities = False
|
|
sent_capabilities = False
|
|
|
|
|
|
- for refname in set(new_refs.keys() + old_refs.keys()):
|
|
|
|
|
|
+ all_refs = set(new_refs.keys()).union(set(old_refs.keys()))
|
|
|
|
+ for refname in all_refs:
|
|
old_sha1 = old_refs.get(refname, ZERO_SHA)
|
|
old_sha1 = old_refs.get(refname, ZERO_SHA)
|
|
new_sha1 = new_refs.get(refname, ZERO_SHA)
|
|
new_sha1 = new_refs.get(refname, ZERO_SHA)
|
|
|
|
|
|
if old_sha1 != new_sha1:
|
|
if old_sha1 != new_sha1:
|
|
if sent_capabilities:
|
|
if sent_capabilities:
|
|
- proto.write_pkt_line('%s %s %s' % (
|
|
|
|
- old_sha1, new_sha1, refname))
|
|
|
|
|
|
+ proto.write_pkt_line(old_sha1 + b' ' + new_sha1 + b' ' + refname)
|
|
else:
|
|
else:
|
|
proto.write_pkt_line(
|
|
proto.write_pkt_line(
|
|
- '%s %s %s\0%s' % (old_sha1, new_sha1, refname,
|
|
|
|
- ' '.join(capabilities)))
|
|
|
|
|
|
+ old_sha1 + b' ' + new_sha1 + b' ' + refname + b'\0' +
|
|
|
|
+ b' '.join(capabilities))
|
|
sent_capabilities = True
|
|
sent_capabilities = True
|
|
if new_sha1 not in have and new_sha1 != ZERO_SHA:
|
|
if new_sha1 not in have and new_sha1 != ZERO_SHA:
|
|
want.append(new_sha1)
|
|
want.append(new_sha1)
|
|
@@ -331,16 +331,16 @@ class GitClient(object):
|
|
:param capabilities: List of negotiated capabilities
|
|
:param capabilities: List of negotiated capabilities
|
|
:param progress: Optional progress reporting function
|
|
:param progress: Optional progress reporting function
|
|
"""
|
|
"""
|
|
- if "side-band-64k" in capabilities:
|
|
|
|
|
|
+ if b"side-band-64k" in capabilities:
|
|
if progress is None:
|
|
if progress is None:
|
|
progress = lambda x: None
|
|
progress = lambda x: None
|
|
channel_callbacks = {2: progress}
|
|
channel_callbacks = {2: progress}
|
|
- if 'report-status' in capabilities:
|
|
|
|
|
|
+ if b'report-status' in capabilities:
|
|
channel_callbacks[1] = PktLineParser(
|
|
channel_callbacks[1] = PktLineParser(
|
|
self._report_status_parser.handle_packet).parse
|
|
self._report_status_parser.handle_packet).parse
|
|
self._read_side_band64k_data(proto, channel_callbacks)
|
|
self._read_side_band64k_data(proto, channel_callbacks)
|
|
else:
|
|
else:
|
|
- if 'report-status' in capabilities:
|
|
|
|
|
|
+ if b'report-status' in capabilities:
|
|
for pkt in proto.read_pkt_seq():
|
|
for pkt in proto.read_pkt_seq():
|
|
self._report_status_parser.handle_packet(pkt)
|
|
self._report_status_parser.handle_packet(pkt)
|
|
if self._report_status_parser is not None:
|
|
if self._report_status_parser is not None:
|
|
@@ -357,30 +357,29 @@ class GitClient(object):
|
|
:param can_read: function that returns a boolean that indicates
|
|
:param can_read: function that returns a boolean that indicates
|
|
whether there is extra graph data to read on proto
|
|
whether there is extra graph data to read on proto
|
|
"""
|
|
"""
|
|
- assert isinstance(wants, list) and isinstance(wants[0], str)
|
|
|
|
- proto.write_pkt_line('want %s %s\n' % (
|
|
|
|
- wants[0], ' '.join(capabilities)))
|
|
|
|
|
|
+ assert isinstance(wants, list) and isinstance(wants[0], bytes)
|
|
|
|
+ proto.write_pkt_line(b'want ' + wants[0] + b' ' + b' '.join(capabilities) + b'\n')
|
|
for want in wants[1:]:
|
|
for want in wants[1:]:
|
|
- proto.write_pkt_line('want %s\n' % want)
|
|
|
|
|
|
+ proto.write_pkt_line(b'want ' + want + b'\n')
|
|
proto.write_pkt_line(None)
|
|
proto.write_pkt_line(None)
|
|
have = next(graph_walker)
|
|
have = next(graph_walker)
|
|
while have:
|
|
while have:
|
|
- proto.write_pkt_line('have %s\n' % have)
|
|
|
|
|
|
+ proto.write_pkt_line(b'have ' + have + b'\n')
|
|
if can_read():
|
|
if can_read():
|
|
pkt = proto.read_pkt_line()
|
|
pkt = proto.read_pkt_line()
|
|
- parts = pkt.rstrip('\n').split(' ')
|
|
|
|
- if parts[0] == 'ACK':
|
|
|
|
|
|
+ parts = pkt.rstrip(b'\n').split(b' ')
|
|
|
|
+ if parts[0] == b'ACK':
|
|
graph_walker.ack(parts[1])
|
|
graph_walker.ack(parts[1])
|
|
- if parts[2] in ('continue', 'common'):
|
|
|
|
|
|
+ if parts[2] in (b'continue', b'common'):
|
|
pass
|
|
pass
|
|
- elif parts[2] == 'ready':
|
|
|
|
|
|
+ elif parts[2] == b'ready':
|
|
break
|
|
break
|
|
else:
|
|
else:
|
|
raise AssertionError(
|
|
raise AssertionError(
|
|
"%s not in ('continue', 'ready', 'common)" %
|
|
"%s not in ('continue', 'ready', 'common)" %
|
|
parts[2])
|
|
parts[2])
|
|
have = next(graph_walker)
|
|
have = next(graph_walker)
|
|
- proto.write_pkt_line('done\n')
|
|
|
|
|
|
+ proto.write_pkt_line(b'done\n')
|
|
|
|
|
|
def _handle_upload_pack_tail(self, proto, capabilities, graph_walker,
|
|
def _handle_upload_pack_tail(self, proto, capabilities, graph_walker,
|
|
pack_data, progress=None, rbufsize=_RBUFSIZE):
|
|
pack_data, progress=None, rbufsize=_RBUFSIZE):
|
|
@@ -395,14 +394,14 @@ class GitClient(object):
|
|
"""
|
|
"""
|
|
pkt = proto.read_pkt_line()
|
|
pkt = proto.read_pkt_line()
|
|
while pkt:
|
|
while pkt:
|
|
- parts = pkt.rstrip('\n').split(' ')
|
|
|
|
- if parts[0] == 'ACK':
|
|
|
|
|
|
+ parts = pkt.rstrip(b'\n').split(b' ')
|
|
|
|
+ if parts[0] == b'ACK':
|
|
graph_walker.ack(parts[1])
|
|
graph_walker.ack(parts[1])
|
|
if len(parts) < 3 or parts[2] not in (
|
|
if len(parts) < 3 or parts[2] not in (
|
|
- 'ready', 'continue', 'common'):
|
|
|
|
|
|
+ b'ready', b'continue', b'common'):
|
|
break
|
|
break
|
|
pkt = proto.read_pkt_line()
|
|
pkt = proto.read_pkt_line()
|
|
- if "side-band-64k" in capabilities:
|
|
|
|
|
|
+ if b"side-band-64k" in capabilities:
|
|
if progress is None:
|
|
if progress is None:
|
|
# Just ignore progress data
|
|
# Just ignore progress data
|
|
progress = lambda x: None
|
|
progress = lambda x: None
|
|
@@ -410,7 +409,7 @@ class GitClient(object):
|
|
else:
|
|
else:
|
|
while True:
|
|
while True:
|
|
data = proto.read(rbufsize)
|
|
data = proto.read(rbufsize)
|
|
- if data == "":
|
|
|
|
|
|
+ if data == b"":
|
|
break
|
|
break
|
|
pack_data(data)
|
|
pack_data(data)
|
|
|
|
|
|
@@ -447,12 +446,12 @@ class TraditionalGitClient(GitClient):
|
|
:raises UpdateRefsError: if the server supports report-status
|
|
:raises UpdateRefsError: if the server supports report-status
|
|
and rejects ref updates
|
|
and rejects ref updates
|
|
"""
|
|
"""
|
|
- proto, unused_can_read = self._connect('receive-pack', path)
|
|
|
|
|
|
+ proto, unused_can_read = self._connect(b'receive-pack', path)
|
|
with proto:
|
|
with proto:
|
|
old_refs, server_capabilities = read_pkt_refs(proto)
|
|
old_refs, server_capabilities = read_pkt_refs(proto)
|
|
negotiated_capabilities = self._send_capabilities & server_capabilities
|
|
negotiated_capabilities = self._send_capabilities & server_capabilities
|
|
|
|
|
|
- if 'report-status' in negotiated_capabilities:
|
|
|
|
|
|
+ if b'report-status' in negotiated_capabilities:
|
|
self._report_status_parser = ReportStatusParser()
|
|
self._report_status_parser = ReportStatusParser()
|
|
report_status_parser = self._report_status_parser
|
|
report_status_parser = self._report_status_parser
|
|
|
|
|
|
@@ -462,15 +461,14 @@ class TraditionalGitClient(GitClient):
|
|
proto.write_pkt_line(None)
|
|
proto.write_pkt_line(None)
|
|
raise
|
|
raise
|
|
|
|
|
|
- if not 'delete-refs' in server_capabilities:
|
|
|
|
|
|
+ if not b'delete-refs' in server_capabilities:
|
|
# Server does not support deletions. Fail later.
|
|
# Server does not support deletions. Fail later.
|
|
new_refs = dict(orig_new_refs)
|
|
new_refs = dict(orig_new_refs)
|
|
- for ref, sha in orig_new_refs.iteritems():
|
|
|
|
|
|
+ for ref, sha in orig_new_refs.items():
|
|
if sha == ZERO_SHA:
|
|
if sha == ZERO_SHA:
|
|
- if 'report-status' in negotiated_capabilities:
|
|
|
|
|
|
+ if b'report-status' in negotiated_capabilities:
|
|
report_status_parser._ref_statuses.append(
|
|
report_status_parser._ref_statuses.append(
|
|
- 'ng %s remote does not support deleting refs'
|
|
|
|
- % sha)
|
|
|
|
|
|
+ b'ng ' + sha + b' remote does not support deleting refs')
|
|
report_status_parser._ref_status_ok = False
|
|
report_status_parser._ref_status_ok = False
|
|
del new_refs[ref]
|
|
del new_refs[ref]
|
|
|
|
|
|
@@ -493,7 +491,7 @@ class TraditionalGitClient(GitClient):
|
|
|
|
|
|
dowrite = len(objects) > 0
|
|
dowrite = len(objects) > 0
|
|
dowrite = dowrite or any(old_refs.get(ref) != sha
|
|
dowrite = dowrite or any(old_refs.get(ref) != sha
|
|
- for (ref, sha) in new_refs.iteritems()
|
|
|
|
|
|
+ for (ref, sha) in new_refs.items()
|
|
if sha != ZERO_SHA)
|
|
if sha != ZERO_SHA)
|
|
if dowrite:
|
|
if dowrite:
|
|
write_pack(proto.write_file(), objects)
|
|
write_pack(proto.write_file(), objects)
|
|
@@ -511,7 +509,7 @@ class TraditionalGitClient(GitClient):
|
|
:param pack_data: Callback called for each bit of data in the pack
|
|
:param pack_data: Callback called for each bit of data in the pack
|
|
:param progress: Callback for progress reports (strings)
|
|
:param progress: Callback for progress reports (strings)
|
|
"""
|
|
"""
|
|
- proto, can_read = self._connect('upload-pack', path)
|
|
|
|
|
|
+ proto, can_read = self._connect(b'upload-pack', path)
|
|
with proto:
|
|
with proto:
|
|
refs, server_capabilities = read_pkt_refs(proto)
|
|
refs, server_capabilities = read_pkt_refs(proto)
|
|
negotiated_capabilities = (
|
|
negotiated_capabilities = (
|
|
@@ -541,15 +539,15 @@ class TraditionalGitClient(GitClient):
|
|
write_error=None):
|
|
write_error=None):
|
|
proto, can_read = self._connect(b'upload-archive', path)
|
|
proto, can_read = self._connect(b'upload-archive', path)
|
|
with proto:
|
|
with proto:
|
|
- proto.write_pkt_line("argument %s" % committish)
|
|
|
|
|
|
+ proto.write_pkt_line(b"argument " + committish)
|
|
proto.write_pkt_line(None)
|
|
proto.write_pkt_line(None)
|
|
pkt = proto.read_pkt_line()
|
|
pkt = proto.read_pkt_line()
|
|
- if pkt == "NACK\n":
|
|
|
|
|
|
+ if pkt == b"NACK\n":
|
|
return
|
|
return
|
|
- elif pkt == "ACK\n":
|
|
|
|
|
|
+ elif pkt == b"ACK\n":
|
|
pass
|
|
pass
|
|
- elif pkt.startswith("ERR "):
|
|
|
|
- raise GitProtocolError(pkt[4:].rstrip("\n"))
|
|
|
|
|
|
+ elif pkt.startswith(b"ERR "):
|
|
|
|
+ raise GitProtocolError(pkt[4:].rstrip(b"\n"))
|
|
else:
|
|
else:
|
|
raise AssertionError("invalid response %r" % pkt)
|
|
raise AssertionError("invalid response %r" % pkt)
|
|
ret = proto.read_pkt_line()
|
|
ret = proto.read_pkt_line()
|
|
@@ -597,9 +595,9 @@ class TCPGitClient(TraditionalGitClient):
|
|
|
|
|
|
proto = Protocol(rfile.read, wfile.write, close,
|
|
proto = Protocol(rfile.read, wfile.write, close,
|
|
report_activity=self._report_activity)
|
|
report_activity=self._report_activity)
|
|
- if path.startswith("/~"):
|
|
|
|
|
|
+ if path.startswith(b"/~"):
|
|
path = path[1:]
|
|
path = path[1:]
|
|
- proto.send_cmd('git-%s' % cmd, path, 'host=%s' % self._host)
|
|
|
|
|
|
+ proto.send_cmd(b'git-' + cmd, path, b'host=' + self._host)
|
|
return proto, lambda: _fileno_can_read(s)
|
|
return proto, lambda: _fileno_can_read(s)
|
|
|
|
|
|
|
|
|
|
@@ -688,7 +686,8 @@ class LocalGitClient(GitClient):
|
|
|
|
|
|
have = [sha1 for sha1 in old_refs.values() if sha1 != ZERO_SHA]
|
|
have = [sha1 for sha1 in old_refs.values() if sha1 != ZERO_SHA]
|
|
want = []
|
|
want = []
|
|
- for refname in set(new_refs.keys() + old_refs.keys()):
|
|
|
|
|
|
+ all_refs = set(new_refs.keys()).union(set(old_refs.keys()))
|
|
|
|
+ for refname in all_refs:
|
|
old_sha1 = old_refs.get(refname, ZERO_SHA)
|
|
old_sha1 = old_refs.get(refname, ZERO_SHA)
|
|
new_sha1 = new_refs.get(refname, ZERO_SHA)
|
|
new_sha1 = new_refs.get(refname, ZERO_SHA)
|
|
if new_sha1 not in have and new_sha1 != ZERO_SHA:
|
|
if new_sha1 not in have and new_sha1 != ZERO_SHA:
|
|
@@ -699,7 +698,7 @@ class LocalGitClient(GitClient):
|
|
|
|
|
|
target.object_store.add_objects(generate_pack_contents(have, want))
|
|
target.object_store.add_objects(generate_pack_contents(have, want))
|
|
|
|
|
|
- for name, sha in new_refs.iteritems():
|
|
|
|
|
|
+ for name, sha in new_refs.items():
|
|
target.refs[name] = sha
|
|
target.refs[name] = sha
|
|
|
|
|
|
return new_refs
|
|
return new_refs
|
|
@@ -909,16 +908,16 @@ class SSHGitClient(TraditionalGitClient):
|
|
self.alternative_paths = {}
|
|
self.alternative_paths = {}
|
|
|
|
|
|
def _get_cmd_path(self, cmd):
|
|
def _get_cmd_path(self, cmd):
|
|
- return self.alternative_paths.get(cmd, 'git-%s' % cmd)
|
|
|
|
|
|
+ return self.alternative_paths.get(cmd, b'git-' + cmd)
|
|
|
|
|
|
def _connect(self, cmd, path):
|
|
def _connect(self, cmd, path):
|
|
- if path.startswith("/~"):
|
|
|
|
|
|
+ if path.startswith(b"/~"):
|
|
path = path[1:]
|
|
path = path[1:]
|
|
con = get_ssh_vendor().run_command(
|
|
con = get_ssh_vendor().run_command(
|
|
- self.host, ["%s '%s'" % (self._get_cmd_path(cmd), path)],
|
|
|
|
|
|
+ self.host, [self._get_cmd_path(cmd) + b" '" + path + b"'"],
|
|
port=self.port, username=self.username)
|
|
port=self.port, username=self.username)
|
|
- return (Protocol(con.read, con.write, con.close,
|
|
|
|
- report_activity=self._report_activity),
|
|
|
|
|
|
+ return (Protocol(con.read, con.write, con.close,
|
|
|
|
+ report_activity=self._report_activity),
|
|
con.can_read)
|
|
con.can_read)
|
|
|
|
|
|
|
|
|
|
@@ -1021,10 +1020,10 @@ class HttpGitClient(GitClient):
|
|
"""
|
|
"""
|
|
url = self._get_url(path)
|
|
url = self._get_url(path)
|
|
old_refs, server_capabilities = self._discover_references(
|
|
old_refs, server_capabilities = self._discover_references(
|
|
- "git-receive-pack", url)
|
|
|
|
|
|
+ b"git-receive-pack", url)
|
|
negotiated_capabilities = self._send_capabilities & server_capabilities
|
|
negotiated_capabilities = self._send_capabilities & server_capabilities
|
|
|
|
|
|
- if 'report-status' in negotiated_capabilities:
|
|
|
|
|
|
+ if b'report-status' in negotiated_capabilities:
|
|
self._report_status_parser = ReportStatusParser()
|
|
self._report_status_parser = ReportStatusParser()
|
|
|
|
|
|
new_refs = determine_wants(dict(old_refs))
|
|
new_refs = determine_wants(dict(old_refs))
|
|
@@ -1041,7 +1040,7 @@ class HttpGitClient(GitClient):
|
|
objects = generate_pack_contents(have, want)
|
|
objects = generate_pack_contents(have, want)
|
|
if len(objects) > 0:
|
|
if len(objects) > 0:
|
|
write_pack(req_proto.write_file(), objects)
|
|
write_pack(req_proto.write_file(), objects)
|
|
- resp = self._smart_request("git-receive-pack", url,
|
|
|
|
|
|
+ resp = self._smart_request(b"git-receive-pack", url,
|
|
data=req_data.getvalue())
|
|
data=req_data.getvalue())
|
|
try:
|
|
try:
|
|
resp_proto = Protocol(resp.read, None)
|
|
resp_proto = Protocol(resp.read, None)
|
|
@@ -1064,7 +1063,7 @@ class HttpGitClient(GitClient):
|
|
"""
|
|
"""
|
|
url = self._get_url(path)
|
|
url = self._get_url(path)
|
|
refs, server_capabilities = self._discover_references(
|
|
refs, server_capabilities = self._discover_references(
|
|
- "git-upload-pack", url)
|
|
|
|
|
|
+ b"git-upload-pack", url)
|
|
negotiated_capabilities = self._fetch_capabilities & server_capabilities
|
|
negotiated_capabilities = self._fetch_capabilities & server_capabilities
|
|
wants = determine_wants(refs)
|
|
wants = determine_wants(refs)
|
|
if wants is not None:
|
|
if wants is not None:
|
|
@@ -1079,7 +1078,7 @@ class HttpGitClient(GitClient):
|
|
req_proto, negotiated_capabilities, graph_walker, wants,
|
|
req_proto, negotiated_capabilities, graph_walker, wants,
|
|
lambda: False)
|
|
lambda: False)
|
|
resp = self._smart_request(
|
|
resp = self._smart_request(
|
|
- "git-upload-pack", url, data=req_data.getvalue())
|
|
|
|
|
|
+ b"git-upload-pack", url, data=req_data.getvalue())
|
|
try:
|
|
try:
|
|
resp_proto = Protocol(resp.read, None)
|
|
resp_proto = Protocol(resp.read, None)
|
|
self._handle_upload_pack_tail(resp_proto, negotiated_capabilities,
|
|
self._handle_upload_pack_tail(resp_proto, negotiated_capabilities,
|