From: Don Armstrong Date: Thu, 28 Sep 2023 03:41:06 +0000 (-0700) Subject: Sort blocked-by to allow merging bugs with mis-sorted blockers X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a15eee729610a5fa25ca0415b6fd19a7a63b43d0;p=debbugs.git Sort blocked-by to allow merging bugs with mis-sorted blockers --- diff --git a/debian/changelog b/debian/changelog index 5cdd98c1..a6392022 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ debbugs (3.0.0~alpha.1) unstable; urgency=medium * Actually return message/rfc822 when there is a single message instead of mbox (closes: #1009181) * Fix missing escaping of comma in address fields (closes: #1041638) + * Sort blocked-by (closes: 751808), thanks to Tim Landscheidt. -- Don Armstrong Fri, 09 Mar 2018 11:17:10 -0800 diff --git a/lib/Debbugs/Status.pm b/lib/Debbugs/Status.pm index f5397814..dcc83b19 100644 --- a/lib/Debbugs/Status.pm +++ b/lib/Debbugs/Status.pm @@ -299,6 +299,17 @@ sub read_bug{ $data{archived} = (defined($location) and ($location eq 'archive'))?1:0; $data{bug_num} = $param{bug}; + # Sort blockedby numerically so that bugs with identical blockers have + # identical lists. + if (defined $data{blockedby} and + $data{blockedby}) { + $data{blockedby} = + join(' ', + sort { $a <=> $b } + split / /, $data{blockedby} + ); + } + # mergedwith occasionally is sorted badly. Fix it to always be sorted by <=> # and not include this bug if (defined $data{mergedwith} and diff --git a/t/12_merge.t b/t/12_merge.t index a20b3979..901b8834 100644 --- a/t/12_merge.t +++ b/t/12_merge.t @@ -142,7 +142,7 @@ send_message(to => 'control@bugs.something', ], body => <<'EOF') or fail 'message to control@bugs.something failed'; debug 10 -clone 2 -1 -2 -3 -4 -5 -6 +clone 2 -1 -2 -3 -4 -5 -6 -7 -8 retitle 2 foo owner 2 bar@baz.com submitter 2 fleb@bleh.com @@ -159,9 +159,21 @@ fixed -4 1.2-3 found -4 1.2-1 found -5 1.2-5 fixed -5 1.2-6 +block -7 by -1 +block -7 by -2 +block -8 by -2 +block -8 by -1 thanks EOF +# The order of "Blocked-By:" in *.summary is not deterministic, so +# these tests assert that the blockers of bugs #9 and #10 are sorted +# differently. +ok(system('perl', '-i', '-pwe', 's/^Blocked-By: 4 3\n/Blocked-By: 3 4\n/;', $spool_dir . '/db-h/09/9.summary') == 0, 'Changed bug #9'); +ok(system('perl', '-i', '-pwe', 's/^Blocked-By: 3 4\n/Blocked-By: 4 3\n/;', $spool_dir . '/db-h/10/10.summary') == 0, 'Changed bug #10'); +ok(system('grep','-q','^Blocked-By: 3 4',"$spool_dir/db-h/09/9.summary") == 0,'Bug #9 has "Blocked-By: 3 4"'); +ok(system('grep','-q','^Blocked-By: 4 3',"$spool_dir/db-h/10/10.summary") == 0,'Bug #10 has "Blocked-By: 4 3"'); + test_control_commands(\%config, forcemerge => {command => 'forcemerge', value => "2 3\nseverity 2 minor", @@ -191,6 +203,12 @@ test_control_commands(\%config, status_value => '8', bug => '7', }, + merge => {command => 'merge', + value => '9 10', + status_key => 'mergedwith', + status_value => '10', + bug => '9', + }, ); done_testing();