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

Supply a BranchConfig instead of a Transport

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import stgit
25
25
import stgit.git as git
26
26
 
27
 
from bzrlib import urlutils
 
27
from bzrlib import config, urlutils
28
28
from bzrlib.decorators import *
29
29
import bzrlib.branch
30
30
import bzrlib.bzrdir
33
33
from bzrlib.revision import Revision
34
34
 
35
35
 
36
 
class GitTransport(object):
37
 
 
38
 
    def __init__(self):
39
 
        self.base = object()
40
 
 
41
 
    def get(self, relpath):
42
 
        assert relpath == 'branch.conf'
43
 
        return StringIO()
 
36
class GitBranchConfig(config.BranchConfig):
 
37
    """BranchConfig that uses locations.conf in place of branch.conf""" 
 
38
 
 
39
    def __init__(self, branch):
 
40
        config.BranchConfig.__init__(self, branch)
 
41
        # do not provide a BranchDataConfig
 
42
        self.option_sources = self.option_sources[0], self.option_sources[2]
 
43
 
 
44
    def set_user_option(self, name, value, local=False):
 
45
        """Force local to True"""
 
46
        config.BranchConfig.set_user_option(self, name, value, local=True)
44
47
 
45
48
 
46
49
def gitrevid_from_bzr(revision_id):
72
75
        self._transaction = None
73
76
        self._lock_mode = None
74
77
        self._lock_count = 0
75
 
        self._transport = GitTransport() 
76
78
 
77
79
 
78
80
class GitDir(bzrlib.bzrdir.BzrDir):
172
174
        # perhaps should escape this ?
173
175
        return bzrrevid_from_git(git.get_head())
174
176
 
 
177
    @needs_read_lock
175
178
    def revision_history(self):
176
179
        history = [self.last_revision()]
177
180
        while True:
181
184
            history.append(revision.parent_ids[0])
182
185
        return list(reversed(history))
183
186
 
 
187
    def get_config(self):
 
188
        return GitBranchConfig(self)
 
189
 
184
190
    def lock_read(self):
185
191
        self.control_files.lock_read()
186
192
 
187
193
    def unlock(self):
188
194
        self.control_files.unlock()
189
195
 
 
196
    def get_push_location(self):
 
197
        """See Branch.get_push_location."""
 
198
        push_loc = self.get_config().get_user_option('push_location')
 
199
        return push_loc
 
200
 
 
201
    def set_push_location(self, location):
 
202
        """See Branch.set_push_location."""
 
203
        self.get_config().set_user_option('push_location', location, 
 
204
                                          local=True)
 
205
 
190
206
 
191
207
class GitRepository(bzrlib.repository.Repository):
192
208
    """An adapter to git repositories for bzr."""