From: Frank Lichtenheld Date: Wed, 22 Feb 2006 22:18:37 +0000 (+0000) Subject: Revert the commit that deleted some version-related methods since they X-Git-Tag: switch-to-templates~70 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=b21dd56695db580574c998f2f9ca59e18d168c06;p=deb%2Fpackages.git Revert the commit that deleted some version-related methods since they are used by create_index_pages --- diff --git a/lib/Packages/Page.pm b/lib/Packages/Page.pm index c3e20d2..000f1a0 100644 --- a/lib/Packages/Page.pm +++ b/lib/Packages/Page.pm @@ -212,6 +212,42 @@ sub get_arch_field { return \%result; } +sub get_versions { + my ($self) = @_; + + my %versions; + foreach (keys %{$self->{versions}}) { + my $version = $self->{versions}{$_}{version}; + $versions{$version} ||= []; + push @{$versions{$version}}, $_; + } + + return \%versions; +} + +sub get_version_string { + my ($self) = @_; + + my $versions = $self->get_versions; + my @versions = version_sort keys %$versions; + my (@v_str, $v_str, $v_str_arch); + if ( scalar @versions == 1 ) { + @v_str = ( [ $versions[0], undef ] ); + $v_str = $versions[0]; + $v_str_arch = $versions[0]; + } else { + my @v_str_arch; + foreach ( @versions ) { + push @v_str, [ $_, $versions->{$_} ]; + push @v_str_arch, "$_ [".join(', ', @{$versions->{$_}})."]"; + } + $v_str_arch = join( ", ", @v_str_arch ); + $v_str = join( ", ", @versions ); + } + + return ($v_str, $v_str_arch, \@v_str); +} + sub get_dep_field { my ($self, $dep_field) = @_; diff --git a/lib/Packages/SrcPage.pm b/lib/Packages/SrcPage.pm index a10a2c2..7fc0e27 100644 --- a/lib/Packages/SrcPage.pm +++ b/lib/Packages/SrcPage.pm @@ -93,6 +93,20 @@ sub get_arch_field { return $self->{data}{$field}; } +sub get_versions { + my ($self) = @_; + + return [ $self->{version} ]; +} + +sub get_version_string { + my ($self) = @_; + + my $versions = $self->get_versions; + + return ($self->{version}, $versions); +} + sub get_dep_field { my ($self, $dep_field) = @_;