[svk-commit] r2405 - in branches/i18n-fixes: . lib/SVK lib/SVK/Editor lib/SVK/Root

nobody at bestpractical.com nobody at bestpractical.com
Sat Jun 9 16:43:41 EDT 2007


Author: clkao
Date: Sat Jun  9 16:43:41 2007
New Revision: 2405

Added:
   branches/i18n-fixes/t/i18n/
   branches/i18n-fixes/t/i18n/big5dirname.t
   branches/i18n-fixes/t/i18n/checkout.t
Modified:
   branches/i18n-fixes/MANIFEST
   branches/i18n-fixes/lib/SVK/Editor/Diff.pm
   branches/i18n-fixes/lib/SVK/Root/Checkout.pm
   branches/i18n-fixes/lib/SVK/Test.pm

Log:
wip i18n patch from clsung.

Modified: branches/i18n-fixes/MANIFEST
==============================================================================
--- branches/i18n-fixes/MANIFEST	(original)
+++ branches/i18n-fixes/MANIFEST	Sat Jun  9 16:43:41 2007
@@ -285,6 +285,8 @@
 t/copy-escape.t
 t/copy-replace.t
 t/diff/mixed-checkout.t
+t/i18n/big5dirname.t
+t/i18n/checkout.t
 t/mirror/commit-copy.t
 t/mirror/dav-authz.t
 t/mirror/relocate.t

Modified: branches/i18n-fixes/lib/SVK/Editor/Diff.pm
==============================================================================
--- branches/i18n-fixes/lib/SVK/Editor/Diff.pm	(original)
+++ branches/i18n-fixes/lib/SVK/Editor/Diff.pm	Sat Jun  9 16:43:41 2007
@@ -56,7 +56,7 @@
 use base 'SVK::Editor';
 
 use SVK::I18N;
-use autouse 'SVK::Util' => qw( slurp_fh tmpfile mimetype_is_text catfile abs2rel );
+use autouse 'SVK::Util' => qw( slurp_fh tmpfile mimetype_is_text catfile abs2rel from_native);
 
 =head1 NAME
 
