~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: INADA Naoki
  • Date: 2011-05-05 09:15:34 UTC
  • mto: (5830.3.3 i18n-msgfmt)
  • mto: This revision was merged to the branch mainline in revision 5873.
  • Revision ID: songofacandy@gmail.com-20110505091534-7sv835xpofwrmpt4
Add update-pot command to Makefile and tools/bzrgettext script that
extracts help text from bzr commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    static_tuple,
33
33
    symbol_versioning,
34
34
    urlutils,
35
 
    vf_repository,
36
 
    )
 
35
)
37
36
from bzrlib.branch import BranchReferenceFormat, BranchWriteLockResult
38
37
from bzrlib.decorators import needs_read_lock, needs_write_lock, only_raises
39
38
from bzrlib.errors import (
44
43
from bzrlib.smart import client, vfs, repository as smart_repo
45
44
from bzrlib.smart.client import _SmartClient
46
45
from bzrlib.revision import NULL_REVISION
47
 
from bzrlib.repository import RepositoryWriteLockResult, _LazyListJoin
 
46
from bzrlib.repository import RepositoryWriteLockResult
48
47
from bzrlib.trace import mutter, note, warning
49
48
 
50
49
 
701
700
        return RemoteBzrDirConfig(self)
702
701
 
703
702
 
704
 
class RemoteRepositoryFormat(vf_repository.VersionedFileRepositoryFormat):
 
703
class RemoteRepositoryFormat(_mod_repository.RepositoryFormat):
705
704
    """Format for repositories accessed over a _SmartClient.
706
705
 
707
706
    Instances of this repository are represented by RemoteRepository
1080
1079
    def find_text_key_references(self):
1081
1080
        """Find the text key references within the repository.
1082
1081
 
 
1082
        :return: a dictionary mapping (file_id, revision_id) tuples to altered file-ids to an iterable of
 
1083
        revision_ids. Each altered file-ids has the exact revision_ids that
 
1084
        altered it listed explicitly.
1083
1085
        :return: A dictionary mapping text keys ((fileid, revision_id) tuples)
1084
1086
            to whether they were referred to by the inventory of the
1085
1087
            revision_id that they contain. The inventory texts from all present
1133
1135
        return RemoteStreamSource(self, to_format)
1134
1136
 
1135
1137
    @needs_read_lock
1136
 
    def get_file_graph(self):
1137
 
        return graph.Graph(self.texts)
1138
 
 
1139
 
    @needs_read_lock
1140
1138
    def has_revision(self, revision_id):
1141
1139
        """True if this repository has a copy of the revision."""
1142
1140
        # Copy of bzrlib.repository.Repository.has_revision
1605
1603
    @needs_read_lock
1606
1604
    def search_missing_revision_ids(self, other,
1607
1605
            revision_id=symbol_versioning.DEPRECATED_PARAMETER,
1608
 
            find_ghosts=True, revision_ids=None, if_present_ids=None,
1609
 
            limit=None):
 
1606
            find_ghosts=True, revision_ids=None, if_present_ids=None):
1610
1607
        """Return the revision ids that other has that this does not.
1611
1608
 
1612
1609
        These are returned in topological order.
1626
1623
        inter_repo = _mod_repository.InterRepository.get(other, self)
1627
1624
        return inter_repo.search_missing_revision_ids(
1628
1625
            find_ghosts=find_ghosts, revision_ids=revision_ids,
1629
 
            if_present_ids=if_present_ids, limit=limit)
 
1626
            if_present_ids=if_present_ids)
1630
1627
 
1631
1628
    def fetch(self, source, revision_id=None, find_ghosts=False,
1632
1629
            fetch_spec=None):
1660
1657
        self._real_repository.create_bundle(target, base, fileobj, format)
1661
1658
 
1662
1659
    @needs_read_lock
1663
 
    @symbol_versioning.deprecated_method(
1664
 
        symbol_versioning.deprecated_in((2, 4, 0)))
1665
1660
    def get_ancestry(self, revision_id, topo_sorted=True):
1666
1661
        self._ensure_real()
1667
1662
        return self._real_repository.get_ancestry(revision_id, topo_sorted)
1975
1970
    def supports_rich_root(self):
1976
1971
        return self._format.rich_root_data
1977
1972
 
1978
 
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4, 0)))
1979
1973
    def iter_reverse_revision_history(self, revision_id):
1980
1974
        self._ensure_real()
1981
1975
        return self._real_repository.iter_reverse_revision_history(revision_id)
2015
2009
        providers = [self._unstacked_provider]
2016
2010
        if other is not None:
2017
2011
            providers.insert(0, other)
2018
 
        return graph.StackedParentsProvider(_LazyListJoin(
2019
 
            providers, self._fallback_repositories))
 
2012
        providers.extend(r._make_parents_provider() for r in
 
2013
                         self._fallback_repositories)
 
2014
        return graph.StackedParentsProvider(providers)
2020
2015
 
2021
2016
    def _serialise_search_recipe(self, recipe):
2022
2017
        """Serialise a graph search recipe.
