/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

Fix dpush to remote locations.

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