summaryrefslogtreecommitdiff
path: root/Porting
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2001-08-17 11:47:54 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2001-08-17 11:47:54 +0000
commitf0b5ba41df93ba6703cb6968a5cc3fad069c7ad7 (patch)
tree750035ba905dfd0bd2a99be4f8debb7117a8d80d /Porting
parent6e126ccdf64222c0f9ab183255cb53a8589a1e63 (diff)
downloadperl-f0b5ba41df93ba6703cb6968a5cc3fad069c7ad7.tar.gz
Mail -> change script (pre-alpha)
p4raw-id: //depot/perl@11704
Diffstat (limited to 'Porting')
-rw-r--r--Porting/apply71
1 files changed, 71 insertions, 0 deletions
diff --git a/Porting/apply b/Porting/apply
new file mode 100644
index 0000000000..a0b01cc56e
--- /dev/null
+++ b/Porting/apply
@@ -0,0 +1,71 @@
+#!/usr/bin/perl -w
+my $file = pop(@ARGV);
+my %meta;
+$ENV{'P4PORT'} = 'bactrian:1667';
+$ENV{'P4CLIENT'} = 'camel-linux';
+open(FILE,$file) || die "Cannot open $file:$!";
+while (<FILE>)
+ {
+ if (/^(From|Subject|Date|Message-ID):(.*)$/i)
+ {
+ $meta{lc($1)} = $2;
+ }
+ }
+my @results = `patch @ARGV <$file 2>&1`;
+warn @results;
+my $code = $?;
+warn "$code from patch\n";
+foreach (@results)
+ {
+ if (/patching\s+file\s*(.*?)\s*$/)
+ {
+ push(@edit,$1);
+ }
+ }
+my @have = `p4 have @edit`;
+
+if ($code == 0)
+ {
+ System("p4 edit @edit");
+ open(PIPE,"|p4 change -i") || die "Cannot open pipe to p4:$!";
+ print PIPE "Change: new\n";
+ print PIPE "Description:\n";
+ foreach my $key (qw(Subject From Date Message-Id))
+ {
+ if (exists $meta{lc($key)})
+ {
+ print PIPE "\t$key: ",$meta{lc($key)},"\n";
+ print "$key: ",$meta{lc($key)},"\n";
+ }
+ }
+ print PIPE "Files:\n";
+ foreach (@have)
+ {
+ if (m,^(.*)#,)
+ {
+ print PIPE "\t$1\n"
+ }
+ }
+ close(PIPE);
+ }
+else
+ {
+ if (@edit)
+ {
+ System("p4 revert @edit");
+ }
+ }
+
+sub System
+{
+ my $cmd = join(' ',@_);
+ warn "$cmd\n";
+ if (fork)
+ {
+ wait;
+ }
+ else
+ {
+ _exit(exec $cmd);
+ }
+}