2046
2041
            raise errors.UnexpectedSmartServerResponse(response)
2047
2042
 
2048
2043
 
2049
 
class RemoteStreamSink(vf_repository.StreamSink):
 
2044
class RemoteStreamSink(_mod_repository.StreamSink):
2050
2045
 
2051
2046
    def _insert_real(self, stream, src_format, resume_tokens):
2052
2047
        self.target_repo._ensure_real()
2164
2159
                yield substream_kind, substream
2165
2160
 
2166
2161
 
2167
 
class RemoteStreamSource(vf_repository.StreamSource):
 
2162
class RemoteStreamSource(_mod_repository.StreamSource):
2168
2163
    """Stream data from a remote server."""
2169
2164
 
2170
2165
    def get_stream(self, search):
2855
2850
            missing_parent = parent_map[missing_parent]
2856
2851
        raise errors.RevisionNotPresent(missing_parent, self.repository)
2857
2852
 
2858
 
    def _read_last_revision_info(self):
 
2853
    def _last_revision_info(self):
2859
2854
        response = self._call('Branch.last_revision_info', self._remote_path())
2860
2855
        if response[0] != 'ok':
2861
2856
            raise SmartProtocolError('unexpected response code %s' % (response,))
2995
2990
            _override_hook_target=self, **kwargs)
2996
2991
 
2997
2992
    @needs_read_lock
2998
 
    def push(self, target, overwrite=False, stop_revision=None, lossy=False):
 
2993
    def push(self, target, overwrite=False, stop_revision=None):
2999
2994
        self._ensure_real()
3000
2995
        return self._real_branch.push(
3001
 
            target, overwrite=overwrite, stop_revision=stop_revision, lossy=lossy,
 
2996
            target, overwrite=overwrite, stop_revision=stop_revision,
3002
2997
            _override_hook_source_branch=self)
3003
2998
 
3004
2999
    def is_locked(self):
3103
3098
        """
3104
3099
        try:
3105
3100
            configobj = self._get_configobj()
3106
 
            section_obj = None
3107
3101
            if section is None:
3108
3102
                section_obj = configobj
3109
3103
            else:
3110
3104
                try:
3111
3105
                    section_obj = configobj[section]
3112
3106
                except KeyError:
3113
 
                    pass
3114
 
            if section_obj is None:
3115
 
                value = default
3116
 
            else:
3117
 
                value = section_obj.get(name, default)
 
3107
                    return default
 
3108
            return section_obj.get(name, default)
3118
3109
        except errors.UnknownSmartMethod:
3119
 
            value = self._vfs_get_option(name, section, default)
3120
 
        for hook in config.OldConfigHooks['get']:
3121
 
            hook(self, name, value)
3122
 
        return value
 
3110
            return self._vfs_get_option(name, section, default)
3123
3111
 
3124
3112
    def _response_to_configobj(self, response):
3125
3113
        if len(response[0]) and response[0][0] != 'ok':
3126
3114
            raise errors.UnexpectedSmartServerResponse(response)
3127
3115
        lines = response[1].read_body_bytes().splitlines()
3128
 
        conf = config.ConfigObj(lines, encoding='utf-8')
3129
 
        for hook in config.OldConfigHooks['load']:
3130
 
            hook(self)
3131
 
        return conf
 
3116
        return config.ConfigObj(lines, encoding='utf-8')
3132
3117
 
3133
3118
 
3134
3119
class RemoteBranchConfig(RemoteConfig):