/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

Merge new dulwich.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    )
25
25
from bzrlib.decorators import needs_read_lock
26
26
 
27
 
from bzrlib.plugins.git import ids
 
27
from bzrlib.plugins.git.foreign import ForeignBranch
 
28
from bzrlib.plugins.git.mapping import default_mapping
28
29
 
29
30
class GitTagDict(tag.BasicTags):
30
31
 
35
36
    def get_tag_dict(self):
36
37
        ret = {}
37
38
        for tag in self.repository._git.tags:
38
 
            ret[tag.name] = ids.convert_revision_id_git_to_bzr(tag.commit.id)
 
39
            ret[tag.name] = self.branch.mapping.revision_id_foreign_to_bzr(tag.ref)
39
40
        return ret
40
41
 
41
42
    def set_tag(self, name, revid):
64
65
        return True
65
66
 
66
67
 
67
 
class GitBranch(branch.Branch):
 
68
class GitBranch(ForeignBranch):
68
69
    """An adapter to git repositories for bzr Branch objects."""
69
70
 
70
71
    def __init__(self, bzrdir, repository, head, base, lockfiles):
71
72
        self.repository = repository
72
 
        super(GitBranch, self).__init__()
 
73
        super(GitBranch, self).__init__(default_mapping)
73
74
        self.control_files = lockfiles
74
75
        self.bzrdir = bzrdir
75
76
        self.head = head
84
85
        # perhaps should escape this ?
85
86
        if self.head is None:
86
87
            return revision.NULL_REVISION
87
 
        return ids.convert_revision_id_git_to_bzr(self.head)
 
88
        return self.mapping.revision_id_foreign_to_bzr(self.head)
88
89
 
89
90
    def _make_tags(self):
90
91
        return GitTagDict(self)
109
110
            skip += max_count
110
111
            for cm in cms:
111
112
                if cm.id == nextid:
112
 
                    ret.append(ids.convert_revision_id_git_to_bzr(cm.id))
 
113
                    ret.append(self.mapping.revision_id_foreign_to_bzr(cm.id))
113
114
                    if cm.parents == []:
114
115
                        nextid = None
115
116
                    else:
141
142
 
142
143
    def supports_tags(self):
143
144
        return True
 
145
 
 
146
    def sprout(self, to_bzrdir, revision_id=None):
 
147
        """See Branch.sprout()."""
 
148
        result = to_bzrdir.create_branch()
 
149
        self.copy_content_into(result, revision_id=revision_id)
 
150
        result.set_parent(self.bzrdir.root_transport.base)
 
151
        return result
 
152