]> git.donarmstrong.com Git - debbugs.git/commitdiff
Sort blocked-by to allow merging bugs with mis-sorted blockers
authorDon Armstrong <don@donarmstrong.com>
Thu, 28 Sep 2023 03:41:06 +0000 (20:41 -0700)
committerDon Armstrong <don@donarmstrong.com>
Thu, 28 Sep 2023 03:41:06 +0000 (20:41 -0700)
debian/changelog
lib/Debbugs/Status.pm
t/12_merge.t

index 5cdd98c17832a1846accb5809fb54f182948b818..a63920229df15ae337b89fe7ec60a2ad751b9537 100644 (file)
@@ -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 <don@debian.org>  Fri, 09 Mar 2018 11:17:10 -0800
 
index f539781495c297c64a54239823411da2a0c328b1..dcc83b19b296206604255a3aa2e635a88dd3a745 100644 (file)
@@ -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
index a20b3979364b9d16a4fdcd5c3d35eb9fbd74dbb5..901b883465f14cd65f40f27349564894ed6dc893 100644 (file)
@@ -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();