Re: Proposal: Handling of changelog bug closures in Debian derived distros
On Tue, 2006-11-14 at 08:11:01 +0200, Guillem Jover wrote:
> [...]. I'm attaching
> a PoC patch with those change to dpkg. Probably we'd not want to
> output the Origin field in the default mode (assuming Debian or local),
> instead of the current implementation which outputs "Origin: debian".
Hmm, and of course forgot the attachment...
regards,
guillem
Index: scripts/changelog/debian.pl
===================================================================
--- scripts/changelog/debian.pl (revision 596)
+++ scripts/changelog/debian.pl (working copy)
@@ -62,13 +62,19 @@
%mapkv=(); # for future use
$i=100;grep($fieldimps{$_}=$i--,
- qw(Source Version Distribution Urgency Maintainer Date Closes
+ qw(Source Version Origin Distribution Urgency Maintainer Date Closes
Changes));
$i=1;grep($urgencies{$_}=$i++,
qw(low medium high critical emergency));
$expect='first heading';
+# Set the default Origin.
+$f{'Origin'} = 'debian';
+my $current_origin;
+
+my @closes;
+
while (<STDIN>) {
s/\s*\n$//;
# printf(STDERR "%-39.39s %-39.39s\n",$expect,$_);
@@ -86,6 +92,10 @@
} else {
&clerror(sprintf(_g("found start of entry where expected %s"), $expect));
}
+
+ # Set the default value in case the optional origin is missing.
+ $current_origin = 'debian';
+
$rhs= $'; $rhs =~ s/^\s+//;
undef %kvdone;
for $kv (split(/\s*,\s*/,$rhs)) {
@@ -113,6 +123,11 @@
(($newurgn > $oldurgn ? $newurg : $oldurg).
$oldcomment.
$newcomment);
+ } elsif ($k eq 'Origin') {
+ if ($expect eq 'first heading') {
+ $f{'Origin'} = $v;
+ }
+ $current_origin = $v;
} elsif (defined($mapkv{$k})) {
$f{$mapkv{$k}}= $v;
} elsif ($k =~ m/^X[BCS]+-/i) {
@@ -142,6 +157,14 @@
$expect eq 'start of change data' || $expect eq 'more change data or trailer' ||
&clerror(sprintf(_g("found change data where expected %s"), $expect));
$f{'Changes'}.= (" .\n"x$blanklines)." $_\n"; $blanklines=0;
+
+ # Add only bug closures if we are on an entry with the same origin as
+ # the first one.
+ if ($f{'Origin'} eq $current_origin and
+ $_ =~ /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/ig) {
+ push(@closes, $& =~ /\#?\s?(\d+)/g);
+ }
+
$expect= 'more change data or trailer';
} elsif (!m/\S/) {
next if $expect eq 'start of change data' || $expect eq 'next heading or eof';
@@ -158,9 +181,6 @@
$f{'Changes'} =~ s/\n$//;
$f{'Changes'} =~ s/^/\n/;
-while ($f{'Changes'} =~ /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/ig) {
- push(@closes, $& =~ /\#?\s?(\d+)/g);
-}
$f{'Closes'} = join(' ',sort { $a <=> $b} @closes);
&outputclose(0);
Index: scripts/dpkg-genchanges.pl
===================================================================
--- scripts/dpkg-genchanges.pl (revision 596)
+++ scripts/dpkg-genchanges.pl (working copy)
@@ -75,7 +75,7 @@
}
$i=100;grep($fieldimps{$_}=$i--,
- qw(Format Date Source Binary Architecture Version
+ qw(Format Date Source Binary Architecture Version Origin
Distribution Urgency Maintainer Changed-By Description
Closes Changes Files));
@@ -228,7 +228,7 @@
&setsourcepackage;
} elsif (m/^Maintainer$/i) {
$f{"Changed-By"}=$v;
- } elsif (m/^(Version|Changes|Urgency|Distribution|Date|Closes)$/i) {
+ } elsif (m/^(Version|Changes|Urgency|Origin|Distribution|Date|Closes)$/i) {
$f{$_}= $v;
} elsif (s/^X[BS]*C[BS]*-//i) {
$f{$_}= $v;
Index: scripts/dpkg-gencontrol.pl
===================================================================
--- scripts/dpkg-gencontrol.pl (revision 596)
+++ scripts/dpkg-gencontrol.pl (working copy)
@@ -173,7 +173,7 @@
} elsif (m/^Version$/) {
$sourceversion= $v;
$f{$_}= $v unless length($forceversion);
- } elsif (m/^(Maintainer|Changes|Urgency|Distribution|Date|Closes)$/) {
+ } elsif (m/^(Maintainer|Changes|Urgency|Origin|Distribution|Date|Closes)$/) {
} elsif (s/^X[CS]*B[CS]*-//i) {
$f{$_}= $v;
} elsif (!m/^X[CS]+-/i) {
Reply to: