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

More work on roundtrip push support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
from bzrlib import (
18
18
    config,
19
19
    debug,
 
20
    tag,
20
21
    trace,
21
22
    ui,
22
23
    urlutils,
26
27
    InvalidRevisionId,
27
28
    NoSuchFile,
28
29
    NoSuchRevision,
29
 
    NotBranchError,
30
30
    NotLocalUrl,
31
 
    UninitializableFormat,
32
31
    )
33
32
from bzrlib.transport import (
34
33
    Transport,
41
40
 
42
41
from bzrlib.plugins.git.branch import (
43
42
    GitBranch,
44
 
    GitTags,
45
 
    )
46
 
from bzrlib.plugins.git.dir import (
47
 
    GitControlDirFormat,
48
 
    GitDir,
49
 
    GitLockableFiles,
50
 
    GitLock,
51
43
    )
52
44
from bzrlib.plugins.git.errors import (
53
45
    GitSmartRemoteNotSupported,
54
46
    NoSuchRef,
55
47
    )
 
48
from bzrlib.plugins.git.dir import (
 
49
    GitDir,
 
50
    )
56
51
from bzrlib.plugins.git.mapping import (
57
52
    mapping_registry,
58
53
    )
209
204
        self._lockfiles = lockfiles
210
205
        self._mode_check_done = None
211
206
 
212
 
    @property
213
 
    def user_url(self):
214
 
        return self.control_url
215
 
 
216
207
    def _branch_name_to_ref(self, name, default=None):
217
208
        return branch_name_to_ref(name, default=default)
218
209
 
219
210
    def open_repository(self):
220
211
        return RemoteGitRepository(self, self._lockfiles)
221
212
 
222
 
    def open_branch(self, name=None, unsupported=False, ignore_fallbacks=False):
 
213
    def _open_branch(self, name=None, ignore_fallbacks=False, 
 
214
                    unsupported=False):
223
215
        repo = self.open_repository()
224
216
        refname = self._branch_name_to_ref(name)
225
217
        return RemoteGitBranch(self, repo, refname, self._lockfiles)
270
262
            os.remove(self._data_path)
271
263
 
272
264
 
273
 
class RemoteGitControlDirFormat(GitControlDirFormat):
274
 
    """The .git directory control format."""
275
 
 
276
 
    supports_workingtrees = False
277
 
 
278
 
    @classmethod
279
 
    def _known_formats(self):
280
 
        return set([RemoteGitControlDirFormat()])
281
 
 
282
 
    def open(self, transport, _found=None):
283
 
        """Open this directory.
284
 
 
285
 
        """
286
 
        # we dont grok readonly - git isn't integrated with transport.
287
 
        url = transport.base
288
 
        if url.startswith('readonly+'):
289
 
            url = url[len('readonly+'):]
290
 
        if (not url.startswith("git://") and not url.startswith("git+")):
291
 
            raise NotBranchError(transport.base)
292
 
        if not isinstance(transport, GitSmartTransport):
293
 
            raise NotBranchError(transport.base)
294
 
        lockfiles = GitLockableFiles(transport, GitLock())
295
 
        return RemoteGitDir(transport, lockfiles, self)
296
 
 
297
 
    def get_format_description(self):
298
 
        return "Remote Git Repository"
299
 
 
300
 
    def initialize_on_transport(self, transport):
301
 
        raise UninitializableFormat(self)
302
 
 
303
 
 
304
265
class RemoteGitRepository(GitRepository):
305
266
 
306
267
    def __init__(self, gitdir, lockfiles):
308
269
        self._refs = None
309
270
 
310
271
    @property
311
 
    def user_url(self):
312
 
        return self.control_url
313
 
 
314
 
    @property
315
272
    def inventories(self):
316
273
        raise GitSmartRemoteNotSupported()
317
274
 
365
322
        return mapping.revision_id_foreign_to_bzr(foreign_revid)
366
323
 
367
324
 
368
 
class RemoteGitTagDict(GitTags):
369
 
 
370
 
    def get_refs(self):
371
 
        return self.repository.get_refs()
372
 
 
373
 
    def _iter_tag_refs(self, refs):
374
 
        for k, (peeled, unpeeled) in extract_tags(refs).iteritems():
375
 
            yield (k, peeled, unpeeled,
376
 
                  self.branch.mapping.revision_id_foreign_to_bzr(peeled))
 
325
class RemoteGitTagDict(tag.BasicTags):
 
326
 
 
327
    def __init__(self, branch):
 
328
        self.branch = branch
 
329
        self.repository = branch.repository
 
330
 
 
331
    def get_tag_dict(self):
 
332
        tags = {}
 
333
        for k, v in extract_tags(self.repository.get_refs()).iteritems():
 
334
            tags[k] = self.branch.mapping.revision_id_foreign_to_bzr(v)
 
335
        return tags
377
336
 
378
337
    def set_tag(self, name, revid):
379
338
        # FIXME: Not supported yet, should do a push of a new ref
387
346
        super(RemoteGitBranch, self).__init__(bzrdir, repository, name,
388
347
                lockfiles)
389
348
 
390
 
    @property
391
 
    def user_url(self):
392
 
        return self.control_url
393
 
 
394
 
    @property
395
 
    def control_url(self):
396
 
        return self.base
397
 
 
398
349
    def revision_history(self):
399
350
        raise GitSmartRemoteNotSupported()
400
351