Ticket #238 (closed enhancement: fixed)
Opened 8 years ago
Last modified 3 years ago
Support for downloading tarballs from the repository
| Reported by: | cathelijne@… | Owned by: | cboos |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.10 |
| Component: | version control/browser | Version: | 0.6 |
| Severity: | minor | Keywords: | objectstore tracdiff |
| Cc: | athomas | ||
| Release Notes: | |||
| API Changes: | |||
Description
It would be cool to be able to browse the repository and download a tarball of a branch or tag.
Attachments
Change History
comment:1 Changed 8 years ago by daniel
comment:2 Changed 8 years ago by daniel
- Milestone set to 0.8
- Priority changed from normal to lowest
comment:3 Changed 8 years ago by daniel
- Milestone changed from 0.8 to 0.9
- Summary changed from Support for extracting tarballs from the repository to Support for downloading tarballs from the repository
comment:4 Changed 7 years ago by cmlenz
#814 marked as duplicate of this ticket.
comment:5 Changed 7 years ago by cmlenz
- Keywords helpwanted added
This shouldn't be so hard... have a look at the zip file support in Changeset.py for an example of how to package up files in a ZIP file.
comment:6 Changed 7 years ago by cmlenz
#1504 has been marked as duplicate of this ticket (although it limits the request to files as opposed to whole directories). It also contains a patch for enabling this.
comment:7 Changed 7 years ago by cboos
Note that this feature would also solve #763.
comment:8 Changed 7 years ago by cboos
- Owner changed from jonas to cboos
- Status changed from new to assigned
This is implemented in the TracDiff branch.
comment:9 Changed 6 years ago by cboos
- Milestone changed from 0.9 to 1.0
- Priority changed from lowest to normal
- Severity changed from normal to minor
comment:10 Changed 6 years ago by cboos
This ticket depends on #2028. Go there for the patches against 0.9.x.
comment:11 Changed 6 years ago by cboos
mgood suggested that this feature could put some load on
the server. While that's certainly not an issue with
small repositories, that can be a problem for big repositories,
so it should be possible to disable this feature:
[browser] download_archive = false
However, a better solution might be to allow the download
of some selected paths and cache the corresponding .zip files:
[browser] restrict_download = tags/trac-0.8.1, tags/trac-0.8.4, tags/trac-0.9b1
Of course, the revision should be taken into account, which may
complicate matters (e.g. cache a maximum of 5 different revisions
for each specified path).
comment:12 Changed 6 years ago by cboos
- Keywords tracdiff added
comment:13 Changed 6 years ago by ttest
I don't know if it would be a good idea to restrict the downloadable directories in the configuration file, since than you would have information in there about the structure of your repository.
IMHO it would be better to put the information which directories are downloadable/not downloadable in the repo. itself. Properties would be perfect for this.
comment:14 Changed 6 years ago by cboos
- Milestone changed from 1.0 to 0.10
answering ttest: not every VersioningSystemBackend has
support for properties (e.g. Mercurial doesn't)
comment:15 Changed 6 years ago by anonymous
- Priority changed from normal to high
comment:16 Changed 6 years ago by anonymous
- Priority changed from high to normal
comment:17 Changed 6 years ago by cboos
Note that the feature is now available in trunk.
I leave this open until there's some consensus about
the form that should take the "control" of this feature.
What we have so far:
- usage of properties is ruled out because that would be specific to TracSubversion
- some possible TracIni settingss:
- enable_download for enabling or not that feature
- restrict_download using a glob pattern to define the paths where a download is possible. e.g.
- "*":: everywhere
- "tags/*":: only below the tags folder
- "":: nowhere
comment:18 Changed 6 years ago by cboos
Implementation of the previous idea (list of glob patterns)
Index: trac/versioncontrol/web_ui/browser.py
===================================================================
--- trac/versioncontrol/web_ui/browser.py (revision 3006)
+++ trac/versioncontrol/web_ui/browser.py (working copy)
@@ -17,6 +17,8 @@
import re
import urllib
+import os.path
+from fnmatch import fnmatchcase
from trac import util
from trac.util import sorted
@@ -154,7 +156,10 @@
req.hdf['browser.items'] = info
req.hdf['browser.changes'] = changes
- if node.path != '':
+ patterns = self.config.get('browser', 'downloadable_paths')
+ if node.path and patterns and \
+ filter(None, [fnmatchcase(node.path, p) for p in
+ patterns.split(os.path.pathsep)]):
zip_href = self.env.href.changeset(rev, node.path, old=rev,
old_path='/', # special case #238
format='zip')
Of course, the most difficult here is to find a sensible
configuration setting name and a sensible default:
- "*": all folders are downloadable
- "": none are downloadable
comment:19 Changed 6 years ago by athomas
- Cc athomas added
This would be incredibly useful for TracHacks!
comment:20 Changed 6 years ago by sid
This feature will probably be used most in root level directories (trunk, branches/0.x-stable, tags/...), not all over the place. In the case where it might be used in a broader fashion (e.g. TrackHacks?), it means there are probably a lot of smaller projects and less overhead to create new archives as needed.
I think the globbing is overkill.
How about:
[browser] enable_archive_download = true
comment:21 Changed 6 years ago by cboos
The problem is that there are no fixed rules for identifying
what is a root level directory...
E.g. you would like to make each release (/tags/release-x.y.z)
downloadable, but certainly not the whole /tags folder,
which might contain dozens of releases...
Other example, in Trac hacks, the glob pattern would be /*/*,
i.e. anything at the second level, like /authformplugin/0.9
but not /authformplugin itself.
IMHO, a global yes/no flag is useless... Sure you may want
to disable the feature completely, but when you want to have it,
you want to have some reasonable control over it, as examplified
above.
With the glob patterns, complete disabling is very easy, simply
leave the option empty, and if control is needed, I can't think
of a better compromise between simplicity and flexibility than
a list of glob patterns...
comment:22 Changed 6 years ago by athomas
I agree, globs seem like an excellent choice. I certainly wouldn't want people downloading the entire TracHacks repository.
comment:23 Changed 6 years ago by cboos
- Resolution set to fixed
- Status changed from assigned to closed
Implemented in r3117.
comment:24 Changed 6 years ago by cboos
- Keywords objectstore added; helpwanted removed
Note that in the future, it might be worth to use a cache
for the zip files, as they can be costly to create.
comment:25 Changed 6 years ago by athomas
I've updated to trunk on TracHacks and this is working beautifully, thanks Christian :)
A cache would also be quite useful.
comment:26 Changed 3 years ago by stepan@…
Is it possible in a similar way to create "real" tar balls (not .zip files) instead?



While presumable a cool feature, it'll possibly take up a lot of resources and bandwidth.
If done though, adding a "download directory as tar/zip-ball" feature to the Browser would suffice.