##// END OF EJS Templates
fixed tests, and archival method
marcink -
r2277:bb0309b4 beta
parent child Browse files
Show More
@@ -360,9 +360,9 b' class FilesController(BaseRepoController'
360 except (ImproperArchiveTypeError, KeyError):
360 except (ImproperArchiveTypeError, KeyError):
361 return _('Unknown archive type')
361 return _('Unknown archive type')
362
362
363 archive = tempfile.NamedTemporaryFile(mode='w+r+b')
363 archive = tempfile.NamedTemporaryFile(mode='w+r+b', delete=False)
364 cs.fill_archive(stream=archive, kind=fileformat, subrepos=subrepos)
364 cs.fill_archive(stream=archive, kind=fileformat, subrepos=subrepos)
365
365 archive.close()
366 response.content_type = content_type
366 response.content_type = content_type
367 response.content_disposition = 'attachment; filename=%s-%s%s' \
367 response.content_disposition = 'attachment; filename=%s-%s%s' \
368 % (repo_name, revision[:12], ext)
368 % (repo_name, revision[:12], ext)
@@ -373,9 +373,10 b' class FilesController(BaseRepoController'
373 data = tmpfile.read(16 * 1024)
373 data = tmpfile.read(16 * 1024)
374 if not data:
374 if not data:
375 tmpfile.close()
375 tmpfile.close()
376 os.unlink(tmpfile.name)
376 break
377 break
377 yield data
378 yield data
378 return get_chunked_archive(tmpfile=archive)
379 return get_chunked_archive(tmpfile=open(archive.name,'rb'))
379
380
380 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
381 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
381 'repository.admin')
382 'repository.admin')
@@ -260,9 +260,11 b' class MercurialChangeset(BaseChangeset):'
260 elif prefix.strip() == '':
260 elif prefix.strip() == '':
261 raise VCSError("Prefix cannot be empty")
261 raise VCSError("Prefix cannot be empty")
262
262
263 print stream.closed
263 archival.archive(self.repository._repo, stream, self.raw_id,
264 archival.archive(self.repository._repo, stream, self.raw_id,
264 kind, prefix=prefix, subrepos=subrepos)
265 kind, prefix=prefix, subrepos=subrepos)
265
266 print stream.closed
267
266 if stream.closed and hasattr(stream, 'name'):
268 if stream.closed and hasattr(stream, 'name'):
267 stream = open(stream.name, 'rb')
269 stream = open(stream.name, 'rb')
268 elif hasattr(stream, 'mode') and 'r' not in stream.mode:
270 elif hasattr(stream, 'mode') and 'r' not in stream.mode:
@@ -190,10 +190,11 b' class TestFilesController(TestController'
190 self.log_user()
190 self.log_user()
191
191
192 for arch_ext, info in ARCHIVE_SPECS.items():
192 for arch_ext, info in ARCHIVE_SPECS.items():
193 short = '27cd5cce30c9%s' % arch_ext
193 fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext
194 fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext
194 filename = '%s-%s' % (HG_REPO, fname)
195 filename = '%s-%s' % (HG_REPO, short)
195
196 response = self.app.get(url(controller='files',
196 response = self.app.get(url(controller='files', action='archivefile',
197 action='archivefile',
197 repo_name=HG_REPO,
198 repo_name=HG_REPO,
198 fname=fname))
199 fname=fname))
199
200
@@ -202,7 +203,8 b' class TestFilesController(TestController'
202 [('Pragma', 'no-cache'),
203 [('Pragma', 'no-cache'),
203 ('Cache-Control', 'no-cache'),
204 ('Cache-Control', 'no-cache'),
204 ('Content-Type', '%s; charset=utf-8' % info[0]),
205 ('Content-Type', '%s; charset=utf-8' % info[0]),
205 ('Content-Disposition', 'attachment; filename=%s' % filename),]
206 ('Content-Disposition', 'attachment; filename=%s' % filename),
207 ]
206 )
208 )
207
209
208 def test_archival_wrong_ext(self):
210 def test_archival_wrong_ext(self):
General Comments 0
You need to be logged in to leave comments. Login now