Rev 6564: (vila) Add a config option for the progress bar type. (Vincent Ladeuil) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Sep 19 09:15:29 UTC 2012
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6564 [merge]
revision-id: pqm at pqm.ubuntu.com-20120919091529-7npqgpvfroffuy8f
parent: pqm at pqm.ubuntu.com-20120919082725-dzvmca37zj5xx2hh
parent: v.ladeuil+lp at free.fr-20120919070739-zqmcghu9pd0ej44o
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2012-09-19 09:15:29 +0000
message:
(vila) Add a config option for the progress bar type. (Vincent Ladeuil)
modified:
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/tests/blackbox/test_debug.py test_debug.py-20061026142942-q76cgg41785b3mdk-1
bzrlib/tests/blackbox/test_diff.py test_diff.py-20060110203741-aa99ac93e633d971
bzrlib/tests/blackbox/test_locale.py test_lang.py-20060824204205-80v50j25qkuop7yn-1
bzrlib/ui/text.py text.py-20051130153916-2e438cffc8afc478
doc/en/release-notes/bzr-2.6.txt bzr2.6.txt-20120116134316-8w1xxom1c7vcu1t5-1
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2012-09-18 16:38:02 +0000
+++ b/bzrlib/config.py 2012-09-19 09:15:29 +0000
@@ -2135,7 +2135,7 @@
class Base64CredentialStore(CredentialStore):
__doc__ = """Base64 credential store for the authentication.conf file"""
-
+
def decode_password(self, credentials):
"""See CredentialStore.decode_password."""
# GZ 2012-07-28: Will raise binascii.Error if password is not base64,
@@ -2161,7 +2161,8 @@
for those under repositories.
"""
if self._config is None:
- raise errors.BzrError("Cannot set configuration in %s" % self._bzrdir)
+ raise errors.BzrError("Cannot set configuration in %s"
+ % self._bzrdir)
if value is None:
self._config.set_option('', 'default_stack_on')
else:
@@ -2473,8 +2474,8 @@
return float(unicode_str)
-# Use a an empty dict to initialize an empty configobj avoiding all
-# parsing and encoding checks
+# Use an empty dict to initialize an empty configobj avoiding all parsing and
+# encoding checks
_list_converter_config = configobj.ConfigObj(
{}, encoding='utf-8', list_values=True, interpolation=False)
@@ -2802,6 +2803,8 @@
Each function takes branch, rev_id as parameters.
'''))
+option_registry.register_lazy('progress_bar', 'bzrlib.ui.text',
+ 'opt_progress_bar')
option_registry.register(
Option('public_branch',
default=None,
=== modified file 'bzrlib/tests/blackbox/test_debug.py'
--- a/bzrlib/tests/blackbox/test_debug.py 2011-02-04 22:25:59 +0000
+++ b/bzrlib/tests/blackbox/test_debug.py 2012-09-19 07:07:39 +0000
@@ -52,9 +52,8 @@
# I would like to avoid run_bzr_subprocess here, but we need it to be
# connected to a real TextUIFactory. The NullProgressView always
# ignores transport activity.
- env = {'BZR_PROGRESS_BAR': 'text'}
- out, err = self.run_bzr_subprocess('branch -Dbytes %s/tree target'
- % (remote_trans.base,),
- env_changes=env)
+ out, err = self.run_bzr_subprocess(
+ 'branch -Dbytes -Oprogress_bar=text %s/tree target'
+ % (remote_trans.base,))
self.assertContainsRe(err, 'Branched 1 revision')
self.assertContainsRe(err, 'Transferred:.*kB')
=== modified file 'bzrlib/tests/blackbox/test_diff.py'
--- a/bzrlib/tests/blackbox/test_diff.py 2012-01-05 13:02:31 +0000
+++ b/bzrlib/tests/blackbox/test_diff.py 2012-09-19 07:07:39 +0000
@@ -388,10 +388,10 @@
# subprocess.py that we had to workaround).
# However, if 'diff' may not be available
self.make_example_branch()
- self.overrideEnv('BZR_PROGRESS_BAR', 'none')
- out, err = self.run_bzr_subprocess('diff -r 1 --diff-options -ub',
- universal_newlines=True,
- retcode=None)
+ out, err = self.run_bzr_subprocess(
+ 'diff -Oprogress_bar=none -r 1 --diff-options -ub',
+ universal_newlines=True,
+ retcode=None)
if 'Diff is not installed on this machine' in err:
raise tests.TestSkipped("No external 'diff' is available")
self.assertEqual('', err)
=== modified file 'bzrlib/tests/blackbox/test_locale.py'
--- a/bzrlib/tests/blackbox/test_locale.py 2011-05-15 14:35:24 +0000
+++ b/bzrlib/tests/blackbox/test_locale.py 2012-09-19 07:07:39 +0000
@@ -41,15 +41,21 @@
timestamp=1156451297.96, timezone=0)
self.tree = tree
+ def run_log_quiet_long(self, args, env_changes={}):
+ cmd = ['--no-aliases', '--no-plugins', '-Oprogress_bar=none',
+ 'log', '-q', '--log-format=long']
+ cmd.extend(args)
+ return self.run_bzr_subprocess(cmd, env_changes=env_changes)
+
def test_log_C(self):
self.disable_missing_extensions_warning()
- # C is not necessarily the default locale, so set both LANG and LC_ALL
- # explicitly because LC_ALL is preferred on (some?) Linux systems but
- # only LANG is respected on Windows.
- out, err = self.run_bzr_subprocess(
- '--no-aliases --no-plugins log -q --log-format=long tree',
- env_changes={'LANG': 'C', 'BZR_PROGRESS_BAR':'none',
- 'LC_ALL': 'C', 'LC_CTYPE':None, 'LANGUAGE':None})
+ out, err = self.run_log_quiet_long(
+ ['tree'],
+ # C is not necessarily the default locale, so set both LANG and
+ # LC_ALL explicitly because LC_ALL is preferred on (some?) Linux
+ # systems but only LANG is respected on Windows.
+ env_changes={'LANG': 'C', 'LC_ALL': 'C', 'LC_CTYPE':None,
+ 'LANGUAGE':None})
self.assertEqual('', err)
self.assertEqualDiff("""\
------------------------------------------------------------
@@ -62,10 +68,10 @@
""", out)
def test_log_BOGUS(self):
- out, err = self.run_bzr_subprocess(
- '--no-aliases --no-plugins log -q --log-format=long tree',
- env_changes={'LANG':'BOGUS', 'BZR_PROGRESS_BAR':'none',
- 'LC_ALL':None, 'LC_CTYPE':None, 'LANGUAGE':None})
+ out, err = self.run_log_quiet_long(
+ ['tree'],
+ env_changes={'LANG':'BOGUS', 'LC_ALL':None, 'LC_CTYPE':None,
+ 'LANGUAGE':None})
self.assertStartsWith(err, 'bzr: warning: unsupported locale setting')
self.assertEqualDiff("""\
------------------------------------------------------------
=== modified file 'bzrlib/ui/text.py'
--- a/bzrlib/ui/text.py 2012-04-30 10:44:04 +0000
+++ b/bzrlib/ui/text.py 2012-09-19 07:07:39 +0000
@@ -31,6 +31,7 @@
import warnings
from bzrlib import (
+ config,
debug,
progress,
osutils,
@@ -155,8 +156,14 @@
return index
+opt_progress_bar = config.Option(
+ 'progress_bar', help='Progress bar type.',
+ default_from_env=['BZR_PROGRESS_BAR'], default=None,
+ invalid='error')
+
+
class TextUIFactory(UIFactory):
- """A UI factory for Text user interefaces."""
+ """A UI factory for Text user interfaces."""
def __init__(self,
stdin=None,
@@ -279,14 +286,14 @@
# do that. otherwise, guess based on $TERM and tty presence.
if self.is_quiet():
return NullProgressView()
- elif os.environ.get('BZR_PROGRESS_BAR') == 'text':
- return TextProgressView(self.stderr)
- elif os.environ.get('BZR_PROGRESS_BAR') == 'none':
- return NullProgressView()
- elif progress._supports_progress(self.stderr):
- return TextProgressView(self.stderr)
- else:
- return NullProgressView()
+ pb_type = config.GlobalStack().get('progress_bar')
+ if pb_type == 'none': # Explicit requirement
+ return NullProgressView()
+ if (pb_type == 'text' # Explicit requirement
+ or progress._supports_progress(self.stderr)): # Guess
+ return TextProgressView(self.stderr)
+ # No explicit requirement and no successful guess
+ return NullProgressView()
def _make_output_stream_explicit(self, encoding, encoding_type):
if encoding_type == 'exact':
=== modified file 'doc/en/release-notes/bzr-2.6.txt'
--- a/doc/en/release-notes/bzr-2.6.txt 2012-09-18 16:38:02 +0000
+++ b/doc/en/release-notes/bzr-2.6.txt 2012-09-19 09:15:29 +0000
@@ -44,6 +44,10 @@
Bug Fixes
*********
+* Add a ``progress_bar`` configuration option defaulting to
+ ``BZR_PROGRESS_BAR``. This can be set in ``bazaar.conf`` or specified from
+ the command line with ``-Oprogress_bar=text``. (Vincent Ladeuil, #388725)
+
* Fixed a bug where the entire contents of ``/etc/mailname`` is read in.
We only want to read in the first line so that comments could be added
and would be ignored.
More information about the bazaar-commits
mailing list