/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-07-22 13:10:44 UTC
  • mfrom: (0.200.588 trunk)
  • mto: (0.200.597 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20090722131044-r30g8w06xd8f40fl
merge trunk.

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,
20
19
    tag,
 
20
    trace,
21
21
    ui,
22
22
    urlutils,
23
23
    )
55
55
    mapping_registry,
56
56
    )
57
57
from bzrlib.plugins.git.repository import (
58
 
    GitRepositoryFormat,
59
58
    GitRepository,
60
59
    )
61
60
 
65
64
    )
66
65
from dulwich.pack import (
67
66
    Pack,
68
 
    PackData,
69
67
    )
70
68
import os
71
69
import tempfile
72
70
import urllib
73
71
import urlparse
74
72
 
75
 
try:
76
 
    from dulwich.pack import load_pack_index
77
 
except ImportError:
78
 
    from dulwich.pack import PackIndex as load_pack_index
 
73
from dulwich.pack import load_pack_index
79
74
 
80
75
 
81
76
# Don't run any tests on GitSmartTransport as it is not intended to be 
94
89
        (self._host, self._port) = urllib.splitnport(hostport, None)
95
90
        self._client = _client
96
91
 
 
92
    def external_url(self):
 
93
        return self.base
 
94
 
97
95
    def has(self, relpath):
98
96
        return False
99
97
 
100
 
    def _get_client(self):
 
98
    def _get_client(self, thin_packs):
101
99
        raise NotImplementedError(self._get_client)
102
100
 
103
101
    def _get_path(self):
107
105
        if progress is None:
108
106
            def progress(text):
109
107
                info("git: %s" % text)
110
 
        client = self._get_client()
 
108
        client = self._get_client(thin_packs=False)
111
109
        try:
112
110
            return client.fetch_pack(self._get_path(), determine_wants, 
113
111
                graph_walker, pack_data, progress)
115
113
            raise BzrError(e)
116
114
 
117
115
    def send_pack(self, get_changed_refs, generate_pack_contents):
118
 
        client = self._get_client()
 
116
        client = self._get_client(thin_packs=False)
119
117
        try:
120
118
            return client.send_pack(self._get_path(), get_changed_refs, 
121
119
                generate_pack_contents)
142
140
 
143
141
    _scheme = 'git'
144
142
 
145
 
    def _get_client(self):
 
143
    def _get_client(self, thin_packs):
146
144
        if self._client is not None:
147
145
            ret = self._client
148
146
            self._client = None
149
147
            return ret
150
 
        return git.client.TCPGitClient(self._host, self._port, thin_packs=False,
 
148
        return git.client.TCPGitClient(self._host, self._port, thin_packs=thin_packs,
151
149
            report_activity=self._report_activity)
152
150
 
153
151
 
160
158
            return self._path[3:]
161
159
        return self._path
162
160
 
163
 
    def _get_client(self):
 
161
    def _get_client(self, thin_packs):
164
162
        if self._client is not None:
165
163
            ret = self._client
166
164
            self._client = None
167
165
            return ret
168
166
        return git.client.SSHGitClient(self._host, self._port, self._username,
169
 
            thin_packs=False, report_activity=self._report_activity)
 
167
            thin_packs=thin_packs, report_activity=self._report_activity)
170
168
 
171
169
 
172
170
class RemoteGitDir(GitDir):
205
203
    @property
206
204
    def index(self):
207
205
        if self._idx is None:
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()
 
206
            if not os.path.exists(self._idx_path):
 
207
                pb = ui.ui_factory.nested_progress_bar()
 
208
                try:
 
209
                    def report_progress(cur, total):
 
210
                        pb.update("generating index", cur, total)
 
211
                    self.data.create_index(self._idx_path, self.resolve_ext_ref,
 
212
                        progress=report_progress)
 
213
                finally:
 
214
                    pb.finished()
216
215
            self._idx = load_pack_index(self._idx_path)
217
216
        return self._idx
218
217
 
243
242
        if self._refs is not None:
244
243
            return self._refs
245
244
        self._refs = self.bzrdir.root_transport.fetch_pack(lambda x: [], None, 
246
 
            lambda x: None, lambda x: mutter("git: %s" % x))
 
245
            lambda x: None, lambda x: trace.mutter("git: %s" % x))
247
246
        return self._refs
248
247
 
249
248
    def fetch_pack(self, determine_wants, graph_walker, pack_data, 
303
302
            return self._ref
304
303
        heads = self.repository.get_refs()
305
304
        if not self.name in heads:
306
 
            raise NoSuchRef(name)
 
305
            raise NoSuchRef(self.name)
307
306
        self._ref = heads[self.name]
308
307
        return self._ref
309
308