/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

Pass repository object to versionedfiles.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    tag,
24
24
    )
25
25
from bzrlib.decorators import needs_read_lock
 
26
from bzrlib.trace import mutter
26
27
 
27
28
from bzrlib.plugins.git.foreign import ForeignBranch
28
 
from bzrlib.plugins.git.mapping import default_mapping
 
29
 
 
30
from dulwich.objects import (
 
31
        Commit,
 
32
        Tag,
 
33
        )
29
34
 
30
35
class GitTagDict(tag.BasicTags):
31
36
 
35
40
 
36
41
    def get_tag_dict(self):
37
42
        ret = {}
38
 
        for tag in self.repository._git.tags:
39
 
            ret[tag.name] = self.branch.mapping.revision_id_foreign_to_bzr(tag.ref)
 
43
        for k,v in self.repository._git.tags.iteritems():
 
44
            obj = self.repository._git.get_object(v)
 
45
            while isinstance(obj, Tag):
 
46
                v = obj.object[1]
 
47
                obj = self.repository._git.get_object(v)
 
48
            if not isinstance(obj, Commit):
 
49
                mutter("Tag %s points at object %r that is not a commit, ignoring", k, obj)
 
50
                continue
 
51
            ret[k] = self.branch.mapping.revision_id_foreign_to_bzr(v)
40
52
        return ret
41
53
 
42
54
    def set_tag(self, name, revid):
43
 
        raise NotImplementedError(self.set_tag)
 
55
        self.repository._git.tags[name] = revid
44
56
 
45
57
 
46
58
class GitBranchConfig(config.BranchConfig):
51
63
        # do not provide a BranchDataConfig
52
64
        self.option_sources = self.option_sources[0], self.option_sources[2]
53
65
 
54
 
    def set_user_option(self, name, value, local=False):
 
66
    def set_user_option(self, name, value, store=config.STORE_BRANCH, warn_masked=False):
55
67
        """Force local to True"""
56
 
        config.BranchConfig.set_user_option(self, name, value, local=True)
 
68
        config.BranchConfig.set_user_option(self, name, value, store=config.STORE_LOCATION, warn_masked=warn_masked)
57
69
 
58
70
 
59
71
class GitBranchFormat(branch.BranchFormat):
70
82
 
71
83
    def __init__(self, bzrdir, repository, name, head, lockfiles):
72
84
        self.repository = repository
73
 
        super(GitBranch, self).__init__(default_mapping)
 
85
        super(GitBranch, self).__init__(repository.get_mapping())
74
86
        self.control_files = lockfiles
75
87
        self.bzrdir = bzrdir
76
88
        self.name = name
89
101
        """See Branch.get_parent()."""
90
102
        return None
91
103
 
 
104
    def set_parent(self, url):
 
105
        pass
 
106
 
92
107
    def lock_read(self):
93
108
        self.control_files.lock_read()
94
109
 
129
144
    def set_push_location(self, location):
130
145
        """See Branch.set_push_location."""
131
146
        self.get_config().set_user_option('push_location', location,
132
 
                                          local=True)
 
147
                                          store=config.STORE_LOCATION)
133
148
 
134
149
    def supports_tags(self):
135
150
        return True