* Darren Salt <[EMAIL PROTECTED]> [20070411 23:03]:
> If a lot of Mercurial-using projects start appearing on alioth, then
> http://hg.debian.org/hg/ is going to become (shall we say) somewhat long.
> It'd be useful to have Mercurial be able to provide partial listings when in
> multi-repository server mode - with a suitably-patched version installed
> (patch attached), http://hg.debian.org/hg/xine-lib/ would list only those
> repositories below /hg/xine-lib.
>
> There is one minor issue: requests for images and style sheet resources are
> also relative to the given path. My patch handles this. (This probably won't
> affect alioth, which is using URLs of the form "...?static=style.css".)
I really want to have this features in hg, too.
Currently I work around it with a bit logic in hgwebdir.cgi.
Some comments on your code:
> + if prefix > '' and not prefix.endswith('/'):
Better simply use
if prefix and not prefix.endswith('/'):
> + sys.stderr.write(name+"\n")
> + sys.stderr.write (virtual + "\n")
There is some debugging code lurking around.
> + elif virtual and virtual.find('/static/') >= 0:
> + static = os.path.join(templater.templatepath(), 'static')
> + fname = virtual[virtual.find('/static/')+8:]
> + req.write(staticfile(static, fname, req) or
> + tmpl('error', error='%r not found' % fname))
The /static change should be separated in a separate patch, and I'm
not sure if virtual.find('/static/') isn't too greedy.
And virtual[virtual.find('/static/')+8:] looks a bit too magic, too.
(I know that '/static/' has the length 8)
> - req.write(tmpl("notfound", repo=virtual))
> + if req.form.has_key('static'):
> + static = os.path.join(templater.templatepath(), "static")
> + sys.stderr.write (static + "\n")
> + fname = req.form['static'][0]
> + req.write(staticfile(static, fname, req)
> + or tmpl("error", error="%r not found" % fname))
> + else:
> + sortable = ["name", "description", "contact",
> "lastchange"]
> + sortcolumn, descending = self.repos_sorted
> + if req.form.has_key('sort'):
> + sortcolumn = req.form['sort'][0]
> + descending = sortcolumn.startswith('-')
> + if descending:
> + sortcolumn = sortcolumn[1:]
> + if sortcolumn not in sortable:
> + sortcolumn = ""
> +
> + sort = [("sort_%s" % column,
> + "%s%s" % ((not descending and column ==
> sortcolumn)
> + and "-" or "", column))
> + for column in sortable]
> + req.write(tmpl("index", entries=entries,
> + sortcolumn=sortcolumn,
> descending=descending,
> + prefix=virtual, **dict(sort)))
> + #req.write(tmpl("notfound", repo=virtual))
No need to comment out code lines, we have a revision history :)
And I haven't checked this, but these lines look like copied from
other locations in the code, so there may be code duplication here.
Some things to consider: http://hg.intevation.org/mercurial/ and
http://hg.intevation.org/mercurial/crew/ (and its siblings) are both
valid repositories. When requesting /mercurial/ the repository
should be visible, not the list of crew, tah, ...
I haven't checked what your code does here.
Finally I'd like to be able to include those two patches upstream, so
it would be good if the patches apply to http://www.selenic.com/hg/
0.9.3 is based off the stable branch: http://www.selenic.com/repo/hg-stable/
Despite my critics, many thanks for the input :)
Regards,
Thomas
--
[EMAIL PROTECTED] - http://intevation.de/~thomas/ - OpenPGP key: 0x5816791A
Intevation GmbH, Osnabrück - Registereintrag: Amtsgericht Osnabrück, HR B 18998
Geschäftsführer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner