]> git.donarmstrong.com Git - debbugs.git/commitdiff
Fix merged sort order to always be numeric
authorDon Armstrong <don@donarmstrong.com>
Thu, 6 Jul 2017 02:04:24 +0000 (19:04 -0700)
committerDon Armstrong <don@donarmstrong.com>
Thu, 6 Jul 2017 02:04:24 +0000 (19:04 -0700)
Debbugs/Control.pm
Debbugs/Status.pm

index 807549f9a8a574b7595e15bf1a7d5eccea549b3b..ab6038426da841bd8bd20f0db31728d9a4f75b9b 100644 (file)
@@ -1975,8 +1975,11 @@ sub set_merged {
                $data->{mergedwith} = '';
            }
            else {
-               $data->{mergedwith} = join(' ',sort grep {$_ != $data->{bug_num}}
-                                           keys %merged_bugs);
+               $data->{mergedwith} =
+                   join(' ',
+                        sort {$a <=> $b}
+                        grep {$_ != $data->{bug_num}}
+                        keys %merged_bugs);
            }
            append_action_to_log(bug => $data->{bug_num},
                                 command  => 'merge',
@@ -2157,11 +2160,14 @@ sub set_merged {
     }
 
     # finally, we can merge the bugs
-    my $action = "Merged ".join(' ',sort keys %merged_bugs);
+    my $action = "Merged ".join(' ',sort { $a <=> $b } keys %merged_bugs);
     for my $data (@data) {
        my $old_data = dclone($data);
-       $data->{mergedwith} = join(' ',sort grep {$_ != $data->{bug_num}}
-                                   keys %merged_bugs);
+       $data->{mergedwith} =
+           join(' ',
+                sort { $a <=> $b }
+                grep {$_ != $data->{bug_num}}
+                keys %merged_bugs);
        append_action_to_log(bug => $data->{bug_num},
                             command  => 'merge',
                             new_data => $data,
index c9f5709265d9ee3f4cc7be86614def9e34e954de..4b8d82e828f06687595ea11a45164a4bb907401d 100644 (file)
@@ -282,6 +282,17 @@ sub read_bug{
     $data{archived} = (defined($location) and ($location eq 'archive'))?1:0;
     $data{bug_num} = $param{bug};
 
+    # mergedwith occasionally is sorted badly. Fix it to always be sorted by <=>
+    # and not include this bug
+    if (defined $data{mergedwith} and
+       $data{mergedwith}) {
+       $data{mergedwith} =
+           join(' ',
+                grep { $_ != $data{bug_num}}
+                sort { $a <=> $b }
+                split / /, $data{mergedwith}
+               );
+    }
     return \%data;
 }
 
@@ -516,7 +527,10 @@ sub lock_read_all_merged_bugs {
            # are all merged with eachother
         # We do a cmp sort instead of an <=> sort here, because that's
         # what merge does
-           my $expectmerge= join(' ',grep {$_ != $bug } sort @bugs);
+           my $expectmerge=
+               join(' ',grep {$_ != $bug }
+                    sort { $a <=> $b }
+                    @bugs);
            if ($newdata->{mergedwith} ne $expectmerge) {
                for (1..$locks) {
                    unfilelock(exists $param{locks}?$param{locks}:());