SOURCES: patch_minimizer - readd comments in hunk headers like: ...
sparky
sparky at pld-linux.org
Thu Nov 23 04:58:57 CET 2006
Author: sparky Date: Thu Nov 23 03:58:57 2006 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- readd comments in hunk headers like:
@@ -2241,6 +2243,7 @@ void some_function_name(void)
---- Files affected:
SOURCES:
patch_minimizer (1.2 -> 1.3)
---- Diffs:
================================================================
Index: SOURCES/patch_minimizer
diff -u SOURCES/patch_minimizer:1.2 SOURCES/patch_minimizer:1.3
--- SOURCES/patch_minimizer:1.2 Thu Nov 23 04:26:44 2006
+++ SOURCES/patch_minimizer Thu Nov 23 04:58:51 2006
@@ -59,7 +59,7 @@
sub get_files($) {
my ($file) = @_;
open CVS_IN, "-|", (@cvs_cmd, @branch, $file);
- my @old_files = grep /^(\+\+\+|---) /, <CVS_IN>;
+ my @old_files = grep /^(\+\+\+|---|@@) /, <CVS_IN>;
close CVS_IN;
my @ret;
@@ -68,7 +68,9 @@
redo unless ($f1 =~ /^-/ and $old_files[0] =~ /^\+/);
my $f2 = shift @old_files;
my $common = find_file_common( $f1, $f2 );
- push @ret, [$common, $f1, $f2];
+ my @hunk_desc;
+ push @hunk_desc, shift @old_files while (defined $old_files[0] and $old_files[0] =~ /^@/);
+ push @ret, [$common, $f1, $f2, @hunk_desc];
}
return \@ret;
@@ -126,6 +128,32 @@
return \@split_patch
}
+sub readd_comments($$) {
+ my ($newhunk, $oldhunk) = @_;
+ my @newhunk = @{$newhunk};
+ my @oldhunk = @{$oldhunk};
+ shift @newhunk;
+ shift @newhunk;
+ shift @newhunk;
+ shift @oldhunk;
+ shift @oldhunk;
+ shift @oldhunk;
+ my $ret = "";
+
+ my %oldhunk = map { /^(@@.*?@@)(.*)$/ } @oldhunk;
+
+ while (my $l = shift @newhunk) {
+ if ($l =~ /^(@@.*?@@)/) {
+ my $h = $1;
+ if (exists $oldhunk{$h}) {
+ $l = $h.$oldhunk{$h}."\n";
+ }
+ }
+ $ret .= $l;
+ }
+ return $ret;
+}
+
sub sort_hunks($$) {
my ($new, $old_files) = @_;
my $diff;
@@ -141,10 +169,7 @@
$diff .= "$oldhunk->[1]";
$diff .= "$oldhunk->[2]";
- shift @{$newhunk};
- shift @{$newhunk};
- shift @{$newhunk};
- $diff .= "@{$newhunk}";
+ $diff .= readd_comments($newhunk, $oldhunk);
delete $new_hash{$f};
}
================================================================
---- CVS-web:
http://cvs.pld-linux.org/SOURCES/patch_minimizer?r1=1.2&r2=1.3&f=u
More information about the pld-cvs-commit
mailing list