r55998 - in /scripts: patchedit t/patchedit/01_patchedit.t t/patchedit/dpatch-meta.ok t/patchedit/dpatch-meta.ok-o t/patchedit/dpatch-meta.orig t/patchedit/dpatch-no-meta.ok t/patchedit/dpatch-no-meta.ok-o t/patchedit/dpatch-no-meta.orig

jozef-guest at users.alioth.debian.org jozef-guest at users.alioth.debian.org
Mon Apr 12 09:25:40 UTC 2010


Author: jozef-guest
Date: Mon Apr 12 09:25:30 2010
New Revision: 55998

URL: http://svn.debian.org/wsvn/?sc=1&rev=55998
Log:
handle patches with comments (dpatch)

Added:
    scripts/t/patchedit/dpatch-meta.ok
    scripts/t/patchedit/dpatch-meta.ok-o
    scripts/t/patchedit/dpatch-meta.orig
    scripts/t/patchedit/dpatch-no-meta.ok
    scripts/t/patchedit/dpatch-no-meta.ok-o
    scripts/t/patchedit/dpatch-no-meta.orig
Modified:
    scripts/patchedit
    scripts/t/patchedit/01_patchedit.t

Modified: scripts/patchedit
URL: http://svn.debian.org/wsvn/scripts/patchedit?rev=55998&op=diff
==============================================================================
--- scripts/patchedit (original)
+++ scripts/patchedit Mon Apr 12 09:25:30 2010
@@ -85,7 +85,6 @@
 
  * preserve the extra fields
  * preserve the order of the fields
- * handle patches with comments (dpatch)
 
 =head1 COPYRIGHT AND LICENSE
 
@@ -201,16 +200,22 @@
 	my $patch_content = $patch_struct->{fields};
 	
 	open(my $patch_fh, '>', $patch) or die 'failed to open "'.$patch.'" - '.$!;
-	print $patch_fh $patch_struct->{head} if $patch_struct->{head};
+	print $patch_fh $patch_struct->{header}{head} if $patch_struct->{header};
 	foreach my $key (@standard_fields) {
-		print $patch_fh $key, ': ', $patch_content->{$key}
-			if $patch_content->{$key};
+		if ($patch_content->{$key}) {
+			print $patch_fh '# '
+				if $patch_struct->{header};
+			print $patch_fh $key, ': ', $patch_content->{$key};
+		}
 		if ($key eq 'Bug') {
 			foreach my $key (grep { m/Bug-/ } sort keys %{$patch_content}) {
+				print $patch_fh '# '
+					if $patch_struct->{header};
 				print $patch_fh $key, ': ', $patch_content->{$key};
 			}
 		}
 	}
+	print $patch_fh $patch_struct->{header}{tail} if $patch_struct->{header};
 	print $patch_fh "\n";
 	print $patch_fh $patch_struct->{body};
 	close($patch_fh);
@@ -275,7 +280,8 @@
 		$patch_content = _read_patch_classic($patch_fh);
 	}
 	else {
-		die "Dpatch is not yet supported";
+		$patch_content = _read_patch_dpatch($patch_fh);
+		
 	}
 	close($patch_fh);
 
@@ -286,7 +292,7 @@
 	my ($patch_fh) = @_;
 
 	my %patch_content = (
-		header => '',
+		header => undef,
 		body   => '',
 		fields => {},
 	);
@@ -333,12 +339,17 @@
 	my ($patch_fh) = @_;
 
 	my %patch_content = (
-		header => '',
+		header => {
+			head => scalar <$patch_fh>,
+			tail => '',
+		},
 		body   => '',
 		fields => {},
 	);
+
 	my $key = '';
 	my $header_end = 0;
