diff --git a/doc/hgrc.5.txt b/doc/hgrc.5.txt --- a/doc/hgrc.5.txt +++ b/doc/hgrc.5.txt @@ -524,7 +524,7 @@ web:: Example: "http://hgserver/repos/" contact;; Name or email address of the person in charge of the repository. - Default is "unknown". + Defaults to ui.username or $EMAIL or "unknown" if unset or empty. deny_push;; Whether to deny pushing to the repository. If empty or not set, push is not denied. If the special value "*", all remote users diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py --- a/mercurial/hgweb/common.py +++ b/mercurial/hgweb/common.py @@ -97,3 +97,12 @@ def paritygen(stripecount, offset=0): parity = 1 - parity count = 0 +def get_contact(config): + """Return repo contact information or empty string. + + web.contact is the primary source, but if that is not set, try + ui.username or $EMAIL as a fallback to display something useful. + """ + return (config("web", "contact") or + config("ui", "username") or + os.environ.get("EMAIL") or "") diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -10,7 +10,7 @@ import os, mimetypes, re, mimetools, cSt from mercurial.node import * from mercurial import mdiff, ui, hg, util, archival, patch from mercurial import revlog, templater -from common import ErrorResponse, get_mtime, style_map, paritygen +from common import ErrorResponse, get_mtime, style_map, paritygen, get_contact from request import wsgirequest import webcommands, protocol @@ -808,9 +808,7 @@ class hgweb(object): yield tmpl("summary", desc=self.config("web", "description", "unknown"), - owner=(self.config("ui", "username") or # preferred - self.config("web", "contact") or # deprecated - self.config("web", "author", "unknown")), # also + owner=get_contact(self.config) or "unknown", lastchange=cl.read(cl.tip())[2], tags=tagentries, branches=branches, diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -9,7 +9,8 @@ import os, mimetools, cStringIO from mercurial.i18n import gettext as _ from mercurial import ui, hg, util, templater -from common import ErrorResponse, get_mtime, staticfile, style_map, paritygen +from common import ErrorResponse, get_mtime, staticfile, style_map, paritygen, \ + get_contact from hgweb_mod import hgweb from request import wsgirequest @@ -182,9 +183,7 @@ class hgwebdir(object): except OSError: continue - contact = (get("ui", "username") or # preferred - get("web", "contact") or # deprecated - get("web", "author", "")) # also + contact = get_contact(get) description = get("web", "description", "") name = get("web", "name", name) row = dict(contact=contact or "unknown", diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -405,6 +405,7 @@ if not options.child: # the tests produce repeatable output. os.environ['LANG'] = os.environ['LC_ALL'] = 'C' os.environ['TZ'] = 'GMT' +os.environ["EMAIL"] = "Foo Bar " TESTDIR = os.environ["TESTDIR"] = os.getcwd() HGTMP = os.environ['HGTMP'] = tempfile.mkdtemp('', 'hgtests.', options.tmpdir) diff --git a/tests/test-hgweb-commands.out b/tests/test-hgweb-commands.out index 5e3ce73614d0d3f4d7012871753618393a49cf1a..f3e584815ce403a79c6d4ebb3134fe0c6f44b830 GIT binary patch literal 13523 zc%1DTYjc}OGWYSQ{SmXcoV{Bc0kZs%EGtfIZ?ao?mF?6$zT^fNBq|7~VPx5x>_535 zd)+gD0HK#R&h6D1t0b7|>38>Z58ftMOpr-J#E22jl31gj7eqtiQPYo$C%oMzuj64# zXyg%hM57@~wYFuEE0+g}An`;b69Ir>7*A78>p#04hvbIwG>D@U-ELVrVUZgnx)YtI zZV>3t23p@|%p(9Ar6>AGh@@wlcKfhp!Jlmc{(bYgh{yUsBmM6UgPcjqVLT*;fn$L; zm|N91VHD=VAo>I{g(rH-LSH8%&in=<6!05>Q8%lLXebzus9+0Msudy-AsYymiWzr( zQ;ov(B=G=;H?X^hmSNfOxwfpH{Ori@zL|q)0L~)8?_gby_qpeRf&?8BP$8(7=gJ4O zwV7{G_psBYc4tPhSt(=2-3bq9Xl@k<4BGL#ZRWN2x<_q?S^Ec0_h`TEv3<{HM~8ci z0(Rf>Sf_& znk8T$%^5=X(uBHz2p&_$ZMYyxSeii|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