/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:
20
20
    branch,
21
21
    config,
22
22
    revision,
 
23
    tag,
23
24
    )
24
25
from bzrlib.decorators import needs_read_lock
25
26
 
26
 
from bzrlib.plugins.git import ids
 
27
from bzrlib.plugins.git.foreign import ForeignBranch
 
28
from bzrlib.plugins.git.mapping import default_mapping
 
29
 
 
30
class GitTagDict(tag.BasicTags):
 
31
 
 
32
    def __init__(self, branch):
 
33
        self.branch = branch
 
34
        self.repository = branch.repository
 
35
 
 
36
    def get_tag_dict(self):
 
37
        ret = {}
 
38
        for tag in self.repository._git.tags:
 
39
            ret[tag.name] = self.branch.mapping.revision_id_foreign_to_bzr(tag.ref)
 
40
        return ret
 
41
 
 
42
    def set_tag(self, name, revid):
 
43
        raise NotImplementedError(self.set_tag)
27
44
 
28
45
 
29
46
class GitBranchConfig(config.BranchConfig):
44
61
    def get_format_description(self):
45
62
        return 'Git Branch'
46
63
 
47
 
 
48
 
class GitBranch(branch.Branch):
 
64
    def supports_tags(self):
 
65
        return True
 
66
 
 
67
 
 
68
class GitBranch(ForeignBranch):
49
69
    """An adapter to git repositories for bzr Branch objects."""
50
70
 
51
71
    def __init__(self, bzrdir, repository, head, base, lockfiles):
52
 
        super(GitBranch, self).__init__()
 
72
        self.repository = repository
 
73
        super(GitBranch, self).__init__(default_mapping)
53
74
        self.control_files = lockfiles
54
75
        self.bzrdir = bzrdir
55
 
        self.repository = repository
56
76
        self.head = head
57
77
        self.base = base
58
78
        self._format = GitBranchFormat()
65
85
        # perhaps should escape this ?
66
86
        if self.head is None:
67
87
            return revision.NULL_REVISION
68
 
        return ids.convert_revision_id_git_to_bzr(self.head)
 
88
        return self.mapping.revision_id_foreign_to_bzr(self.head)
 
89
 
 
90
    def _make_tags(self):
 
91
        return GitTagDict(self)
69
92
 
70
93
    def get_parent(self):
71
94
        """See Branch.get_parent()."""
87
110
            skip += max_count
88
111
            for cm in cms:
89
112
                if cm.id == nextid:
90
 
                    ret.append(ids.convert_revision_id_git_to_bzr(cm.id))
 
113
                    ret.append(self.mapping.revision_id_foreign_to_bzr(cm.id))
91
114
                    if cm.parents == []:
92
115
                        nextid = None
93
116
                    else:
118
141
                                          local=True)
119
142
 
120
143
    def supports_tags(self):
121
 
        return False
 
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