+	my $spaces = '--- ';
 	while (my $line = <$patch_fh>) {
 
 		if (! $header_end and $line =~ /^--- /) {
@@ -352,22 +363,30 @@
 			next;
 		}
 
-		if ($line =~ m/^#+ (\S+) : \s+ (.+) $/xms) {
+		if ($line =~ m/^ \# (\s+) (\S+) : \s+ (.+) $/xms) {
 			# Starting a new field
 			my $value;
-			($key, $value) = ($1, $2);
+			($spaces, $key, $value) = ($1, $2, $3);
+			die $line if not $key;
 			$patch_content{fields}{$key} = $value;
 			next;
 		}
 
-		if ($line =~ m/^#+ / or $key eq 'Subject') {
+		if ($line =~ m/^ \# $spaces \s+ /xms or $key eq 'Subject') {
 			# Previous field not over
 			$patch_content{fields}{$key} .= $line;
 			next;
 		}
 
-		# Still in the header
-		$patch_content{header} .= $line;
+		if ($line =~ m/^ \# /xms) {
+			# Still in the header
+			$patch_content{header}{$key ? 'tail' : 'head'} .= $line;
+			next;
+		}
+
+		# End of header but not yet the start of patch (before ---) 
+		$header_end = 1;
+		$patch_content{body} .= $line;
 	}
 	
 	# remove the first empty line (will be added automaticaly)

Modified: scripts/t/patchedit/01_patchedit.t
URL: http://svn.debian.org/wsvn/scripts/t/patchedit/01_patchedit.t?rev=55998&op=diff
==============================================================================
--- scripts/t/patchedit/01_patchedit.t (original)
+++ scripts/t/patchedit/01_patchedit.t Mon Apr 12 09:25:30 2010
@@ -26,6 +26,8 @@
 		with-meta-and-extra-fields
 		with-utf8-meta
 		subject
+		dpatch-no-meta
+		dpatch-meta
 	);
 	plan tests => @tests * 2;
 
@@ -36,7 +38,16 @@
 			local @ARGV = (($sub_type ? $sub_type : ()), '-f', 'edit', 't/patchedit/'.$type);
 			main();
 			my $fixed          = read_file('t/patchedit/'.$type);
-			my $should_be      = read_file('t/patchedit/'.$type.'.ok'.$sub_type);
+			
+			my $should_be_filename = 't/patchedit/'.$type.'.ok'.$sub_type;
+			if (not -f $should_be_filename) {
+				SKIP: {
+					skip $should_be_filename.' file not found, skipping test', 1;
+				};
+				next;
+			}
+			
+			my $should_be      = read_file($should_be_filename);
 			eq_or_diff($fixed, $should_be, 'fixing '.$type.($sub_type ? ' '.$sub_type : ''));
 			unlink('t/patchedit/'.$type);
 		}

Added: scripts/t/patchedit/dpatch-meta.ok
URL: http://svn.debian.org/wsvn/scripts/t/patchedit/dpatch-meta.ok?rev=55998&op=file
==============================================================================
--- scripts/t/patchedit/dpatch-meta.ok (added)
+++ scripts/t/patchedit/dpatch-meta.ok Mon Apr 12 09:25:30 2010
@@ -1,0 +1,33 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 78_kfbsd_tab.dpatch by Petr Salinger <Petr.Salinger at seznam.cz>
+#
+# Description: fix build problem on kfreebsd
+#              one more line of desc
+# Origin: testing
+# Last-Update: 2004-02-02
+#
+## DP: kfreebsd
+
+ at DPATCH@
+diff -urNad coreutils-7.2~/src/stty.c coreutils-7.2/src/stty.c
+--- coreutils-7.2~/src/stty.c	2009-03-29 13:43:41.000000000 -0400
++++ coreutils-7.2/src/stty.c	2009-04-07 21:11:35.096288547 -0400
+@@ -279,10 +279,18 @@
+   {"cr0", output, SANE_SET, CR0, CRDLY},
+ #endif
+ #ifdef TABDLY
++#ifdef TAB3
+   {"tab3", output, SANE_UNSET, TAB3, TABDLY},
++#endif
++#ifdef TAB2
+   {"tab2", output, SANE_UNSET, TAB2, TABDLY},
++#endif
++#ifdef TAB1
+   {"tab1", output, SANE_UNSET, TAB1, TABDLY},
++#endif
++#ifdef TAB0
+   {"tab0", output, SANE_SET, TAB0, TABDLY},
++#endif
+ #else
+ # ifdef OXTABS
+   {"tab3", output, SANE_UNSET, OXTABS, 0},

