diff --git a/docs/changelog.rst b/docs/changelog.rst --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -3,7 +3,7 @@ Changelog ========= -1.1.0 (**2010-XX-XX**) +1.2.0 (**2010-12-18**) ---------------------- :status: in-progress @@ -12,6 +12,18 @@ 1.1.0 (**2010-XX-XX**) news ++++ +- implemented #91 added nicer looking archive urls + +fixes +++++ + + +1.1.0 (**2010-12-18**) +---------------------- + +news +++++ + - rewrite of internals for vcs >=0.1.10 - uses mercurial 1.7 with dotencode disabled for maintaining compatibility with older clients @@ -117,5 +129,4 @@ 1.0.0rc2 (**2010-10-11**) - Disabled dirsize in file browser, it's causing nasty bug when dir renames occure. After vcs is fixed it'll be put back again. -- templating/css rewrites, optimized css. - +- templating/css rewrites, optimized css. \ No newline at end of file diff --git a/rhodecode/config/routing.py b/rhodecode/config/routing.py --- a/rhodecode/config/routing.py +++ b/rhodecode/config/routing.py @@ -189,8 +189,8 @@ def make_map(config): map.connect('files_annotate_home', '/{repo_name:.*}/annotate/{revision}/{f_path:.*}', controller='files', action='annotate', revision='tip', f_path='', conditions=dict(function=check_repo)) - map.connect('files_archive_home', '/{repo_name:.*}/archive/{revision}/{fileformat}', - controller='files', action='archivefile', revision='tip', + map.connect('files_archive_home', '/{repo_name:.*}/archive/{fname}', + controller='files', action='archivefile', conditions=dict(function=check_repo)) map.connect('repo_settings_delete', '/{repo_name:.*}/settings', controller='settings', action="delete", diff --git a/rhodecode/controllers/files.py b/rhodecode/controllers/files.py --- a/rhodecode/controllers/files.py +++ b/rhodecode/controllers/files.py @@ -39,7 +39,7 @@ from rhodecode.lib.base import BaseContr from rhodecode.lib.utils import EmptyChangeset from rhodecode.model.scm import ScmModel -from vcs.exceptions import RepositoryError, ChangesetError +from vcs.exceptions import RepositoryError, ChangesetError, ChangesetDoesNotExistError from vcs.nodes import FileNode from vcs.utils import diffs as differ @@ -133,14 +133,32 @@ class FilesController(BaseController): return render('files/files_annotate.html') - def archivefile(self, repo_name, revision, fileformat): + def archivefile(self, repo_name, fname): + info = fname.split('.') + revision, fileformat = info[0], '.' + '.'.join(info[1:]) archive_specs = { '.tar.bz2': ('application/x-tar', 'tbz2'), '.tar.gz': ('application/x-tar', 'tgz'), '.zip': ('application/zip', 'zip'), } if not archive_specs.has_key(fileformat): - return 'Unknown archive type %s' % fileformat + return _('Unknown archive type %s') % fileformat + + repo = ScmModel().get_repo(repo_name) + + try: + repo.get_changeset(revision) + except ChangesetDoesNotExistError: + return _('Unknown revision %s') % revision + + archive = tempfile.TemporaryFile() + localrepo = repo.repo + fname = '%s-%s%s' % (repo_name, revision, fileformat) + archival.archive(localrepo, archive, revision, archive_specs[fileformat][1], + prefix='%s-%s' % (repo_name, revision)) + response.content_type = archive_specs[fileformat][0] + response.content_disposition = 'attachment; filename=%s' % fname + archive.seek(0) def read_in_chunks(file_object, chunk_size=1024 * 40): """Lazy function (generator) to read a file piece by piece. @@ -151,14 +169,6 @@ class FilesController(BaseController): break yield data - archive = tempfile.TemporaryFile() - repo = ScmModel().get_repo(repo_name).repo - fname = '%s-%s%s' % (repo_name, revision, fileformat) - archival.archive(repo, archive, revision, archive_specs[fileformat][1], - prefix='%s-%s' % (repo_name, revision)) - response.content_type = archive_specs[fileformat][0] - response.content_disposition = 'attachment; filename=%s' % fname - archive.seek(0) return read_in_chunks(archive) def diff(self, repo_name, f_path): diff --git a/rhodecode/templates/summary/summary.html b/rhodecode/templates/summary/summary.html --- a/rhodecode/templates/summary/summary.html +++ b/rhodecode/templates/summary/summary.html @@ -223,7 +223,7 @@ %endif ${h.link_to(c.repo_info.name+'.'+archive['type'], h.url('files_archive_home',repo_name=c.repo_info.name, - revision='tip',fileformat=archive['extension']),class_="archive_icon")} + fname='tip'+archive['extension']),class_="archive_icon")} %endfor diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -5,13 +5,13 @@ from rhodecode import get_version requirements = [ "Pylons==1.0.0", - "SQLAlchemy==0.6.5", + "SQLAlchemy>=0.6.5", "Mako==0.3.6", - "vcs==0.1.10", - "pygments==1.3.1", - "mercurial==1.7.2", - "whoosh==1.3.4", - "celery==2.1.4", + "vcs=>0.1.10", + "pygments>=1.3.1", + "mercurial>=1.7.2", + "whoosh>=1.3.4", + "celery>=2.1.4", "py-bcrypt", "babel", ]