Rev 6375: (jelmer) BZR_EMAIL should be respected for the 'email' config option default in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Dec 15 12:18:53 UTC 2011
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6375 [merge]
revision-id: pqm at pqm.ubuntu.com-20111215121853-1jw97a5rjazzqnbi
parent: pqm at pqm.ubuntu.com-20111215095847-ups4vccjrbfq6tvr
parent: jelmer at samba.org-20111215115348-murs91ipn8jbw6y0
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2011-12-15 12:18:53 +0000
message:
(jelmer) BZR_EMAIL should be respected for the 'email' config option default
value. (Jelmer Vernooij)
modified:
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-12-14 14:35:37 +0000
+++ b/bzrlib/config.py 2011-12-15 11:53:48 +0000
@@ -73,10 +73,8 @@
"""
import os
-import string
import sys
-
import bzrlib
from bzrlib.decorators import needs_write_lock
from bzrlib.lazy_import import lazy_import
@@ -441,14 +439,14 @@
# add) the final ','
l = [l]
return l
-
+
def get_user_option_as_int_from_SI(self, option_name, default=None):
"""Get a generic option from a human readable size in SI units, e.g 10MB
-
+
Accepted suffixes are K,M,G. It is case-insensitive and may be followed
by a trailing b (i.e. Kb, MB). This is intended to be practical and not
pedantic.
-
+
:return Integer, expanded to its base-10 value if a proper SI unit is
found. If the option doesn't exist, or isn't a value in
SI units, return default (which defaults to None)
@@ -479,7 +477,6 @@
except TypeError:
val = default
return val
-
@deprecated_method(deprecated_in((2, 5, 0)))
def gpg_signing_command(self):
@@ -1636,9 +1633,10 @@
f.close()
-
-
def default_email():
+ v = os.environ.get('BZR_EMAIL')
+ if v:
+ return v.decode(osutils.get_user_encoding())
v = os.environ.get('EMAIL')
if v:
return v.decode(osutils.get_user_encoding())
@@ -1855,7 +1853,7 @@
:param user: login (optional)
:param path: the absolute path on the server (optional)
-
+
:param realm: the http authentication realm (optional)
:return: A dict containing the matching credentials or None.
@@ -2461,7 +2459,6 @@
return float(unicode_str)
-
# Use a an empty dict to initialize an empty configobj avoiding all
# parsing and encoding checks
_list_converter_config = configobj.ConfigObj(
@@ -3488,7 +3485,7 @@
def __init__(self, location):
"""Make a new stack for a location and global configuration.
-
+
:param location: A URL prefix to """
lstore = LocationStore()
if location.startswith('file://'):
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2011-12-14 14:40:56 +0000
+++ b/bzrlib/tests/test_config.py 2011-12-15 11:53:48 +0000
@@ -4539,7 +4539,7 @@
def test_auto_user_id(self):
"""Automatic inference of user name.
-
+
This is a bit hard to test in an isolated way, because it depends on
system functions that go direct to /etc or perhaps somewhere else.
But it's reasonable to say that on Unix, with an /etc/mailname, we ought
@@ -4555,3 +4555,25 @@
else:
self.assertEquals((None, None), (realname, address))
+
+class EmailOptionTests(tests.TestCase):
+
+ def test_default_email_uses_BZR_EMAIL(self):
+ # BZR_EMAIL takes precedence over EMAIL
+ self.overrideEnv('BZR_EMAIL', 'jelmer at samba.org')
+ self.overrideEnv('EMAIL', 'jelmer at apache.org')
+ self.assertEquals('jelmer at samba.org', config.default_email())
+
+ def test_default_email_uses_EMAIL(self):
+ self.overrideEnv('BZR_EMAIL', None)
+ self.overrideEnv('EMAIL', 'jelmer at apache.org')
+ self.assertEquals('jelmer at apache.org', config.default_email())
+
+ def test_BZR_EMAIL_overrides(self):
+ self.overrideEnv('BZR_EMAIL', 'jelmer at apache.org')
+ self.assertEquals('jelmer at apache.org',
+ config.email_from_store('jelmer at debian.org'))
+ self.overrideEnv('BZR_EMAIL', None)
+ self.overrideEnv('EMAIL', 'jelmer at samba.org')
+ self.assertEquals('jelmer at debian.org',
+ config.email_from_store('jelmer at debian.org'))
More information about the bazaar-commits
mailing list