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

Basic support for opening working trees.

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
27
from bzrlib.plugins.git import ids
27
28
 
 
29
class GitTagDict(tag.BasicTags):
 
30
 
 
31
    def __init__(self, branch):
 
32
        self.branch = branch
 
33
        self.repository = branch.repository
 
34
 
 
35
    def get_tag_dict(self):
 
36
        ret = {}
 
37
        for tag in self.repository._git.tags:
 
38
            ret[tag.name] = ids.convert_revision_id_git_to_bzr(tag.commit.id)
 
39
        return ret
 
40
 
 
41
    def set_tag(self, name, revid):
 
42
        raise NotImplementedError(self.set_tag)
 
43
 
28
44
 
29
45
class GitBranchConfig(config.BranchConfig):
30
46
    """BranchConfig that uses locations.conf in place of branch.conf"""
44
60
    def get_format_description(self):
45
61
        return 'Git Branch'
46
62
 
 
63
    def supports_tags(self):
 
64
        return True
 
65
 
47
66
 
48
67
class GitBranch(branch.Branch):
49
68
    """An adapter to git repositories for bzr Branch objects."""
50
69
 
51
70
    def __init__(self, bzrdir, repository, head, base, lockfiles):
 
71
        self.repository = repository
52
72
        super(GitBranch, self).__init__()
53
73
        self.control_files = lockfiles
54
74
        self.bzrdir = bzrdir
55
 
        self.repository = repository
56
75
        self.head = head
57
76
        self.base = base
58
77
        self._format = GitBranchFormat()
67
86
            return revision.NULL_REVISION
68
87
        return ids.convert_revision_id_git_to_bzr(self.head)
69
88
 
 
89
    def _make_tags(self):
 
90
        return GitTagDict(self)
 
91
 
70
92
    def get_parent(self):
71
93
        """See Branch.get_parent()."""
72
94
        return None
118
140
                                          local=True)
119
141
 
120
142
    def supports_tags(self):
121
 
        return False
 
143
        return True