The branch, master has been updated
via c6c756d5594b107fea7712fe6b377d77abfc6ef2 (commit)
from 99b8119fd26336dc6568cfc611523fd9ca4f71a6 (commit)
- Shortlog ------------------------------------------------------------
c6c756d Dpkg::Deps: tweak the comparison algorithm to sort > lower than <
Summary of changes:
ChangeLog | 8 ++++++++
debian/changelog | 3 +++
scripts/Dpkg/Deps.pm | 46 ++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 53 insertions(+), 4 deletions(-)
-----------------------------------------------------------------------
Details of changes:
commit c6c756d5594b107fea7712fe6b377d77abfc6ef2
Author: Raphael Hertzog <[EMAIL PROTECTED]>
Date: Tue Dec 11 10:46:08 2007 +0100
Dpkg::Deps: tweak the comparison algorithm to sort > lower than <
* scripts/Dpkg/Deps.pm: Add a compare function that compares
dependencies more intelligently than a comparison on their
string representation. In particular we want >= and >> to sort
lower than << and <= so that intervals are nicely displayed
as "a (>= 1), a (<< 2)" instead of the ugly "a (<< 2), a (>= 1)".
diff --git a/ChangeLog b/ChangeLog
index 2b703d5..93b1463 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-12-11 Raphael Hertzog <[EMAIL PROTECTED]>
+
+ * scripts/Dpkg/Deps.pm: Add a compare function that compares
+ dependencies more intelligently than a comparison on their
+ string representation. In particular we want >= and >> to sort
+ lower than << and <= so that intervals are nicely displayed
+ as "a (>= 1), a (<< 2)" instead of the ugly "a (<< 2), a (>= 1)".
+
2007-12-10 Raphael Hertzog <[EMAIL PROTECTED]>
* README.translators: Explain how to format Git commit messages.
diff --git a/debian/changelog b/debian/changelog
index ed45efb..a562d49 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -26,6 +26,9 @@ dpkg (1.14.13) UNRELEASED; urgency=low
-lm. Closes: #454616
* Included files in symbols files (via #include) do no more need to repeat
the header line. Closes: #455260
+ * Tweak the sort algorithm between dependencies so that intervals
+ are displayed as "a (>= 1), a (<< 2)" instead of the opposite.
+ Closes: #455520
[ Updated man pages translations ]
* Swedish (Peter Karlsson)
diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm
index 3b5ca3a..4ceceb5 100644
--- a/scripts/Dpkg/Deps.pm
+++ b/scripts/Dpkg/Deps.pm
@@ -74,7 +74,8 @@ use Dpkg::ErrorHandling qw(warning);
use Dpkg::Gettext;
our @ISA = qw(Exporter);
-our @EXPORT_OK = qw(@pkg_dep_fields @src_dep_fields %dep_field_type);
+our @EXPORT_OK = qw(@pkg_dep_fields @src_dep_fields %dep_field_type
+ %relation_ordering);
# Some generic variables
our @pkg_dep_fields = qw(Pre-Depends Depends Recommends Suggests Enhances
@@ -97,6 +98,15 @@ our %dep_field_type = (
'Build-Conflicts-Indep' => 'union',
);
+our %relation_ordering = (
+ 'undef' => 0,
+ '>=' => 1,
+ '>>' => 2,
+ '=' => 3,
+ '<<' => 4,
+ '<=' => 5,
+);
+
# Some factorized function
=item Dpkg::Deps::arch_is_superset([EMAIL PROTECTED], [EMAIL PROTECTED])
@@ -285,8 +295,6 @@ this when parsing non-dependency fields like Conflicts (see
=back
-=back
-
=cut
sub parse {
my $dep_line = shift;
@@ -331,6 +339,36 @@ sub parse {
return $dep_and;
}
+=item Dpkg::Deps::compare($a, $b)
+
+This functions is used to order AND and Union dependencies prior to
+dumping.
+
+=back
+
+=cut
+sub compare {
+ my ($a, $b) = @_;
+ return -1 if $a->is_empty();
+ return 1 if $b->is_empty();
+ while ($a->isa('Dpkg::Deps::Multiple')) {
+ return -1 if $a->is_empty();
+ my @deps = $a->get_deps();
+ $a = $deps[0];
+ }
+ while ($b->isa('Dpkg::Deps::Multiple')) {
+ return 1 if $b->is_empty();
+ my @deps = $b->get_deps();
+ $b = $deps[0];
+ }
+ my $ar = defined($a->{relation}) ? $a->{relation} : "undef";
+ my $br = defined($b->{relation}) ? $b->{relation} : "undef";
+ return (($a->{package} cmp $b->{package}) ||
+ ($relation_ordering{$ar} <=> $relation_ordering{$br}) ||
+ ($a->{version} cmp $b->{version}));
+}
+
+
package Dpkg::Deps::Simple;
=head1 OBJECTS - Dpkg::Deps::*
@@ -762,7 +800,7 @@ sub get_deps {
sub sort {
my $self = shift;
my @res = ();
- @res = sort { $a->dump() cmp $b->dump() } @{$self->{list}};
+ @res = sort { Dpkg::Deps::compare($a, $b) } @{$self->{list}};
$self->{list} = [ @res ];
}
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]