/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:
1
 
# Copyright (C) 2007-2009 Jelmer Vernooij <jelmer@samba.org>
 
1
# Copyright (C) 2007-2010 Jelmer Vernooij <jelmer@samba.org>
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
182
182
            ret = self._client
183
183
            self._client = None
184
184
            return ret
185
 
        return git.client.SSHGitClient(self._host, self._port, self._username,
 
185
        location_config = config.LocationConfig(self.base)
 
186
        client = git.client.SSHGitClient(self._host, self._port, self._username,
186
187
            thin_packs=thin_packs, report_activity=self._report_activity)
 
188
        # Set up alternate pack program paths
 
189
        upload_pack = location_config.get_user_option('git_upload_pack')
 
190
        if upload_pack:
 
191
            client.alternative_paths["upload-pack"] = upload_pack
 
192
        receive_pack = location_config.get_user_option('git_receive_pack')
 
193
        if receive_pack:
 
194
            client.alternative_paths["receive-pack"] = receive_pack
 
195
        return client
187
196
 
188
197
 
189
198
class RemoteGitDir(GitDir):
195
204
        self._lockfiles = lockfiles
196
205
        self._mode_check_done = None
197
206
 
198
 
    def _branch_name_to_ref(self, name):
199
 
        return branch_name_to_ref(name, default="refs/heads/master")
 
207
    def _branch_name_to_ref(self, name, default=None):
 
208
        return branch_name_to_ref(name, default=default)
200
209
 
201
210
    def open_repository(self):
202
211
        return RemoteGitRepository(self, self._lockfiles)
303
312
        except InvalidRevisionId:
304
313
            raise NoSuchRevision(self, bzr_revid)
305
314
 
 
315
    def lookup_foreign_revision_id(self, foreign_revid, mapping=None):
 
316
        """Lookup a revision id.
 
317
 
 
318
        """
 
319
        if mapping is None:
 
320
            mapping = self.get_mapping()
 
321
        # Not really an easy way to parse foreign revids here..
 
322
        return mapping.revision_id_foreign_to_bzr(foreign_revid)
 
323
 
306
324
 
307
325
class RemoteGitTagDict(tag.BasicTags):
308
326
 
324
342
class RemoteGitBranch(GitBranch):
325
343
 
326
344
    def __init__(self, bzrdir, repository, name, lockfiles):
327
 
        self._ref = None
 
345
        self._sha = None
328
346
        super(RemoteGitBranch, self).__init__(bzrdir, repository, name,
329
347
                lockfiles)
330
348
 
332
350
        raise GitSmartRemoteNotSupported()
333
351
 
334
352
    def last_revision(self):
335
 
        return self.mapping.revision_id_foreign_to_bzr(self.head)
 
353
        return self.lookup_foreign_revision_id(self.head)
336
354
 
337
355
    def _get_config(self):
338
356
        class EmptyConfig(object):
344
362
 
345
363
    @property
346
364
    def head(self):
347
 
        if self._ref is not None:
348
 
            return self._ref
 
365
        if self._sha is not None:
 
366
            return self._sha
349
367
        heads = self.repository.get_refs()
350
 
        if self.name in heads:
351
 
            self._ref = heads[self.name]
352
 
        elif ("refs/heads/" + self.name) in heads:
353
 
            self._ref = heads["refs/heads/" + self.name]
 
368
        name = self.bzrdir._branch_name_to_ref(self.name, "HEAD")
 
369
        if name in heads:
 
370
            self._sha = heads[name]
354
371
        else:
355
372
            raise NoSuchRef(self.name)
356
 
        return self._ref
 
373
        return self._sha
357
374
 
358
375
    def _synchronize_history(self, destination, revision_id):
359
376
        """See Branch._synchronize_history()."""