/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/smart/repository.py

  • Committer: Martin Pool
  • Date: 2007-04-11 10:07:02 UTC
  • mto: (2420.2.2 bzr.http.auth)
  • mto: This revision was merged to the branch mainline in revision 2462.
  • Revision ID: mbp@sourcefrog.net-20070411100702-r12ixsycxcohqu4s
copy_content_into from Remote repositories by using temporary directories on both ends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
198
198
        repo_transport = repository.control_files._transport
199
199
        tmp_dirname, tmp_repo = self._copy_to_tempdir(repository)
200
200
        try:
201
 
            repo_dir = tmp_repo.control_files._transport.local_abspath('.')
202
 
            return self._tarfile_response(repo_dir, compression)
 
201
            controldir_name = tmp_dirname + '/.bzr'
 
202
            return self._tarfile_response(controldir_name, compression)
203
203
        finally:
204
204
            osutils.rmtree(tmp_dirname)
205
205
 
210
210
        from_repo.copy_content_into(tmp_repo)
211
211
        return tmp_dirname, tmp_repo
212
212
 
213
 
    def _tarfile_response(self, repo_dir, compression):
 
213
    def _tarfile_response(self, tmp_dirname, compression):
214
214
        temp = tempfile.NamedTemporaryFile()
215
215
        try:
216
 
            self._tarball_of_dir(repo_dir, compression, temp.name)
 
216
            self._tarball_of_dir(tmp_dirname, compression, temp.name)
217
217
            # all finished; write the tempfile out to the network
218
218
            temp.seek(0)
219
219
            return SmartServerResponse(('ok',), temp.read())
222
222
        finally:
223
223
            temp.close()
224
224
 
225
 
    def _tarball_of_dir(self, repo_dir, compression, tarfile_name):
 
225
    def _tarball_of_dir(self, dirname, compression, tarfile_name):
226
226
        tarball = tarfile.open(tarfile_name, mode='w:' + compression)
227
227
        try:
228
228
            # The tarball module only accepts ascii names, and (i guess)
229
229
            # packs them with their 8bit names.  We know all the files
230
230
            # within the repository have ASCII names so the should be safe
231
231
            # to pack in.
232
 
            repo_dir = repo_dir.encode(sys.getfilesystemencoding())
 
232
            dirname = dirname.encode(sys.getfilesystemencoding())
233
233
            # python's tarball module includes the whole path by default so
234
234
            # override it
235
 
            assert repo_dir.endswith('/repository'), \
236
 
                "unexpected repository path %r" % repo_dir
237
 
            tarball.add(repo_dir, 'repository') # recursive by default
 
235
            assert dirname.endswith('.bzr')
 
236
            tarball.add(dirname, '.bzr') # recursive by default
238
237
        finally:
239
238
            tarball.close()