[dpkg] 107/192: Dpkg::ErrorHandling: Move color setup into report_pretty
Ximin Luo
infinity0 at debian.org
Tue Oct 17 11:04:06 UTC 2017
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch pu/reproducible_builds
in repository dpkg.
commit 5ea09cee634e4fe0cfac726937ccd2be81c272e8
Author: Guillem Jover <guillem at debian.org>
Date: Sat Jul 15 15:21:33 2017 +0200
Dpkg::ErrorHandling: Move color setup into report_pretty
Call setup_color() only if we are going to print something, so that
we remove code executed at import time.
---
debian/changelog | 1 +
scripts/Dpkg/ErrorHandling.pm | 7 ++++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index d9f7b86..dfc86ff 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -32,6 +32,7 @@ dpkg (1.19.0) UNRELEASED; urgency=medium
other modules.
- Only load Term::ANSIColor from Dpkg::ErrorHandling if we are going to
use colors, reducing the load time of many other modules.
+ - Move color setup into report_pretty in Dpkg::ErrorHandling.
* Documentation:
- Document currently accepted syntax for changelogs in deb-changelog(5).
Closes: #858579
diff --git a/scripts/Dpkg/ErrorHandling.pm b/scripts/Dpkg/ErrorHandling.pm
index b1f5ed0..a5b549f 100644
--- a/scripts/Dpkg/ErrorHandling.pm
+++ b/scripts/Dpkg/ErrorHandling.pm
@@ -15,6 +15,7 @@ package Dpkg::ErrorHandling;
use strict;
use warnings;
+use feature qw(state);
our $VERSION = '0.02';
our @EXPORT_OK = qw(
@@ -52,11 +53,11 @@ use Dpkg::Gettext;
my $quiet_warnings = 0;
my $debug_level = 0;
my $info_fh = \*STDOUT;
-my $use_color = 0;
sub setup_color
{
my $mode = $ENV{'DPKG_COLORS'} // 'auto';
+ my $use_color;
if ($mode eq 'auto') {
## no critic (InputOutput::ProhibitInteractiveTest)
@@ -70,8 +71,6 @@ sub setup_color
require Term::ANSIColor if $use_color;
}
-setup_color();
-
use constant {
REPORT_PROGNAME => 1,
REPORT_COMMAND => 2,
@@ -153,6 +152,8 @@ sub report_pretty
{
my ($msg, $color) = @_;
+ state $use_color = setup_color();
+
if ($use_color) {
return Term::ANSIColor::colored($msg, $color);
} else {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git
More information about the Reproducible-commits
mailing list