def _handle_receive_pack_tail(self, proto, capabilities, progress=None): """Handle the tail of a 'git-receive-pack' request. :param proto: Protocol object to read from :param capabilities: List of negotiated capabilities :param progress: Optional progress reporting function """ if "side-band-64k" in capabilities: if progress is None: progress = lambda x: None channel_callbacks = {2: progress} if 'report-status' in capabilities: channel_callbacks[1] = PktLineParser( self._report_status_parser.handle_packet).parse self._read_side_band64k_data(proto, channel_callbacks) else: if 'report-status' in capabilities: for pkt in proto.read_pkt_seq(): self._report_status_parser.handle_packet(pkt) if self._report_status_parser is not None: self._report_status_parser.check() # wait for EOF before returning data = proto.read() if data: raise SendPackError('Unexpected response %r' % data)
def test_small_fragments(self): pktlines = [] parser = PktLineParser(pktlines.append) parser.parse("00") parser.parse("05") parser.parse("z0000") self.assertEquals(pktlines, ["z", None]) self.assertEquals("", parser.get_tail())
def test_small_fragments(self): pktlines = [] parser = PktLineParser(pktlines.append) parser.parse(b"00") parser.parse(b"05") parser.parse(b"z0000") self.assertEqual(pktlines, [b"z", None]) self.assertEqual(b"", parser.get_tail())
def _handle_receive_pack_tail(self, proto, capabilities, progress=None): """Handle the tail of a 'git-receive-pack' request. :param proto: Protocol object to read from :param capabilities: List of negotiated capabilities :param progress: Optional progress reporting function """ if b"side-band-64k" in capabilities: if progress is None: progress = lambda x: None channel_callbacks = {2: progress} if CAPABILITY_REPORT_STATUS in capabilities: channel_callbacks[1] = PktLineParser( self._report_status_parser.handle_packet).parse self._read_side_band64k_data(proto, channel_callbacks) else: if CAPABILITY_REPORT_STATUS in capabilities: for pkt in proto.read_pkt_seq(): self._report_status_parser.handle_packet(pkt) if self._report_status_parser is not None: self._report_status_parser.check()
def test_multiple_packets(self): pktlines = [] parser = PktLineParser(pktlines.append) parser.parse(b"0005z0006aba") self.assertEqual(pktlines, [b"z", b"ab"]) self.assertEqual(b"a", parser.get_tail())
def test_none(self): pktlines = [] parser = PktLineParser(pktlines.append) parser.parse(b"0000") self.assertEqual(pktlines, [None]) self.assertEqual(b"", parser.get_tail())
def test_multiple_packets(self): pktlines = [] parser = PktLineParser(pktlines.append) parser.parse("0005z0006aba") self.assertEquals(pktlines, ["z", "ab"]) self.assertEquals("a", parser.get_tail())
def test_none(self): pktlines = [] parser = PktLineParser(pktlines.append) parser.parse("0000") self.assertEquals(pktlines, [None]) self.assertEquals("", parser.get_tail())