Mercurial > public > mercurial-scm > hg-stable
diff tests/test-archive.t @ 18771:bb38f4f78104
hgweb: teach archive how to download a specific directory or file
The archive web command now takes into account the "file" request entry, if one
is provided.
The provided "file" is processed as a "path" corresponding to a directory or
file that will be downloaded.
With this change hgweb can to process requests such as:
http://mercurial.selenic.com/hg/archive/tip.zip/mercurial/templates
This will download all files on the mercurial/templates directory as a zip file.
It is not possible to specify file patterns ('glob', 'relglob', 'path',
'relpath', 're', 'relre' nor 'set'). The server will reject those with a
403 HTTP error response.
Note that this is a first step to add support for downloading directories from
the web interface. A following patch will modify the archiveentry map entry on
the different templates so that it adds the current folder path to the archive
links.
author | Angel Ezquerra <angel.ezquerra@gmail.com> |
---|---|
date | Sun, 10 Feb 2013 11:52:05 +0100 |
parents | dcb6a99e82ff |
children | 88d1b59f6906 |
line wrap: on
line diff
--- a/tests/test-archive.t Wed Feb 06 10:06:45 2013 +0100 +++ b/tests/test-archive.t Sun Feb 10 11:52:05 2013 +0100 @@ -101,6 +101,18 @@ testing: test-archive-2c0277f05ed4/foo OK No errors detected in compressed data of archive.zip. +test that we can download single directories and files + + $ python getarchive.py "$TIP" gz baz | gunzip | tar tf - 2>/dev/null + test-archive-2c0277f05ed4/baz/bletch + $ python getarchive.py "$TIP" gz foo | gunzip | tar tf - 2>/dev/null + test-archive-2c0277f05ed4/foo + +test that we reject unsafe patterns + + $ python getarchive.py "$TIP" gz relre:baz + HTTP Error 403: Archive pattern not allowed: relre:baz + $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS $ hg archive -t tar test.tar