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

  • Committer: Martin Pool
  • Date: 2008-05-08 04:33:38 UTC
  • mfrom: (3414 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3415.
  • Revision ID: mbp@sourcefrog.net-20080508043338-ru3vflx8z641a76k
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
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
43
43
from bzrlib.smart import client, vfs
44
44
from bzrlib.symbol_versioning import (
45
45
    deprecated_method,
46
 
    zero_ninetyone,
47
46
    )
48
47
from bzrlib.revision import ensure_null, NULL_REVISION
49
48
from bzrlib.trace import mutter, note, warning
834
833
            # :- its because we're working with a deprecated server anyway, and
835
834
            # the user will almost certainly have seen a warning about the
836
835
            # server version already.
837
 
            return self.get_revision_graph()
 
836
            rg = self.get_revision_graph()
 
837
            # There is an api discrepency between get_parent_map and
 
838
            # get_revision_graph. Specifically, a "key:()" pair in
 
839
            # get_revision_graph just means a node has no parents. For
 
840
            # "get_parent_map" it means the node is a ghost. So fix up the
 
841
            # graph to correct this.
 
842
            #   https://bugs.launchpad.net/bzr/+bug/214894
 
843
            # There is one other "bug" which is that ghosts in
 
844
            # get_revision_graph() are not returned at all. But we won't worry
 
845
            # about that for now.
 
846
            for node_id, parent_ids in rg.iteritems():
 
847
                if parent_ids == ():
 
848
                    rg[node_id] = (NULL_REVISION,)
 
849
            rg[NULL_REVISION] = ()
 
850
            return rg
838
851
 
839
852
        keys = set(keys)
840
853
        if NULL_REVISION in keys:
870
883
        body = self._serialise_search_recipe(recipe)
871
884
        path = self.bzrdir._path_for_remote_call(self._client)
872
885
        for key in keys:
873
 
            if not isinstance(key, str):
874
 
                raise ValueError(key)
 
886
            if type(key) is not str:
 
887
                raise ValueError(
 
888
                    "key %r not a plain string" % (key,))
875
889
        verb = 'Repository.get_parent_map'
876
890
        args = (path,) + tuple(keys)
877
891
        try:
1154
1168
        self._dir_mode = None
1155
1169
        self._file_mode = None
1156
1170
 
1157
 
    def get(self, path):
1158
 
        """'get' a remote path as per the LockableFiles interface.
1159
 
 
1160
 
        :param path: the file to 'get'. If this is 'branch.conf', we do not
1161
 
             just retrieve a file, instead we ask the smart server to generate
1162
 
             a configuration for us - which is retrieved as an INI file.
1163
 
        """
1164
 
        if path == 'branch.conf':
1165
 
            path = self.bzrdir._path_for_remote_call(self._client)
1166
 
            response = self._client.call_expecting_body(
1167
 
                'Branch.get_config_file', path)
1168
 
            if response[0][0] != 'ok':
1169
 
                raise SmartProtocolError(
1170
 
                    'unexpected response code %s' % (response[0],))
1171
 
            return StringIO(response[1].read_body_bytes())
1172
 
        else:
1173
 
            # VFS fallback.
1174
 
            return LockableFiles.get(self, path)
1175
 
 
1176
1171
 
1177
1172
class RemoteBranchFormat(branch.BranchFormat):
1178
1173
 
1469
1464
        self._ensure_real()
1470
1465
        return self._real_branch.set_parent(url)
1471
1466
        
1472
 
    def get_config(self):
1473
 
        return RemoteBranchConfig(self)
1474
 
 
1475
1467
    def sprout(self, to_bzrdir, revision_id=None):
1476
1468
        # Like Branch.sprout, except that it sprouts a branch in the default
1477
1469
        # format, because RemoteBranches can't be created at arbitrary URLs.
1545
1537
            other, stop_revision=stop_revision, overwrite=overwrite)
1546
1538
 
1547
1539
 
1548
 
class RemoteBranchConfig(BranchConfig):
1549
 
 
1550
 
    def username(self):
1551
 
        self.branch._ensure_real()
1552
 
        return self.branch._real_branch.get_config().username()
1553
 
 
1554
 
    def _get_branch_data_config(self):
1555
 
        self.branch._ensure_real()
1556
 
        if self._branch_data_config is None:
1557
 
            self._branch_data_config = TreeConfig(self.branch._real_branch)
1558
 
        return self._branch_data_config
1559
 
 
1560
 
 
1561
1540
def _extract_tar(tar, to_dir):
1562
1541
    """Extract all the contents of a tarfile object.
1563
1542