/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

  • Committer: Jelmer Vernooij
  • Date: 2008-12-25 01:28:00 UTC
  • mto: (0.200.144 dulwich)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20081225012800-96iswmhsbn3wlyz6
Update copyright years.

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()."""
77
100
    def _gen_revision_history(self):
78
101
        if self.head is None:
79
102
            return []
80
 
        skip = 0
81
 
        cms = None
82
 
        ret = []
83
 
        max_count = 1000
84
 
        nextid = self.head
85
 
        while cms != []:
86
 
            cms = self.repository._git.commits(self.head, max_count=max_count, skip=skip)
87
 
            skip += max_count
88
 
            for cm in cms:
89
 
                if cm.id == nextid:
90
 
                    ret.append(ids.convert_revision_id_git_to_bzr(cm.id))
91
 
                    if cm.parents == []:
92
 
                        nextid = None
93
 
                    else:
94
 
                        nextid = cm.parents[0].id
 
103
        ret = list(self.repository.iter_reverse_revision_history(self.last_revision()))
95
104
        ret.reverse()
96
105
        return ret
97
106
 
118
127
                                          local=True)
119
128
 
120
129
    def supports_tags(self):
121
 
        return False
 
130
        return True
 
131
 
 
132
    def sprout(self, to_bzrdir, revision_id=None):
 
133
        """See Branch.sprout()."""
 
134
        result = to_bzrdir.create_branch()
 
135
        self.copy_content_into(result, revision_id=revision_id)
 
136
        result.set_parent(self.bzrdir.root_transport.base)
 
137
        return result
 
138