/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 fetch.py

Fix fetching between git repositories.

Show diffs side-by-side

added added

removed removed

Lines of Context:
526
526
class InterGitGitRepository(InterGitRepository):
527
527
    """InterRepository that copies between Git repositories."""
528
528
 
 
529
    def fetch_objects(self, determine_wants, mapping, pb=None):
 
530
        def progress(text):
 
531
            trace.note("git: %s", text)
 
532
        graphwalker = self.target._git.get_graph_walker()
 
533
        if isinstance(self.source, LocalGitRepository) and isinstance(self.target, LocalGitRepository):
 
534
            return self.source._git.fetch(self.target._git, determine_wants, 
 
535
                progress)
 
536
        elif isinstance(self.source, LocalGitRepository) and isinstance(self.target, RemoteGitRepository):
 
537
            raise NotImplementedError
 
538
        elif isinstance(self.source, RemoteGitRepository) and isinstance(self.target, LocalGitRepository):
 
539
            f, commit = self.target._git.object_store.add_thin_pack()
 
540
            try:
 
541
                refs = self.source._git.fetch_pack(determine_wants, graphwalker,
 
542
                                                   f.write, progress)
 
543
                commit()
 
544
                return refs
 
545
            except:
 
546
                f.close()
 
547
                raise
 
548
        else:
 
549
            raise AssertionError
 
550
 
529
551
    def fetch_refs(self, revision_id=None, pb=None, find_ghosts=False, 
530
552
              mapping=None, fetch_spec=None, branches=None):
531
553
        if mapping is None:
532
554
            mapping = self.source.get_mapping()
533
 
        def progress(text):
534
 
            trace.info("git: %s", text)
535
555
        r = self.target._git
536
556
        if revision_id is not None:
537
557
            args = [mapping.revision_id_bzr_to_foreign(revision_id)[0]]
543
563
            determine_wants = r.object_store.determine_wants_all
544
564
        else:
545
565
            determine_wants = lambda x: [y for y in args if not y in r.object_store]
 
566
        return self.fetch_objects(determine_wants, mapping)
546
567
 
547
 
        graphwalker = r.get_graph_walker()
548
 
        f, commit = r.object_store.add_thin_pack()
549
 
        try:
550
 
            refs = self.source.fetch_pack(determine_wants, graphwalker,
551
 
                                          f.write, progress)
552
 
            commit()
553
 
            return refs
554
 
        except:
555
 
            f.close()
556
 
            raise
557
568
 
558
569
    @staticmethod
559
570
    def is_compatible(source, target):