Mercurial > hg-stable
changeset 5779:e9f68860d5ed
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.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 01 Jan 2008 17:07:15 +0100 |
parents | 9e97a7a0bb82 |
children | 0ae953487255 |
files | doc/hgrc.5.txt mercurial/hgweb/common.py mercurial/hgweb/hgweb_mod.py mercurial/hgweb/hgwebdir_mod.py tests/run-tests.py tests/test-hgweb-commands.out |
diffstat | 6 files changed, 16 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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 "")
--- 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,
--- 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",
--- 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 <foo.bar@example.com>" TESTDIR = os.environ["TESTDIR"] = os.getcwd() HGTMP = os.environ['HGTMP'] = tempfile.mkdtemp('', 'hgtests.', options.tmpdir)