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

Add convenience method for getting missing objects iterator.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
from bzrlib.decorators import (
36
36
    needs_read_lock,
37
37
    )
38
 
from bzrlib.revision import (
39
 
    NULL_REVISION,
40
 
    )
41
38
from bzrlib.trace import (
42
39
    is_quiet,
43
40
    mutter,
51
48
    NoSuchRef,
52
49
    )
53
50
from bzrlib.plugins.git.refs import (
 
51
    branch_name_to_ref,
54
52
    ref_to_branch_name,
55
53
    extract_tags,
56
54
    tag_name_to_ref,
60
58
 
61
59
 
62
60
class GitPullResult(branch.PullResult):
63
 
    """Result of a pull from a Git branch."""
64
61
 
65
62
    def _lookup_revno(self, revid):
66
63
        assert isinstance(revid, str), "was %r" % revid
111
108
        for name in extra:
112
109
            if name.startswith("refs/tags/"):
113
110
                del self.repository._git[name]
114
 
 
 
111
        
115
112
    def set_tag(self, name, revid):
116
113
        self.repository._git.refs[tag_name_to_ref(name)], _ = \
117
114
            self.branch.mapping.revision_id_bzr_to_foreign(revid)
254
251
            overwrite, stop_revision)
255
252
 
256
253
    def lookup_foreign_revision_id(self, foreign_revid):
257
 
        return self.repository.lookup_foreign_revision_id(foreign_revid,
 
254
        return self.repository.lookup_foreign_revision_id(foreign_revid, 
258
255
            self.mapping)
259
256
 
260
257
 
262
259
    """A local Git branch."""
263
260
 
264
261
    def __init__(self, bzrdir, repository, name, lockfiles, tagsdict=None):
265
 
        super(LocalGitBranch, self).__init__(bzrdir, repository, name,
 
262
        super(LocalGitBranch, self).__init__(bzrdir, repository, name, 
266
263
              lockfiles, tagsdict)
267
264
        refs = repository._git.get_refs()
268
265
        if not (name in refs.keys() or "HEAD" in refs.keys()):
282
279
            return tree
283
280
        else:
284
281
            return self._create_heavyweight_checkout(to_location, revision_id,
285
 
                hardlink)
 
282
            hardlink)
286
283
 
287
284
    def _create_heavyweight_checkout(self, to_location, revision_id=None,
288
285
                                     hardlink=False):
345
342
 
346
343
    def supports_tags(self):
347
344
        return True
348
 
 
 
345
    
349
346
 
350
347
class GitBranchPullResult(branch.PullResult):
351
348
 
392
389
 
393
390
    def _set_new_revno(self, revno):
394
391
        self._new_revno = revno
395
 
 
 
392
    
396
393
    new_revno = property(_get_new_revno, _set_new_revno)
397
394
 
398
395
 
623
620
        return result
624
621
 
625
622
 
626
 
class InterToGitBranch(branch.GenericInterBranch):
 
623
class InterToGitBranch(branch.InterBranch):
627
624
    """InterBranch implementation that pulls from Git into bzr."""
628
625
 
629
626
    def __init__(self, source, target):
633
630
 
634
631
    @staticmethod
635
632
    def _get_branch_formats_to_test():
636
 
        return []
 
633
        return None, None
637
634
 
638
635
    @classmethod
639
636
    def is_compatible(self, source, target):
646
643
    def _get_new_refs(self, stop_revision=None):
647
644
        if stop_revision is None:
648
645
            stop_revision = self.source.last_revision()
649
 
        assert type(stop_revision) is str
650
646
        main_ref = self.target.ref or "refs/heads/master"
651
 
        refs = { main_ref: (None, stop_revision) }
 
647
        refs = { main_ref: stop_revision }
652
648
        for name, revid in self.source.tags.get_tag_dict().iteritems():
653
649
            if self.source.repository.has_revision(revid):
654
 
                refs[tag_name_to_ref(name)] = (None, revid)
 
650
                refs[tag_name_to_ref(name)] = revid
655
651
        return refs, main_ref
656
652
 
657
653
    def pull(self, overwrite=False, stop_revision=None, local=False,
691
687
        return result
692
688
 
693
689
    def lossy_push(self, stop_revision=None):
 
690
        from dulwich.protocol import ZERO_SHA
694
691
        result = GitBranchPushResult()
695
692
        result.source_branch = self.source
696
693
        result.target_branch = self.target
702
699
            return refs
703
700
        result.revidmap, old_refs, new_refs = self.interrepo.dfetch_refs(
704
701
            update_refs)
705
 
        result.old_revid = old_refs.get(self.target.ref, (None, NULL_REVISION))[1]
706
 
        result.new_revid = new_refs[main_ref][1]
 
702
        result.old_revid = self.target.lookup_foreign_revision_id(
 
703
            old_refs.get(self.target.ref, ZERO_SHA))
 
704
        result.new_revid = self.target.lookup_foreign_revision_id(
 
705
            new_refs[main_ref])
707
706
        return result
708
707
 
709
708