~jelmer/dulwich/lp-pqm

« back to all changes in this revision

Viewing changes to dulwich/client.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-01 22:13:51 UTC
  • mfrom: (413.11.554)
  • Revision ID: jelmer@samba.org-20120201221351-b3n2p9zttzh62dwu
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
18
# MA  02110-1301, USA.
19
19
 
20
 
"""Client side support for the Git protocol."""
 
20
"""Client side support for the Git protocol.
 
21
 
 
22
The Dulwich client supports the following capabilities:
 
23
 
 
24
 * thin-pack
 
25
 * multi_ack_detailed
 
26
 * multi_ack
 
27
 * side-band-64k
 
28
 * ofs-delta
 
29
 * report-status
 
30
 * delete-refs
 
31
 
 
32
Known capabilities that are not supported:
 
33
 
 
34
 * shallow
 
35
 * no-progress
 
36
 * include-tag
 
37
"""
21
38
 
22
39
__docformat__ = 'restructuredText'
23
40
 
177
194
        :param determine_wants: Optional function to determine what refs
178
195
            to fetch
179
196
        :param progress: Optional progress function
180
 
        :return: remote refs
 
197
        :return: remote refs as dictionary
181
198
        """
182
199
        if determine_wants is None:
183
200
            determine_wants = target.object_store.determine_wants_all
189
206
            commit()
190
207
 
191
208
    def fetch_pack(self, path, determine_wants, graph_walker, pack_data,
192
 
                   progress):
 
209
                   progress=None):
193
210
        """Retrieve a pack from a git smart server.
194
211
 
195
212
        :param determine_wants: Callback that returns list of commits to fetch
286
303
        proto.write_pkt_line(None)
287
304
        return (have, want)
288
305
 
289
 
    def _handle_receive_pack_tail(self, proto, capabilities, progress):
 
306
    def _handle_receive_pack_tail(self, proto, capabilities, progress=None):
290
307
        """Handle the tail of a 'git-receive-pack' request.
291
308
 
292
309
        :param proto: Protocol object to read from
298
315
        else:
299
316
            report_status_parser = None
300
317
        if "side-band-64k" in capabilities:
 
318
            if progress is None:
 
319
                progress = lambda x: None
301
320
            channel_callbacks = { 2: progress }
302
321
            if 'report-status' in capabilities:
303
322
                channel_callbacks[1] = PktLineParser(
351
370
        proto.write_pkt_line('done\n')
352
371
 
353
372
    def _handle_upload_pack_tail(self, proto, capabilities, graph_walker,
354
 
                                 pack_data, progress, rbufsize=_RBUFSIZE):
 
373
                                 pack_data, progress=None, rbufsize=_RBUFSIZE):
355
374
        """Handle the tail of a 'git-upload-pack' request.
356
375
 
357
376
        :param proto: Protocol object to read from
371
390
                break
372
391
            pkt = proto.read_pkt_line()
373
392
        if "side-band-64k" in capabilities:
 
393
            if progress is None:
 
394
                # Just ignore progress data
 
395
                progress = lambda x: None
374
396
            self._read_side_band64k_data(proto, {1: pack_data, 2: progress})
375
397
            # wait for EOF before returning
376
398
            data = proto.read()
455
477
        except:
456
478
            proto.write_pkt_line(None)
457
479
            raise
 
480
        if wants is not None:
 
481
            wants = [cid for cid in wants if cid != ZERO_SHA]
458
482
        if not wants:
459
483
            proto.write_pkt_line(None)
460
484
            return refs
707
731
        return new_refs
708
732
 
709
733
    def fetch_pack(self, path, determine_wants, graph_walker, pack_data,
710
 
                   progress):
 
734
                   progress=None):
711
735
        """Retrieve a pack from a git smart server.
712
736
 
713
737
        :param determine_wants: Callback that returns list of commits to fetch
714
738
        :param graph_walker: Object with next() and ack().
715
739
        :param pack_data: Callback called for each bit of data in the pack
716
740
        :param progress: Callback for progress reports (strings)
 
741
        :return: Dictionary with the refs of the remote repository
717
742
        """
718
743
        url = self._get_url(path)
719
744
        refs, server_capabilities = self._discover_references(
720
745
            "git-upload-pack", url)
721
746
        negotiated_capabilities = list(server_capabilities)
722
747
        wants = determine_wants(refs)
 
748
        if wants is not None:
 
749
            wants = [cid for cid in wants if cid != ZERO_SHA]
723
750
        if not wants:
724
751
            return refs
725
752
        if self.dumb: