summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2010-11-21 17:43:09 -0600
committerJesse Luehrs <doy@tozt.net>2010-11-21 17:43:09 -0600
commit7ff55144b9c6f9c4933f1b21cc04c1199e9f5de5 (patch)
tree1c88ae55265fd4e0064e386a3bd9ee078b3ff048 /lib
parent8cc54374790f8728eb1be75bbbab33b91ae69838 (diff)
downloaddist-checkconflicts-7ff55144b9c6f9c4933f1b21cc04c1199e9f5de5.tar.gz
dist-checkconflicts-7ff55144b9c6f9c4933f1b21cc04c1199e9f5de5.zip
allow using the dist name in the error message
Diffstat (limited to 'lib')
-rw-r--r--lib/Dist/CheckConflicts.pm17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/Dist/CheckConflicts.pm b/lib/Dist/CheckConflicts.pm
index da9b859..ec87fc3 100644
--- a/lib/Dist/CheckConflicts.pm
+++ b/lib/Dist/CheckConflicts.pm
@@ -7,20 +7,22 @@ use List::MoreUtils 'first_index';
use Sub::Exporter;
my $import = Sub::Exporter::build_exporter({
- exports => [ qw(conflicts check_conflicts calculate_conflicts) ],
+ exports => [ qw(conflicts check_conflicts calculate_conflicts dist) ],
groups => {
- default => [ qw(conflicts check_conflicts calculate_conflicts) ],
+ default => [ qw(conflicts check_conflicts calculate_conflicts dist) ],
},
});
my %CONFLICTS;
+my %DISTS;
sub import {
my $for = caller;
- my ($conflicts, $alsos);
+ my ($conflicts, $alsos, $dist);
($conflicts, @_) = _strip_opt('-conflicts' => @_);
($alsos, @_) = _strip_opt('-also' => @_);
+ ($dist, @_) = _strip_opt('-dist' => @_);
my %conflicts = %{ $conflicts || {} };
for my $also (@{ $alsos || [] }) {
@@ -34,6 +36,7 @@ sub import {
}
$CONFLICTS{$for} = \%conflicts;
+ $DISTS{$for} = $dist || $for;
goto $import;
}
@@ -56,12 +59,18 @@ sub conflicts {
return %{ $CONFLICTS{ $package } };
}
+sub dist {
+ my $package = shift;
+ return $DISTS{ $package };
+}
+
sub check_conflicts {
my $package = shift;
+ my $dist = $package->dist;
my @conflicts = $package->calculate_conflicts;
return unless @conflicts;
- my $err = "Conflicts detected for $package:\n";
+ my $err = "Conflicts detected for $dist:\n";
for my $conflict (@conflicts) {
$err .= " $conflict->{package} is version "
. "$conflict->{installed}, but must be greater than version "