~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-06-21 05:22:37 UTC
  • mfrom: (2490.2.33 graphwalker)
  • Revision ID: pqm@pqm.ubuntu.com-20070621052237-2phm1z5dg4arrwnk
Avoid topological sorting in Repository.get_ancestry where possible

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Server-side repository related request implmentations."""
18
18
 
19
 
import os
20
19
import sys
21
20
import tempfile
22
21
import tarfile
214
213
    def _tarfile_response(self, tmp_dirname, compression):
215
214
        temp = tempfile.NamedTemporaryFile()
216
215
        try:
217
 
            self._tarball_of_dir(tmp_dirname, compression, temp.file)
 
216
            self._tarball_of_dir(tmp_dirname, compression, temp.name)
218
217
            # all finished; write the tempfile out to the network
219
218
            temp.seek(0)
220
219
            return SuccessfulSmartServerResponse(('ok',), temp.read())
223
222
        finally:
224
223
            temp.close()
225
224
 
226
 
    def _tarball_of_dir(self, dirname, compression, ofile):
227
 
        filename = os.path.basename(ofile.name)
228
 
        tarball = tarfile.open(fileobj=ofile, name=filename,
229
 
            mode='w|' + compression)
 
225
    def _tarball_of_dir(self, dirname, compression, tarfile_name):
 
226
        tarball = tarfile.open(tarfile_name, mode='w:' + compression)
230
227
        try:
231
228
            # The tarball module only accepts ascii names, and (i guess)
232
229
            # packs them with their 8bit names.  We know all the files