Attached patch (to be applied after the first one) has these
improvements:

 - sort blocking data fields so merge works
 - fix merge check for Blocked-By fields
 - fix cloning of bugs that are blockers or blocked
 - deal properly with changing blocking status of sets of merged bugs

-- 
see shy jo
diff --exclude=CVS -ur old/source/scripts/service.in debbugs/scripts/service.in
--- old/source/scripts/service.in       2005-03-16 21:55:19.000000000 -0500
+++ debbugs/scripts/service.in  2005-03-16 21:50:30.000000000 -0500
@@ -509,7 +509,18 @@
                $ref=$b;
                if (&getbug) {
                    push @okayblocks, $b;
-                   &cancelbug; # done checking the bug exists
+
+                   # add to the list all bugs that are merged with $b,
+                   # because all of their data must be kept in sync
+                   @thisbugmergelist= split(/ /,$data->{mergedwith});
+                   &cancelbug;
+
+                   foreach $ref (@thisbugmergelist) {
+                       if (&getbug) {
+                          push @okayblocks, $ref;
+                          &cancelbug;
+                       }
+                   }
                }
                else {
                    &notfoundbug;
@@ -545,11 +556,9 @@
                my @oldblocklist = split ' ', $data->{blocks};
                $data->{blocks} = '' if ($addsub eq "set");
                foreach my $b (@okayblocks) {
-                   $data->{blocks} = join ' ', grep $_ ne $b, 
-                       split ' ', $data->{blocks};
-                   $data->{blocks} = "$b $data->{blocks}" unless $addsub eq 
"sub";
+                       $data->{blocks} = manipset($data->{blocks}, $b,
+                               ($addsub ne "sub"));
                }
-               $data->{blocks} =~ s/\s*$//;
 
                foreach my $b (@oldblocklist) {
                        if (! grep { $_ eq $b } split ' ', $data->{blocks}) {
@@ -568,18 +577,15 @@
            foreach $ref (keys %addedblocks) {
                if (&getbug) {
                    foreach my $b (@{$addedblocks{$ref}}) {
-                       $data->{blockedby} = join ' ', grep $_ ne $b,
-                           split ' ', $data->{blockedby};
-                       $data->{blockedby} = "$b $data->{blockedby}";
+                       $data->{blockedby} = manipset($data->{blockedby}, $b, 
1);
                    }
                    &savebug;
                 }
            }
            foreach $ref (keys %removedblocks) {
                if (&getbug) {
-                   foreach my $b (@{$addedblocks{$ref}}) {
-                       $data->{blockedby} = join ' ', grep $_ ne $b,
-                           split ' ', $data->{blockedby};
+                   foreach my $b (@{$removedblocks{$ref}}) {
+                       $data->{blockedby} = manipset($data->{blockedby}, $b, 
0);
                    }
                    &savebug;
                 }
@@ -646,7 +652,7 @@
            $data->{severity} = '$gDefaultSeverity' if $data->{severity} eq '';
            &checkmatch('severity','m_severity',$data->{severity});
            &checkmatch('blocks','m_blocks',$data->{blocks});
-           &checkmatch('blocked-by','m_blocked-by',$data->{blockedby});
+           &checkmatch('blocked-by','m_blockedby',$data->{blockedby});
            &checkmatch('done mark','m_done',length($data->{done}) ? 'done' : 
'open');
            &checkmatch('owner','m_owner',$data->{owner});
            foreach my $t (split /\s+/, $data->{keywords}) { $tags{$t} = 1; }
@@ -699,20 +705,37 @@
                } else {
                    $action= "$gBug $origref cloned as bugs 
$firstref-$lastref.";
                }
+
+               my $blocks = $data->{blocks};
+               my $blockedby = $data->{blockedby};
+               
                &getnextbug;
                my $ohash = get_hashname($origref);
-               $ref = $firstref;
+               my $clone = $firstref;
                for $newclonedid (@newclonedids) {
-                   $clonebugs{$newclonedid} = $ref;
+                   $clonebugs{$newclonedid} = $clone;
            
-                   my $hash = get_hashname($ref);
-                   copy("db-h/$ohash/$origref.log", "db-h/$hash/$ref.log");
-                   copy("db-h/$ohash/$origref.status", 
"db-h/$hash/$ref.status");
-                   copy("db-h/$ohash/$origref.summary", 
"db-h/$hash/$ref.summary");
-                   copy("db-h/$ohash/$origref.report", 
"db-h/$hash/$ref.report");
-                   &bughook('new', $ref, $data);
+                   my $hash = get_hashname($clone);
+                   copy("db-h/$ohash/$origref.log", "db-h/$hash/$clone.log");
+                   copy("db-h/$ohash/$origref.status", 
"db-h/$hash/$clone.status");
+                   copy("db-h/$ohash/$origref.summary", 
"db-h/$hash/$clone.summary");
+                   copy("db-h/$ohash/$origref.report", 
"db-h/$hash/$clone.report");
+                   &bughook('new', $clone, $data);
+               
+                   # Update blocking info of bugs blocked by or blocking the
+                   # cloned bug.
+                   foreach $ref (split ' ', $blocks) {
+                       &getbug;
+                       $data->{blockedby} = manipset($data->{blockedby}, 
$clone, 1);
+                       &savebug;
+                   }
+                   foreach $ref (split ' ', $blockedby) {
+                       &getbug;
+                       $data->{blocks} = manipset($data->{blocks}, $clone, 1);
+                       &savebug;
+                   }
 
-                   $ref++;
+                   $clone++;
                }
            }
        }
@@ -891,6 +914,21 @@
     }
 }
 
+sub manipset {
+    my $list = shift;
+    my $elt = shift;
+    my $add = shift;
+
+    my %h = map { $_ => 1 } split ' ', $list;
+    if ($add) {
+        $h{$elt}=1;
+    }
+    else {
+       delete $h{$elt};
+    }
+    return join ' ', sort keys %h;
+}
+
 # High-level bug manipulation calls
 # Do announcements themselves
 #

Attachment: signature.asc
Description: Digital signature

Reply via email to