@@ -211,8 +211,10 @@
 sub _report_path {
     my ($self, $path) = @_;
 
-    return (defined $self->{report} && length $self->{report})
-	? catfile($self->{report}, $path) : $path;
+    return $path if !(defined $self->{report} && length $self->{report});
+    my $report = $self->{report}; $report = "$report";
+    from_native($report);
+    return catfile($report, $path);
 }
 
 sub close_file {

Modified: branches/i18n-fixes/lib/SVK/Root/Checkout.pm
==============================================================================
--- branches/i18n-fixes/lib/SVK/Root/Checkout.pm	(original)
+++ branches/i18n-fixes/lib/SVK/Root/Checkout.pm	Sat Jun  9 16:43:41 2007
@@ -50,7 +50,7 @@
 # END BPS TAGGED BLOCK }}}
 package SVK::Root::Checkout;
 use strict;
-use SVK::Util qw(abs2rel md5_fh is_symlink);
+use SVK::Util qw(abs2rel md5_fh is_symlink from_native to_native );
 
 use base qw{ Class::Accessor::Fast };
 
@@ -180,7 +180,10 @@
 sub _get_copath {
     my ($self, $path, $pool) = @_;
     # XXX: copath shouldn't be copath_anchor!
-    my $copath = abs2rel($path, $self->path->path_anchor => $self->path->copath);
+    my $copath = $self->path->copath; $copath = "$copath";
+    from_native($copath);
+    $copath = abs2rel($path, $self->path->path_anchor => $copath);
+    to_native($copath);
     my $root;
     ($root, $_[1]) = $self->path->source->root->get_revision_root
 	($path, $self->path->xd->{checkout}->get($copath, 1)->{revision}, $pool);

Modified: branches/i18n-fixes/lib/SVK/Test.pm
==============================================================================
--- branches/i18n-fixes/lib/SVK/Test.pm	(original)
+++ branches/i18n-fixes/lib/SVK/Test.pm	Sat Jun  9 16:43:41 2007
@@ -614,7 +614,7 @@
     open my $fh, '>', $hook or die $!;
     if (IS_WIN32) {
         print $fh "\@rem = '--*-Perl-*--\n";
-        print $fh '@echo off'."\n$^X".' -x -S %0 %*'."\n";
+        print $fh '@echo off'."\n\"$^X\"".' -x -S %0 %*'."\n";
         print $fh 'if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul'."\n";
 	print $fh "goto endofperl\n\@rem ';\n";
     }

Added: branches/i18n-fixes/t/i18n/big5dirname.t
==============================================================================
--- (empty file)
+++ branches/i18n-fixes/t/i18n/big5dirname.t	Sat Jun  9 16:43:41 2007
@@ -0,0 +1,86 @@
+#!/usr/bin/perl -w
+use strict;
+use SVK::Util qw( to_native from_native);
+use SVK::Test;
+#plan skip_all => "Only needed to test on win32" unless IS_WIN32;
+
+use POSIX qw(setlocale LC_CTYPE);
+setlocale (LC_CTYPE, $ENV{LC_CTYPE} = 'zh_TW.Big5')
+    or plan skip_all => 'cannot set locale to zh_TW.Big5';
+
+plan tests => 8;
+our $output;
+
+my $big5dir = "\x{b7}\x{7c}\x{b1}\x{e0}"; # meeting , contains a '|' character
+my $file = "\x{a4}\x{a4}\x{a4}\x{e5}.txt"; # Chinese
+my $file2 = "\x{b6}\x{7d}\x{b7}\x{7c}.txt"; # meeting
+mkpath ["t/checkout/filenames/$big5dir"], 0, 0700 unless -d "t/checkout/filenames/$big5dir";
+
+my ($xd, $svk) = build_test('dirname_enc');
+my ($copath, $corpath) = get_copath ("filenames/$big5dir");
+my ($repospath, $path, $repos) = $xd->find_repos ('/dirname_enc/', 1);
+sub copath { SVK::Path::Checkout->copath($copath, @_) }
+
+$svk->checkout ('//', $copath);
+
+my $filename = $file;
+overwrite_file ("$copath/$file", "new file to add\n");
+overwrite_file ("$copath/$file2", "new file2 to add\n");
+chdir($copath);
+
+is_output ($svk, 'add', [ $file],
+           ['A   '.$file]);
+is_output ($svk, 'add', [ $file2],
+           ['A   '.$file2]);
+chdir('..');
+is_output($svk, 'ci', [-m => 'commit single checkout', $big5dir],
+          ['Committed revision 1.']);
+chdir($big5dir);
+append_file($file, "change single file\n");
+
+from_native($filename);
+append_file($file, "utf8 filename: $filename\n");
+is_output($svk, 'diff', [$file],
+          ['=== '.$filename,
+           '==================================================================',
+           "--- $file\t(revision 1)",
+           "+++ $file\t(local)",
+           '@@ -1 +1,3 @@',
+           ' new file to add',
+           '+change single file',
+           '+utf8 filename: '.$filename,
+          ]);
+is_output($svk, 'ci', [-m => 'commit single checkout', $file],
+          ['Committed revision 2.']);
+
+chdir ('../../../../');
+$svk->update ('-r', 1, $copath);
+chdir($copath);
+is_file_content ("$file", "new file to add\n");
+
+overwrite_file ("$file",
+                "hihi\n");
+our $answer = [ 'd', 'y' ];
+chdir ('../../../../');
+$svk->update ($copath); # XXX use is_ouptut to compare conflict diff header
+warn $output;
+ok ($output =~ m/1 conflict found\./, 'conflict');
+
+$svk->revert ($copath);
+$svk->resolved ($copath);
+$svk->update ($copath); # XXX use is_ouptut to compare conflict diff header
+warn $output;
+append_file("$copath/$file2", "big5 filename: $file2\n");
+chdir($copath);
+chdir('..');
+$filename = "$big5dir/$file2";
+from_native($filename);
+is_output($svk, 'diff', ["$big5dir/$file2"],
+          ['=== '.$filename,
+           '==================================================================',
+           "--- $big5dir/$file2\t(revision 2)",
+           "+++ $big5dir/$file2\t(local)",
+           '@@ -1 +1,2 @@',
+           ' new file2 to add',
+           '+big5 filename: '.$file2,
+          ]);

Added: branches/i18n-fixes/t/i18n/checkout.t
==============================================================================
--- (empty file)
+++ branches/i18n-fixes/t/i18n/checkout.t	Sat Jun  9 16:43:41 2007
@@ -0,0 +1,64 @@
+#!/usr/bin/perl -w
+use strict;
+use SVK::Util qw( is_executable to_native from_native);
+use SVK::Test;
+#plan skip_all => "Only needed to test on win32" unless IS_WIN32;
+
+use POSIX qw(setlocale LC_CTYPE);
+setlocale (LC_CTYPE, $ENV{LC_CTYPE} = 'zh_TW.Big5')
+    or plan skip_all => 'cannot set locale to zh_TW.Big5';
+
+plan tests => 6;
+our $output;
+
+mkpath ["t/checkout/filenames"], 0, 0700 unless -d "t/checkout/filenames";
+
+my ($xd, $svk) = build_test('filename_enc');
+my ($copath, $corpath) = get_copath ('filenames');
+my ($repospath, $path, $repos) = $xd->find_repos ('/filename_enc/', 1);
+sub copath { SVK::Path::Checkout->copath($copath, @_) }
+
+$svk->checkout ('//', $copath);
+
+my $file = "\x{a4}\x{a4}\x{a4}\x{e5}\x{c0}\x{c9}.txt";
+my $filename = $file;
+overwrite_file ("$copath/$file", "new file to add\n");
+chdir($copath);
+
+is_output ($svk, 'add', [$file],
+           ['A   '.$file]);
+is_output($svk, 'ci', [-m => 'commit single checkout', $file],
+          ['Committed revision 1.']);
+append_file($file, "change single file\n");
+
+from_native($filename);
+append_file($file, "utf8 filename: $filename\n");
+is_output($svk, 'diff', [$file],
+          ['=== '.$filename,
+           '==================================================================',
+           "--- $file\t(revision 1)",
+           "+++ $file\t(local)",
+           '@@ -1 +1,3 @@',
+           ' new file to add',
+           '+change single file',
+           '+utf8 filename: '.$filename,
+          ]);
+is_output($svk, 'ci', [-m => 'commit single checkout', $file],
+          ['Committed revision 2.']);
+
+chdir ('..');
+chdir ('..');
+chdir ('..');
+$svk->update ('-r', 1, $copath);
+is_file_content (copath("$file"), "new file to add\n");
+
+overwrite_file (copath("$file"),
+                "hihi\n");
+$ENV{SVKRESOLVE} = undef;
+our $answer = [ 'd', 'y' ];
+$svk->update ($copath); # XXX use is_ouptut to compare conflict diff header
+warn $output;
+ok ($output =~ m/1 conflict found\./, 'conflict');
+
+$svk->revert ($copath);
+$svk->resolved ($copath);


More information about the svk-commit mailing list