/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 git -> git fetching.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
    FulltextContentFactory,
65
65
    )
66
66
 
67
 
from bzrlib.plugins.git.converter import (
68
 
    BazaarObjectStore,
69
 
    )
70
67
from bzrlib.plugins.git.mapping import (
71
68
    DEFAULT_FILE_MODE,
72
69
    inventory_to_tree_and_blobs,
73
70
    text_to_blob,
74
71
    )
 
72
from bzrlib.plugins.git.object_store import (
 
73
    BazaarObjectStore,
 
74
    )
75
75
from bzrlib.plugins.git.remote import (
76
76
    RemoteGitRepository,
77
77
    )
373
373
    target_git_object_retriever._idmap.commit()
374
374
 
375
375
 
376
 
class InterGitNonGitRepository(InterRepository):
377
 
    """Base InterRepository that copies revisions from a Git into a non-Git 
378
 
    repository."""
 
376
class InterGitRepository(InterRepository):
379
377
 
380
378
    _matching_repo_format = GitRepositoryFormat()
381
379
 
392
390
        self.fetch_refs(revision_id=revision_id, pb=pb, find_ghosts=find_ghosts,
393
391
                mapping=mapping, fetch_spec=fetch_spec)
394
392
 
 
393
 
 
394
class InterGitNonGitRepository(InterGitRepository):
 
395
    """Base InterRepository that copies revisions from a Git into a non-Git 
 
396
    repository."""
 
397
 
395
398
    def fetch_refs(self, revision_id=None, pb=None, find_ghosts=False, 
396
399
              mapping=None, fetch_spec=None):
397
400
        if mapping is None:
498
501
                not isinstance(target, GitRepository))
499
502
 
500
503
 
501
 
class InterGitRepository(InterRepository):
 
504
class InterGitGitRepository(InterGitRepository):
502
505
    """InterRepository that copies between Git repositories."""
503
506
 
504
 
    _matching_repo_format = GitRepositoryFormat()
505
 
 
506
 
    @staticmethod
507
 
    def _get_repo_format_to_test():
508
 
        return None
509
 
 
510
 
    def copy_content(self, revision_id=None, pb=None):
511
 
        """See InterRepository.copy_content."""
512
 
        self.fetch(revision_id, pb, find_ghosts=False)
513
 
 
514
 
    def fetch(self, revision_id=None, pb=None, find_ghosts=False, 
515
 
              mapping=None, fetch_spec=None):
 
507
    def fetch_refs(self, revision_id=None, pb=None, find_ghosts=False, 
 
508
              mapping=None, fetch_spec=None, branches=None):
516
509
        if mapping is None:
517
510
            mapping = self.source.get_mapping()
518
511
        def progress(text):
522
515
            args = [mapping.revision_id_bzr_to_foreign(revision_id)[0]]
523
516
        elif fetch_spec is not None:
524
517
            args = [mapping.revision_id_bzr_to_foreign(revid)[0] for revid in fetch_spec.heads]
525
 
        if fetch_spec is None and revision_id is None:
 
518
        if branches is not None:
 
519
            determine_wants = lambda x: [x[y] for y in branches if not x[y] in r.object_store]
 
520
        elif fetch_spec is None and revision_id is None:
526
521
            determine_wants = r.object_store.determine_wants_all
527
522
        else:
528
523
            determine_wants = lambda x: [y for y in args if not y in r.object_store]
530
525
        graphwalker = SimpleFetchGraphWalker(r.heads().values(), r.get_parents)
531
526
        f, commit = r.object_store.add_thin_pack()
532
527
        try:
533
 
            self.source.fetch_pack(determine_wants, graphwalker, f.write, progress)
 
528
            refs = self.source.fetch_pack(determine_wants, graphwalker,
 
529
                                          f.write, progress)
534
530
            commit()
 
531
            return refs
535
532
        except:
536
533
            f.close()
537
534
            raise