~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Andrew Bennetts
  • Date: 2008-05-07 22:47:56 UTC
  • mfrom: (3412 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3414.
  • Revision ID: andrew.bennetts@canonical.com-20080507224756-upxgmud0bdo4ysuf
Merge from bzr.dev.

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
40
40
from bzrlib.smart import client, vfs
41
41
from bzrlib.symbol_versioning import (
42
42
    deprecated_method,
43
 
    zero_ninetyone,
44
43
    )
45
44
from bzrlib.revision import ensure_null, NULL_REVISION
46
45
from bzrlib.trace import mutter, note, warning
823
822
            # :- its because we're working with a deprecated server anyway, and
824
823
            # the user will almost certainly have seen a warning about the
825
824
            # server version already.
826
 
            return self.get_revision_graph()
 
825
            rg = self.get_revision_graph()
 
826
            # There is an api discrepency between get_parent_map and
 
827
            # get_revision_graph. Specifically, a "key:()" pair in
 
828
            # get_revision_graph just means a node has no parents. For
 
829
            # "get_parent_map" it means the node is a ghost. So fix up the
 
830
            # graph to correct this.
 
831
            #   https://bugs.launchpad.net/bzr/+bug/214894
 
832
            # There is one other "bug" which is that ghosts in
 
833
            # get_revision_graph() are not returned at all. But we won't worry
 
834
            # about that for now.
 
835
            for node_id, parent_ids in rg.iteritems():
 
836
                if parent_ids == ():
 
837
                    rg[node_id] = (NULL_REVISION,)
 
838
            rg[NULL_REVISION] = ()
 
839
            return rg
827
840
 
828
841
        keys = set(keys)
829
842
        if NULL_REVISION in keys:
1144
1157
        self._dir_mode = None
1145
1158
        self._file_mode = None
1146
1159
 
1147
 
    def get(self, path):
1148
 
        """'get' a remote path as per the LockableFiles interface.
1149
 
 
1150
 
        :param path: the file to 'get'. If this is 'branch.conf', we do not
1151
 
             just retrieve a file, instead we ask the smart server to generate
1152
 
             a configuration for us - which is retrieved as an INI file.
1153
 
        """
1154
 
        if path == 'branch.conf':
1155
 
            path = self.bzrdir._path_for_remote_call(self._client)
1156
 
            response = self._client.call_expecting_body(
1157
 
                'Branch.get_config_file', path)
1158
 
            assert response[0][0] == 'ok', \
1159
 
                'unexpected response code %s' % (response[0],)
1160
 
            return StringIO(response[1].read_body_bytes())
1161
 
        else:
1162
 
            # VFS fallback.
1163
 
            return LockableFiles.get(self, path)
1164
 
 
1165
1160
 
1166
1161
class RemoteBranchFormat(branch.BranchFormat):
1167
1162
 
1456
1451
        self._ensure_real()
1457
1452
        return self._real_branch.set_parent(url)
1458
1453
        
1459
 
    def get_config(self):
1460
 
        return RemoteBranchConfig(self)
1461
 
 
1462
1454
    def sprout(self, to_bzrdir, revision_id=None):
1463
1455
        # Like Branch.sprout, except that it sprouts a branch in the default
1464
1456
        # format, because RemoteBranches can't be created at arbitrary URLs.
1533
1525
            other, stop_revision=stop_revision, overwrite=overwrite)
1534
1526
 
1535
1527
 
1536
 
class RemoteBranchConfig(BranchConfig):
1537
 
 
1538
 
    def username(self):
1539
 
        self.branch._ensure_real()
1540
 
        return self.branch._real_branch.get_config().username()
1541
 
 
1542
 
    def _get_branch_data_config(self):
1543
 
        self.branch._ensure_real()
1544
 
        if self._branch_data_config is None:
1545
 
            self._branch_data_config = TreeConfig(self.branch._real_branch)
1546
 
        return self._branch_data_config
1547
 
 
1548
 
 
1549
1528
def _extract_tar(tar, to_dir):
1550
1529
    """Extract all the contents of a tarfile object.
1551
1530