# HG changeset patch # User Thomas Arendsen Hein # Date 1199203635 -3600 # Node ID e9f68860d5edd3ab5e491eb7a98995b255652f56 # Parent 9e97a7a0bb8214a09e83b0dcff934414ea35daa7 Don't let ui.username override web.contact (issue900) 4603eef60237 introduced using ui.username before web.contact, but this was never documented and might cause commit accidents. - Drop web.author (deprecated since 2005) - Try ui.username or $EMAIL as a fallback to display something useful. - Update docs for the fallbacks. diff -r 9e97a7a0bb82 -r e9f68860d5ed doc/hgrc.5.txt --- a/doc/hgrc.5.txt Tue Jan 01 11:19:15 2008 +0100 +++ b/doc/hgrc.5.txt Tue Jan 01 17:07:15 2008 +0100 @@ -524,7 +524,7 @@ 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 -r 9e97a7a0bb82 -r e9f68860d5ed mercurial/hgweb/common.py --- a/mercurial/hgweb/common.py Tue Jan 01 11:19:15 2008 +0100 +++ b/mercurial/hgweb/common.py Tue Jan 01 17:07:15 2008 +0100 @@ -97,3 +97,12 @@ 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 -r 9e97a7a0bb82 -r e9f68860d5ed mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py Tue Jan 01 11:19:15 2008 +0100 +++ b/mercurial/hgweb/hgweb_mod.py Tue Jan 01 17:07:15 2008 +0100 @@ -10,7 +10,7 @@ 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 @@ 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 -r 9e97a7a0bb82 -r e9f68860d5ed mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py Tue Jan 01 11:19:15 2008 +0100 +++ b/mercurial/hgweb/hgwebdir_mod.py Tue Jan 01 17:07:15 2008 +0100 @@ -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 @@ 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 -r 9e97a7a0bb82 -r e9f68860d5ed tests/run-tests.py --- a/tests/run-tests.py Tue Jan 01 11:19:15 2008 +0100 +++ b/tests/run-tests.py Tue Jan 01 17:07:15 2008 +0100 @@ -405,6 +405,7 @@ # 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 -r 9e97a7a0bb82 -r e9f68860d5ed tests/test-hgweb-commands.out Binary file tests/test-hgweb-commands.out has changed