hgweb: filectx doesn't show file index

chris.eldredge chris.eldredge at gmail.com
Mon Sep 24 14:41:34 CDT 2012


Browsing to e.g. http://localhost/MyRepo/file/tip/ on hgweb raises an HTTP
404: "file not given" status instead of showing an index of files in the
top-level folder of the repository.

This behavior is not consistent with browsing to a nested subdirectory in
the repository which still shows an index of files within that subdirectory.

The supplied patch restores correct behavior.

# HG changeset patch
# User Chris Eldredge <celdredge at fool.com>
# Date 1348515530 -3600
# Node ID e56d52075f167f0b333c61624927f6747861fa0d
# Parent  ff5ed1ecd43a8940d2e93cab53ac8187a97c35ea
hgweb: return index of root directory when file is not given

diff -r ff5ed1ecd43a -r e56d52075f16 mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py	Thu Sep 20 23:30:59 2012 -0400
+++ b/mercurial/hgweb/webutil.py	Mon Sep 24 20:38:50 2012 +0100
@@ -156,15 +156,15 @@
     return ctx
 
 def filectx(repo, req):
-    if 'file' not in req.form:
-        raise ErrorResponse(HTTP_NOT_FOUND, 'file not given')
-    path = cleanpath(repo, req.form['file'][0])
     if 'node' in req.form:
         changeid = req.form['node'][0]
     elif 'filenode' in req.form:
         changeid = req.form['filenode'][0]
     else:
         raise ErrorResponse(HTTP_NOT_FOUND, 'node or filenode not given')
+    if 'file' not in req.form:
+        return repo.filectx(path='', fileid=changeid)
+    path = cleanpath(repo, req.form['file'][0])
     try:
         fctx = repo[changeid][path]
     except error.RepoError:




--
View this message in context: http://mercurial.808500.n3.nabble.com/hgweb-filectx-doesn-t-show-file-index-tp3992927.html
Sent from the Development mailing list archive at Nabble.com.


More information about the Mercurial-devel mailing list