The following commit has been merged in the master branch: commit bb486d9e2630ec77b798f1730bd7603df69c9013 Author: Guillem Jover <guil...@debian.org> Date: Mon May 21 03:54:37 2012 +0200
Dpkg::Substvars: Rename no_warn() member function to mark_as_used() Keep the old name for backwards compatibility, but make it issue a warning. diff --git a/debian/changelog b/debian/changelog index 2bb057a..c561cb2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -32,6 +32,8 @@ dpkg (1.16.4) UNRELEASED; urgency=low error message. Thanks to Thomas Adam <thomas.a...@smoothwall.net> and Jonathan Nieder <jrnie...@gmail.com>. * Add new Dpkg::Substvars::set_as_used() member function. + * Rename Dpkg::Substvars no_warn() member function to mark_as_used(), keep + the old name aliased to the new one producing a deprecation warning. [ Updated man page translations ] * German (Helge Kreutzmann). diff --git a/scripts/Dpkg/Substvars.pm b/scripts/Dpkg/Substvars.pm index be26580..241bce3 100644 --- a/scripts/Dpkg/Substvars.pm +++ b/scripts/Dpkg/Substvars.pm @@ -25,6 +25,7 @@ use Dpkg::Arch qw(get_host_arch); use Dpkg::ErrorHandling; use Dpkg::Gettext; +use Carp; use POSIX qw(:errno_h); use base qw(Dpkg::Interface::Storable); @@ -76,7 +77,7 @@ sub new { }; $self->{'vars'}{'dpkg:Upstream-Version'} =~ s/-[^-]+$//; bless $self, $class; - $self->no_warn($_) foreach keys %{$self->{'vars'}}; + $self->mark_as_used($_) foreach keys %{$self->{'vars'}}; if ($arg) { $self->load($arg) if -e $arg; } @@ -104,7 +105,7 @@ even if unused). sub set_as_used { my ($self, $key, $value) = @_; $self->set($key, $value); - $self->no_warn($key); + $self->mark_as_used($key); } =item $s->get($key) @@ -130,18 +131,30 @@ sub delete { return delete $self->{'vars'}{$key}; } -=item $s->no_warn($key) +=item $s->mark_as_used($key) Prevents warnings about a unused substitution, for example if it is provided by default. =cut -sub no_warn { +sub mark_as_used { my ($self, $key) = @_; $self->{'used'}{$key}++; } +=item $s->no_warn($key) + +Obsolete function, use mark_as_used() instead. + +=cut + +sub no_warn { + my ($self, $key) = @_; + carp "obsolete no_warn() function, use mark_as_used() instead"; + $self->mark_as_used($key); +} + =item $s->load($file) Add new substitutions read from $file. @@ -187,7 +200,7 @@ sub set_version_substvars { # XXX: Source-Version is now deprecated, remove in the future. $self->{'vars'}{'Source-Version'} = $version; - $self->no_warn($_) foreach qw/binary:Version source:Version source:Upstream-Version Source-Version/; + $self->mark_as_used($_) foreach qw/binary:Version source:Version source:Upstream-Version Source-Version/; } =item $s->set_arch_substvars() @@ -230,7 +243,7 @@ sub substvars { $lhs = $1; $vn = $2; $rhs = $3; if (defined($self->{'vars'}{$vn})) { $v = $lhs . $self->{'vars'}{$vn} . $rhs; - $self->no_warn($vn); + $self->mark_as_used($vn); $count++; } else { warning($opts{msg_prefix} . _g("unknown substitution variable \${%s}"), diff --git a/scripts/t/750_Dpkg_Substvars.t b/scripts/t/750_Dpkg_Substvars.t index f7e03a5..2e35780 100644 --- a/scripts/t/750_Dpkg_Substvars.t +++ b/scripts/t/750_Dpkg_Substvars.t @@ -95,7 +95,7 @@ is($output, "750_Dpkg_Substvars.t: warning: unused substitution variable \${var2 , 'unused variables warnings'); # Disable warnings for a certain variable -$s->no_warn('var2'); +$s->mark_as_used('var2'); $output = ''; $SIG{'__WARN__'} = sub { $output .= $_[0] }; $s->warn_about_unused(); -- dpkg's main repository -- To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org