/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

Implement GitRevisionTree.get_file_sha1.

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
 
210
219
    def open_repository(self):
211
220
        return RemoteGitRepository(self, self._lockfiles)
212
221
 
213
 
    def _open_branch(self, name=None, ignore_fallbacks=False, 
214
 
                    unsupported=False):
 
222
    def open_branch(self, name=None, unsupported=False, ignore_fallbacks=False):
215
223
        repo = self.open_repository()
216
224
        refname = self._branch_name_to_ref(name)
217
225
        return RemoteGitBranch(self, repo, refname, self._lockfiles)
262
270
            os.remove(self._data_path)
263
271
 
264
272
 
 
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
 
265
304
class RemoteGitRepository(GitRepository):
266
305
 
267
306
    def __init__(self, gitdir, lockfiles):
269
308
        self._refs = None
270
309
 
271
310
    @property
 
311
    def user_url(self):
 
312
        return self.control_url
 
313
 
 
314
    @property
272
315
    def inventories(self):
273
316
        raise GitSmartRemoteNotSupported()
274
317
 
322
365
        return mapping.revision_id_foreign_to_bzr(foreign_revid)
323
366
 
324
367
 
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
 
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))
336
377
 
337
378
    def set_tag(self, name, revid):
338
379
        # FIXME: Not supported yet, should do a push of a new ref
346
387
        super(RemoteGitBranch, self).__init__(bzrdir, repository, name,
347
388
                lockfiles)
348
389
 
 
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
 
349
398
    def revision_history(self):
350
399
        raise GitSmartRemoteNotSupported()
351
400