[PATCH] hgweb: add remoteuser to template variables

FZiegler zarf at klacto.net
Thu Sep 16 21:48:33 CDT 2010


# HG changeset patch
# User Francois Ziegler <zarf at klacto.net>
# Date 1284690040 14400
# Node ID d8f32f9badc6580a6418d1ddac425479abd63efb
# Parent  4134686b83e147b70c66c3364a5c2921651818e9
hgweb: add remoteuser to template variables

diff -r 4134686b83e1 -r d8f32f9badc6 mercurial/hgweb/common.py
--- a/mercurial/hgweb/common.py	Thu Sep 16 17:51:32 2010 -0500
+++ b/mercurial/hgweb/common.py	Thu Sep 16 22:20:40 2010 -0400
@@ -155,7 +155,8 @@
             os.environ.get("EMAIL") or "")
 
 def caching(web, req):
-    tag = str(web.mtime)
+    user = req.env.get('REMOTE_USER', '')
+    tag = str(web.mtime)+'/'+str(user)
     if req.env.get('HTTP_IF_NONE_MATCH') == tag:
         raise ErrorResponse(HTTP_NOT_MODIFIED)
     req.headers.append(('ETag', tag))
diff -r 4134686b83e1 -r d8f32f9badc6 mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Thu Sep 16 17:51:32 2010 -0500
+++ b/mercurial/hgweb/hgweb_mod.py	Thu Sep 16 22:20:40 2010 -0400
@@ -217,6 +217,7 @@
             proto = 'http'
             default_port = "80"
 
+        user = req.env.get('REMOTE_USER', '')
         port = req.env["SERVER_PORT"]
         port = port != default_port and (":" + port) or ""
         urlbase = '%s://%s%s' % (proto, req.env['SERVER_NAME'], port)
@@ -261,6 +262,7 @@
                                    defaults={"url": req.url,
                                              "staticurl": staticurl,
                                              "urlbase": urlbase,
+                                             "remoteuser": user,
                                              "repo": self.reponame,
                                              "header": header,
                                              "footer": footer,
diff -r 4134686b83e1 -r d8f32f9badc6 mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py	Thu Sep 16 17:51:32 2010 -0500
+++ b/mercurial/hgweb/hgwebdir_mod.py	Thu Sep 16 22:20:40 2010 -0400
@@ -310,6 +310,7 @@
 
         self.updatereqenv(req.env)
 
+        user = req.env.get('REMOTE_USER', '')
         url = req.env.get('SCRIPT_NAME', '')
         if not url.endswith('/'):
             url += '/'
@@ -334,6 +335,7 @@
                                    defaults={"header": header,
                                              "footer": footer,
                                              "motd": motd,
+                                             "remoteuser": user,
                                              "url": url,
                                              "staticurl": staticurl,
                                              "sessionvars": sessionvars})


More information about the Mercurial-devel mailing list