subversionのコミットメールスクリプト(commit-email.pl)を日本語対応に

Subversionコミットメール日本語パッチ

--- commit-email.pl	2004-06-24 22:13:40.000000000 +0900
+++ commit-email-jp.pl	2004-06-26 23:00:12.000000000 +0900
@@ -36,6 +36,7 @@
 
 use strict;
 use Carp;
+use Jcode;
 
 ######################################################################
 # Configuration section.
@@ -220,7 +221,9 @@
 my $author = shift @svnlooklines;
 my $date = shift @svnlooklines;
 shift @svnlooklines;
-my @log = map { "$_\n" } @svnlooklines;
+my @log_raw = map { "$_\n" } @svnlooklines;
+my @log_utf8 = map { decode_commit_log($_) } @log_raw;
+my @log = map { Jcode->new($_, 'utf8')->jis } @log_utf8;
 
 # Figure out what directories have changed using svnlook.
 my @dirschanged = &read_from_process($svnlook, 'dirs-changed', $repos, 
@@ -277,8 +280,9 @@
 
 # Get the diff from svnlook.
 my @no_diff_deleted = $no_diff_deleted ? ('--no-diff-deleted') : ();
-my @difflines = &read_from_process($svnlook, 'diff', $repos,
+my @difflines_raw = &read_from_process($svnlook, 'diff', $repos,
                                    '-r', $rev, @no_diff_deleted);
+my @difflines = map { Jcode->new($_)->jis } @difflines_raw;
 
 ######################################################################
 # Modified directory name collapsing.
@@ -441,9 +445,9 @@
     # 
     # Basically: adding/tweaking the content-type is nice, but don't
     # think that is the proper solution.
-    push(@head, "Content-Type: text/plain; charset=UTF-8\n");
-    push(@head, "Content-Transfer-Encoding: 8bit\n");
+    push(@head, "Content-Type: text/plain; charset=\"iso-2022-jp\"\n");
+    push(@head, "Content-Transfer-Encoding: 7bit\n");
    
     push(@head, "\n");
 
     if ($sendmail =~ /\w/ and @email_addresses)
@@ -589,3 +593,10 @@
       return @output;
     }
 }
+
+sub decode_commit_log {
+  my ($str) = @_;
+  $str =~ s/\?\\(\d{3})/pack('C', $1)/eg;
+  return $str;
+}