Added: scripts/t/patchedit/dpatch-meta.ok-o
URL: http://svn.debian.org/wsvn/scripts/t/patchedit/dpatch-meta.ok-o?rev=55998&op=file
==============================================================================
--- scripts/t/patchedit/dpatch-meta.ok-o (added)
+++ scripts/t/patchedit/dpatch-meta.ok-o Mon Apr 12 09:25:30 2010
@@ -1,0 +1,37 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 78_kfbsd_tab.dpatch by Petr Salinger <Petr.Salinger at seznam.cz>
+#
+# Description: fix build problem on kfreebsd
+#              one more line of desc
+# Origin: testing
+# Bug: *** FIXME ***
+# Forwarded: *** FIXME ***
+# Author: *** FIXME ***
+# Reviewed-by: *** FIXME ***
+# Last-Update: 2004-02-02
+#
+## DP: kfreebsd
+
+ at DPATCH@
+diff -urNad coreutils-7.2~/src/stty.c coreutils-7.2/src/stty.c
+--- coreutils-7.2~/src/stty.c	2009-03-29 13:43:41.000000000 -0400
++++ coreutils-7.2/src/stty.c	2009-04-07 21:11:35.096288547 -0400
+@@ -279,10 +279,18 @@
+   {"cr0", output, SANE_SET, CR0, CRDLY},
+ #endif
+ #ifdef TABDLY
++#ifdef TAB3
+   {"tab3", output, SANE_UNSET, TAB3, TABDLY},
++#endif
++#ifdef TAB2
+   {"tab2", output, SANE_UNSET, TAB2, TABDLY},
++#endif
++#ifdef TAB1
+   {"tab1", output, SANE_UNSET, TAB1, TABDLY},
++#endif
++#ifdef TAB0
+   {"tab0", output, SANE_SET, TAB0, TABDLY},
++#endif
+ #else
+ # ifdef OXTABS
+   {"tab3", output, SANE_UNSET, OXTABS, 0},

Added: scripts/t/patchedit/dpatch-meta.orig
URL: http://svn.debian.org/wsvn/scripts/t/patchedit/dpatch-meta.orig?rev=55998&op=file
==============================================================================
--- scripts/t/patchedit/dpatch-meta.orig (added)
+++ scripts/t/patchedit/dpatch-meta.orig Mon Apr 12 09:25:30 2010
@@ -1,0 +1,33 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 78_kfbsd_tab.dpatch by Petr Salinger <Petr.Salinger at seznam.cz>
+#
+# Description: fix build problem on kfreebsd
+#              one more line of desc
+# Origin: testing
+# Last-Update: 2004-02-02
+#
+## DP: kfreebsd
+
+ at DPATCH@
+diff -urNad coreutils-7.2~/src/stty.c coreutils-7.2/src/stty.c
+--- coreutils-7.2~/src/stty.c	2009-03-29 13:43:41.000000000 -0400
++++ coreutils-7.2/src/stty.c	2009-04-07 21:11:35.096288547 -0400
+@@ -279,10 +279,18 @@
+   {"cr0", output, SANE_SET, CR0, CRDLY},
+ #endif
+ #ifdef TABDLY
++#ifdef TAB3
+   {"tab3", output, SANE_UNSET, TAB3, TABDLY},
++#endif
++#ifdef TAB2
+   {"tab2", output, SANE_UNSET, TAB2, TABDLY},
++#endif
++#ifdef TAB1
+   {"tab1", output, SANE_UNSET, TAB1, TABDLY},
++#endif
++#ifdef TAB0
+   {"tab0", output, SANE_SET, TAB0, TABDLY},
++#endif
+ #else
+ # ifdef OXTABS
+   {"tab3", output, SANE_UNSET, OXTABS, 0},

Added: scripts/t/patchedit/dpatch-no-meta.ok
URL: http://svn.debian.org/wsvn/scripts/t/patchedit/dpatch-no-meta.ok?rev=55998&op=file
==============================================================================
--- scripts/t/patchedit/dpatch-no-meta.ok (added)
+++ scripts/t/patchedit/dpatch-no-meta.ok Mon Apr 12 09:25:30 2010
@@ -1,0 +1,31 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 78_kfbsd_tab.dpatch by Petr Salinger <Petr.Salinger at seznam.cz>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: fix build problem on kfreebsd
+# Description: *** FIXME ***
+# Origin: *** FIXME ***
+
+ at DPATCH@
+diff -urNad coreutils-7.2~/src/stty.c coreutils-7.2/src/stty.c
+--- coreutils-7.2~/src/stty.c	2009-03-29 13:43:41.000000000 -0400
++++ coreutils-7.2/src/stty.c	2009-04-07 21:11:35.096288547 -0400
+@@ -279,10 +279,18 @@
+   {"cr0", output, SANE_SET, CR0, CRDLY},
+ #endif
+ #ifdef TABDLY
++#ifdef TAB3
+   {"tab3", output, SANE_UNSET, TAB3, TABDLY},
++#endif
++#ifdef TAB2
+   {"tab2", output, SANE_UNSET, TAB2, TABDLY},
++#endif
++#ifdef TAB1
+   {"tab1", output, SANE_UNSET, TAB1, TABDLY},
++#endif
++#ifdef TAB0
+   {"tab0", output, SANE_SET, TAB0, TABDLY},
++#endif
+ #else
+ # ifdef OXTABS
+   {"tab3", output, SANE_UNSET, OXTABS, 0},

