/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

Use transports in git-import.

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