/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

Implement GitLock.peek().

Show diffs side-by-side

added added

removed removed

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