Rev 6366: BZR_EMAIL should override all config settings, no matter how surprising it may seem. in file:///home/vila/src/bzr/reviews/commit-uses-config-stacks/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Dec 14 14:35:37 UTC 2011
At file:///home/vila/src/bzr/reviews/commit-uses-config-stacks/
------------------------------------------------------------
revno: 6366
revision-id: v.ladeuil+lp at free.fr-20111214143537-dh7ipx6vdd3n0y90
parent: jelmer at samba.org-20111214140947-ha9yup6hfoigz63s
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: commit-uses-config-stacks
timestamp: Wed 2011-12-14 15:35:37 +0100
message:
BZR_EMAIL should override all config settings, no matter how surprising it may seem.
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-12-14 14:09:47 +0000
+++ b/bzrlib/config.py 2011-12-14 14:35:37 +0000
@@ -1636,6 +1636,31 @@
f.close()
+
+
+def default_email():
+ v = os.environ.get('EMAIL')
+ if v:
+ return v.decode(osutils.get_user_encoding())
+ name, email = _auto_user_id()
+ if name and email:
+ return u'%s <%s>' % (name, email)
+ elif email:
+ return email
+ raise errors.NoWhoami()
+
+
+def email_from_store(unicode_str):
+ """Unlike other env vars, BZR_EMAIL takes precedence over config settings.
+
+ Whatever comes from a config file is then overridden.
+ """
+ value = os.environ.get('BZR_EMAIL')
+ if value:
+ return value.decode(osutils.get_user_encoding())
+ return unicode_str
+
+
def _auto_user_id():
"""Calculate automatic user identification.
@@ -2580,24 +2605,9 @@
option_registry.register(
Option('editor',
help='The command called to launch an editor to enter a message.'))
-
-
-def default_email():
- v = os.environ.get('EMAIL')
- if v:
- return v.decode(osutils.get_user_encoding())
- name, email = _auto_user_id()
- if name and email:
- return u'%s <%s>' % (name, email)
- elif email:
- return email
- raise errors.NoWhoami()
-
-
-# FIXME: 'email' should also look at the BZR_EMAIL environment variable,
-# which takes precedence over the settings in the configuration file.
option_registry.register(
Option('email', default=default_email,
+ from_unicode=email_from_store,
help='The users identity'))
option_registry.register(
Option('gpg_signing_command',
More information about the bazaar-commits
mailing list