Here's an experiment to keep the change history of lines in annotate's output:

annotate.diff
        Switch from patch to ed

annotate2.diff
        Switch to ed-like perl script that alternatively appends to lines
        instead of changing them.

Please tell me if this is of any practical use to you (apart from showing 
"interesting"). Jean, how much does Quian speed suffer (whether -a is used 
doesn't have a significant impact)?

Thanks,
Andreas.
Index: quilt/Makefile.in
===================================================================
--- quilt.orig/Makefile.in
+++ quilt/Makefile.in
@@ -80,7 +80,7 @@ SRC +=		$(QUILT_SRC:%=quilt/%)
 DIRT +=		$(QUILT_IN:%=quilt/%)
 
 SCRIPTS_IN :=	patchfns parse-patch inspect dependency-graph edmail \
-		remove-trailing-ws
+		remove-trailing-ws annotate-helper
 
 SCRIPTS_SRC :=	$(SCRIPTS_IN:%=%.in)
 SCRIPTS :=	$(SCRIPTS_IN)
Index: quilt/quilt/annotate.in
===================================================================
--- quilt.orig/quilt/annotate.in
+++ quilt/quilt/annotate.in
@@ -85,7 +85,7 @@ merge_files()
 	exec 4<&-
 }
 
-options=`getopt -o p:h -- "$@"`
+options=`getopt -o ap:h -- "$@"`
 
 if [ $? -ne 0 ]
 then
@@ -97,6 +97,9 @@ eval set -- "$options"
 while true
 do
 	case "$1" in
+	-a)
+		opt_a=-a
+		shift ;;
 	-p)
 		if ! opt_patch=$(find_patch "$2")
 		then
@@ -176,7 +179,7 @@ empty_file ${files[0]} > $template
 		annotation_for "${files[n]}" "${files[n+1]}" $((n+1))
 	done
 	echo w
-) | ed -s $template
+) | @SCRIPTS@/annotate-helper -s $opt_a $template
 merge_files $template "[EMAIL PROTECTED]"
 
 echo
Index: quilt/scripts/annotate-helper.in
===================================================================
--- /dev/null
+++ quilt/scripts/annotate-helper.in
@@ -0,0 +1,59 @@
+#! @PERL@ -w
+
+use FileHandle;
+use Getopt::Std;
+use vars qw($opt_a $opt_s);
+use strict;
+
+getopts('as');
+
+my $filename = shift @ARGV;
+my $fh = new FileHandle("< $filename")
+    or die "$filename: $!\n";
+my @file = <$fh>;
+$fh->close();
+
+while (<>) {
+    my ($a, $b, $c);
+    ($a, $b, $c) = /(\d+)?(?:,(\d+))?([acdw])/
+	or die "parse error\n";
+    if (defined $1) {
+	    $a = $1 - 1;
+	    if (defined $2) {
+		    $b = $2 - 1;
+	    } else {
+		$b = $a;
+	    }
+    }
+    $c = $3;
+    if ($c eq 'w') {
+	$fh = new FileHandle("> $filename")
+	    or die "$filename: $!\n";
+	print $fh @file;
+	$fh->close();
+    } elsif ($c eq 'd') {
+	@file = (@file[0 .. $a-1], @file[$b+1 .. $#file]);
+    } else {
+	my @new;
+	while (<>) {
+	    last if (/^\.$/);
+	    push @new, $_;
+	}
+	if ($c eq 'c') {
+	    if ($opt_a) {
+		for (my $n = 0; $n < @new; $n++) {
+		    chomp $file[$a + $n];
+		    if ($file[$a + $n] eq '') {
+			$file[$a + $n] = $new[$n];
+		    } else {
+			$file[$a + $n] .= "," . $new[$n];
+		    }
+		}
+	    } else {
+		@file = (@file[0 .. $a-1], @new, @file[$b+1 .. $#file]);
+	    }
+	} elsif ($c eq 'a') {
+	    @file = (@file[0 .. $a], @new, @file[$a+1 .. $#file]);
+	}
+    }
+}
Index: quilt/test/annotate.test
===================================================================
--- quilt.orig/test/annotate.test
+++ quilt/test/annotate.test
@@ -43,6 +43,14 @@
 	> 1	patches/patch
 	> 2	patches/patch2
 
+	$ quilt annotate -a foo
+	>	foo
+	> 1	Bar
+	> 1,2	baz
+	>
+	> 1	patches/patch
+	> 2	patches/patch2
+
 	$ quilt new patch3
 	> Patch patches/patch3 is now on top
 
Index: quilt/quilt/annotate.in
===================================================================
--- quilt.orig/quilt/annotate.in
+++ quilt/quilt/annotate.in
@@ -171,11 +171,12 @@ trap "rm -f $template" EXIT
 # by line.
 
 empty_file ${files[0]} > $template
-for ((n = 0; n < [EMAIL PROTECTED]; n++))
-do
-	annotation_for "${files[n]}" "${files[n+1]}" $((n+1))
-done \
-| patch $template
+(	for ((n = 0; n < [EMAIL PROTECTED]; n++))
+	do
+		annotation_for "${files[n]}" "${files[n+1]}" $((n+1))
+	done
+	echo w
+) | ed -s $template
 merge_files $template "[EMAIL PROTECTED]"
 
 echo
_______________________________________________
Quilt-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/quilt-dev

Reply via email to