/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

  • Committer: Jelmer Vernooij
  • Date: 2009-09-10 13:13:15 UTC
  • mto: (0.200.602 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20090910131315-6890xg58pl2jseml
Allow serving remote URLs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import bzrlib
18
18
from bzrlib import (
19
 
    branch,
 
19
    config,
20
20
    tag,
 
21
    trace,
21
22
    ui,
22
23
    urlutils,
23
24
    )
55
56
    mapping_registry,
56
57
    )
57
58
from bzrlib.plugins.git.repository import (
58
 
    GitRepositoryFormat,
59
59
    GitRepository,
60
60
    )
61
61
 
65
65
    )
66
66
from dulwich.pack import (
67
67
    Pack,
68
 
    PackData,
69
68
    )
70
69
import os
71
70
import tempfile
72
71
import urllib
73
72
import urlparse
74
73
 
75
 
try:
76
 
    from dulwich.pack import load_pack_index
77
 
except ImportError:
78
 
    from dulwich.pack import PackIndex as load_pack_index
 
74
from dulwich.pack import load_pack_index
79
75
 
80
76
 
81
77
# Don't run any tests on GitSmartTransport as it is not intended to be 
100
96
    def has(self, relpath):
101
97
        return False
102
98
 
103
 
    def _get_client(self):
 
99
    def _get_client(self, thin_packs):
104
100
        raise NotImplementedError(self._get_client)
105
101
 
106
102
    def _get_path(self):
110
106
        if progress is None:
111
107
            def progress(text):
112
108
                info("git: %s" % text)
113
 
        client = self._get_client()
 
109
        client = self._get_client(thin_packs=False)
114
110
        try:
115
111
            return client.fetch_pack(self._get_path(), determine_wants, 
116
112
                graph_walker, pack_data, progress)
118
114
            raise BzrError(e)
119
115
 
120
116
    def send_pack(self, get_changed_refs, generate_pack_contents):
121
 
        client = self._get_client()
 
117
        client = self._get_client(thin_packs=False)
122
118
        try:
123
119
            return client.send_pack(self._get_path(), get_changed_refs, 
124
120
                generate_pack_contents)
145
141
 
146
142
    _scheme = 'git'
147
143
 
148
 
    def _get_client(self):
 
144
    def _get_client(self, thin_packs):
149
145
        if self._client is not None:
150
146
            ret = self._client
151
147
            self._client = None
152
148
            return ret
153
 
        return git.client.TCPGitClient(self._host, self._port, thin_packs=False,
 
149
        return git.client.TCPGitClient(self._host, self._port, thin_packs=thin_packs,
154
150
            report_activity=self._report_activity)
155
151
 
156
152
 
163
159
            return self._path[3:]
164
160
        return self._path
165
161
 
166
 
    def _get_client(self):
 
162
    def _get_client(self, thin_packs):
167
163
        if self._client is not None:
168
164
            ret = self._client
169
165
            self._client = None
170
166
            return ret
171
167
        return git.client.SSHGitClient(self._host, self._port, self._username,
172
 
            thin_packs=False, report_activity=self._report_activity)
 
168
            thin_packs=thin_packs, report_activity=self._report_activity)
173
169
 
174
170
 
175
171
class RemoteGitDir(GitDir):
208
204
    @property
209
205
    def index(self):
210
206
        if self._idx is None:
211
 
            pb = ui.ui_factory.nested_progress_bar()
212
 
            try:
213
 
                def report_progress(cur, total):
214
 
                    pb.update("generating index", cur, total)
215
 
                self.data.create_index(self._idx_path, self.resolve_ext_ref,
216
 
                    progress=report_progress)
217
 
            finally:
218
 
                pb.finished()
 
207
            if not os.path.exists(self._idx_path):
 
208
                pb = ui.ui_factory.nested_progress_bar()
 
209
                try:
 
210
                    def report_progress(cur, total):
 
211
                        pb.update("generating index", cur, total)
 
212
                    self.data.create_index(self._idx_path, self.resolve_ext_ref,
 
213
                        progress=report_progress)
 
214
                finally:
 
215
                    pb.finished()
219
216
            self._idx = load_pack_index(self._idx_path)
220
217
        return self._idx
221
218
 
246
243
        if self._refs is not None:
247
244
            return self._refs
248
245
        self._refs = self.bzrdir.root_transport.fetch_pack(lambda x: [], None, 
249
 
            lambda x: None, lambda x: mutter("git: %s" % x))
 
246
            lambda x: None, lambda x: trace.mutter("git: %s" % x))
250
247
        return self._refs
251
248
 
252
249
    def fetch_pack(self, determine_wants, graph_walker, pack_data, 
300
297
    def last_revision(self):
301
298
        return self.mapping.revision_id_foreign_to_bzr(self.head)
302
299
 
 
300
    def _get_config(self):
 
301
        class EmptyConfig(object):
 
302
 
 
303
            def _get_configobj(self):
 
304
                return config.ConfigObj()
 
305
 
 
306
        return EmptyConfig()
 
307
 
303
308
    @property
304
309
    def head(self):
305
310
        if self._ref is not None:
306
311
            return self._ref
307
312
        heads = self.repository.get_refs()
308
313
        if not self.name in heads:
309
 
            raise NoSuchRef(name)
 
314
            raise NoSuchRef(self.name)
310
315
        self._ref = heads[self.name]
311
316
        return self._ref
312
317