SOURCES: patch_minimizer - readd comment at the begining if it was...

sparky sparky at pld-linux.org
Thu Nov 23 15:35:53 CET 2006


Author: sparky                       Date: Thu Nov 23 14:35:53 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- readd comment at the begining if it was lost

---- Files affected:
SOURCES:
   patch_minimizer (1.4 -> 1.5) 

---- Diffs:

================================================================
Index: SOURCES/patch_minimizer
diff -u SOURCES/patch_minimizer:1.4 SOURCES/patch_minimizer:1.5
--- SOURCES/patch_minimizer:1.4	Thu Nov 23 05:00:24 2006
+++ SOURCES/patch_minimizer	Thu Nov 23 15:35:47 2006
@@ -18,6 +18,7 @@
 my @cvs_cmd = qw(cvs -z9 -q up -p);
 my (@branch, @force_branch);
 my $file;
+my $old_comment = undef;
 
 sub strip_suffix($) {
 	my ($n) = @_;
@@ -56,10 +57,30 @@
 	return $ret;
 }
 
+sub strip_comment($) {
+	my $comment = shift;
+	pop @{$comment} while scalar @{$comment} and
+				$comment->[$#${comment}] =~ /^(diff .*|Index: .*|={67}|)$/;
+}
+
 sub get_files($) {
 	my ($file) = @_;
+	$old_comment = undef;
 	open CVS_IN, "-|", (@cvs_cmd, @branch, $file);
+	
+	my @comment;
+	my $l;
+	while ($l = <CVS_IN>) {
+		if ($l =~ /^---/) {
+			strip_comment(\@comment);
+			last;
+		}
+		push @comment, $l;
+	}
+	$old_comment = [@comment] if scalar @comment;
+
 	my @old_files = grep /^(\+\+\+|---|@@) /, <CVS_IN>;
+	unshift @old_files, $l;
 	close CVS_IN;
 	my @ret;
 	
@@ -89,8 +110,7 @@
 	while (my $l = shift @patch) {
 		if ($l =~ /^---/) {
 			unshift @patch, $l;
-			pop @comment while scalar @comment and
-				$comment[$#comment] =~ /^(diff .*|Index: .*|={67}|)$/;
+			strip_comment(\@comment);
 			last;
 		}
 		push @comment, $l;
@@ -132,12 +152,8 @@
 	my ($newhunk, $oldhunk) = @_;
 	my @newhunk = @{$newhunk};
 	my @oldhunk = @{$oldhunk};
-	shift @newhunk;
-	shift @newhunk;
-	shift @newhunk;
-	shift @oldhunk;
-	shift @oldhunk;
-	shift @oldhunk;
+	splice(@newhunk,0,3);
+	splice(@oldhunk,0,3);
 	my $ret = "";
 	
 	my %oldhunk = map { /^(@@.*?@@)(.*)$/ } @oldhunk;
@@ -158,7 +174,11 @@
 	my ($new, $old_files) = @_;
 	my $diff;
 	local $" = "";
-	$diff .= "@{$new->[0]}\n" if scalar @{$new->[0]};
+	if (scalar @{$new->[0]}) {
+		$diff .= "@{$new->[0]}\n";
+	} elsif (defined $old_comment) {
+		$diff .= "@{$old_comment}\n";
+	}
 	shift @{$new};
 	my %new_hash = map { $_->[0] => $_ } @{$new};
 	
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/patch_minimizer?r1=1.4&r2=1.5&f=u



More information about the pld-cvs-commit mailing list