Added: scripts/t/patchedit/dpatch-no-meta.ok-o
URL: http://svn.debian.org/wsvn/scripts/t/patchedit/dpatch-no-meta.ok-o?rev=55998&op=file
==============================================================================
--- scripts/t/patchedit/dpatch-no-meta.ok-o (added)
+++ scripts/t/patchedit/dpatch-no-meta.ok-o Mon Apr 12 09:25:30 2010
@@ -1,0 +1,36 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 78_kfbsd_tab.dpatch by Petr Salinger <Petr.Salinger at seznam.cz>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: fix build problem on kfreebsd
+# Description: *** FIXME ***
+# Origin: *** FIXME ***
+# Bug: *** FIXME ***
+# Forwarded: *** FIXME ***
+# Author: *** FIXME ***
+# Reviewed-by: *** FIXME ***
+# Last-Update: 2004-02-02
+
+ at DPATCH@
+diff -urNad coreutils-7.2~/src/stty.c coreutils-7.2/src/stty.c
+--- coreutils-7.2~/src/stty.c	2009-03-29 13:43:41.000000000 -0400
++++ coreutils-7.2/src/stty.c	2009-04-07 21:11:35.096288547 -0400
+@@ -279,10 +279,18 @@
+   {"cr0", output, SANE_SET, CR0, CRDLY},
+ #endif
+ #ifdef TABDLY
++#ifdef TAB3
+   {"tab3", output, SANE_UNSET, TAB3, TABDLY},
++#endif
++#ifdef TAB2
+   {"tab2", output, SANE_UNSET, TAB2, TABDLY},
++#endif
++#ifdef TAB1
+   {"tab1", output, SANE_UNSET, TAB1, TABDLY},
++#endif
++#ifdef TAB0
+   {"tab0", output, SANE_SET, TAB0, TABDLY},
++#endif
+ #else
+ # ifdef OXTABS
+   {"tab3", output, SANE_UNSET, OXTABS, 0},

Added: scripts/t/patchedit/dpatch-no-meta.orig
URL: http://svn.debian.org/wsvn/scripts/t/patchedit/dpatch-no-meta.orig?rev=55998&op=file
==============================================================================
--- scripts/t/patchedit/dpatch-no-meta.orig (added)
+++ scripts/t/patchedit/dpatch-no-meta.orig Mon Apr 12 09:25:30 2010
@@ -1,0 +1,29 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 78_kfbsd_tab.dpatch by Petr Salinger <Petr.Salinger at seznam.cz>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: fix build problem on kfreebsd
+
+ at DPATCH@
+diff -urNad coreutils-7.2~/src/stty.c coreutils-7.2/src/stty.c
+--- coreutils-7.2~/src/stty.c	2009-03-29 13:43:41.000000000 -0400
++++ coreutils-7.2/src/stty.c	2009-04-07 21:11:35.096288547 -0400
+@@ -279,10 +279,18 @@
+   {"cr0", output, SANE_SET, CR0, CRDLY},
+ #endif
+ #ifdef TABDLY
++#ifdef TAB3
+   {"tab3", output, SANE_UNSET, TAB3, TABDLY},
++#endif
++#ifdef TAB2
+   {"tab2", output, SANE_UNSET, TAB2, TABDLY},
++#endif
++#ifdef TAB1
+   {"tab1", output, SANE_UNSET, TAB1, TABDLY},
++#endif
++#ifdef TAB0
+   {"tab0", output, SANE_SET, TAB0, TABDLY},
++#endif
+ #else
+ # ifdef OXTABS
+   {"tab3", output, SANE_UNSET, OXTABS, 0},




More information about the Pkg-perl-cvs-commits mailing list