[svk-commit] r2151 - in branches/svk-logging/lib/SVK: Command

stig at bestpractical.com stig at bestpractical.com
Thu Nov 16 11:32:45 EST 2006


Author: stig
Date: Thu Nov 16 11:32:45 2006
New Revision: 2151

Modified:
   branches/svk-logging/lib/SVK/Command.pm
   branches/svk-logging/lib/SVK/Command/Cmerge.pm
   branches/svk-logging/lib/SVK/Command/Commit.pm
   branches/svk-logging/lib/SVK/Command/Copy.pm
   branches/svk-logging/lib/SVK/Command/Log.pm
   branches/svk-logging/lib/SVK/Command/Mirror.pm
   branches/svk-logging/lib/SVK/Command/Patch.pm
   branches/svk-logging/lib/SVK/Command/Propset.pm
   branches/svk-logging/lib/SVK/Command/Revert.pm
   branches/svk-logging/lib/SVK/Command/Smerge.pm
   branches/svk-logging/lib/SVK/Command/Sync.pm
   branches/svk-logging/lib/SVK/Command/Update.pm

Log:
use SVK::Logger a few more places.

Modified: branches/svk-logging/lib/SVK/Command.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Command.pm	(original)
+++ branches/svk-logging/lib/SVK/Command.pm	Thu Nov 16 11:32:45 2006
@@ -4,6 +4,7 @@
 use SVK::Version;  our $VERSION = $SVK::VERSION;
 use Getopt::Long qw(:config no_ignore_case bundling);
 
+use SVK::Logger;
 use SVK::Util qw( get_prompt abs2rel abs_path is_uri catdir bsd_glob from_native
 		  find_svm_source $SEP IS_WIN32 catdepot traverse_history);
 use SVK::I18N;
@@ -366,7 +367,7 @@
     die loc ("URI not allowed here: %1.\n", $no_new_mirror)
 	if $no_new_mirror;
 
-    print loc("New URI encountered: %1\n", $uri);
+    $logger->info(loc("New URI encountered: %1\n", $uri));
 
     my $depots = join('|', map quotemeta, sort keys %$map);
     my ($base_uri, $rel_uri);
@@ -988,7 +989,7 @@
 
 	my $target = $self->arg_depotpath ($path);
 	last if $allow_exist or $target->root->check_path ($target->path) == $SVN::Node::none;
-	print loc ("Path %1 already exists.\n", $path);
+	$logger->warn(loc ("Path %1 already exists.", $path));
     }
 
     return $path;

Modified: branches/svk-logging/lib/SVK/Command/Cmerge.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Command/Cmerge.pm	(original)
+++ branches/svk-logging/lib/SVK/Command/Cmerge.pm	Thu Nov 16 11:32:45 2006
@@ -5,6 +5,7 @@
 use base qw( SVK::Command::Merge SVK::Command::Copy SVK::Command::Propset );
 use SVK::XD;
 use SVK::I18N;
+use SVK::Logger;
 use SVK::Editor::Combine;
 use SVK::Inspector::Compat;
 
@@ -29,8 +30,8 @@
     if ($0 =~ /svk$/) { 
         # Only warn about deprecation if the user is running svk. 
         # (Don't warn when running tests)                 
-        print loc("%1 cmerge is deprecated, pending improvements to the Subversion API",$0) ."\n";
-        print loc("'Use %1 merge -c' to obtain similar functionality.",$0)."\n\n";
+        $logger->warn(loc("%1 cmerge is deprecated, pending improvements to the Subversion API",$0));
+        $logger->warn(loc("'Use %1 merge -c' to obtain similar functionality.",$0)."\n");
     }
     my @revlist = $self->parse_revlist($src);
     for my $r (@revlist) {
@@ -61,8 +62,8 @@
     my $inspector = SVK::Inspector::Compat->new({$ceditor->callbacks});
     for (@revlist) {
 	my ($fromrev, $torev) = @$_;
-	print loc("Merging with base %1 %2: applying %3 %4:%5.\n",
-		  @{$base}{qw/path revision/}, $src->{path}, $fromrev, $torev);
+	$logger->info(loc("Merging with base %1 %2: applying %3 %4:%5.",
+		  @{$base}{qw/path revision/}, $src->{path}, $fromrev, $torev));
 
 	SVK::Merge->new (%$self, repos => $repos,
 			 base => $src->new (revision => $fromrev),
@@ -80,7 +81,7 @@
 				    ('file://' . $src->depot->repospath,
 				     $tmpbranch,
 				     $ENV{USER}, "merge $self->{chgspec} from $src->{path}",
-				     sub { print loc("Committed revision %1.\n", $_[0]) })
+				     sub { $logger->info(loc("Committed revision %1.", $_[0])) })
 				  ]),
 		      $fs->youngest_rev);
     my $newrev = $fs->youngest_rev;

Modified: branches/svk-logging/lib/SVK/Command/Commit.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Command/Commit.pm	(original)
+++ branches/svk-logging/lib/SVK/Command/Commit.pm	Thu Nov 16 11:32:45 2006
@@ -126,7 +126,7 @@
     local $@;
     my ($fh, $file) = tmpfile ('commit', DIR => '', TEXT => 1, UNLINK => 0);
     print $fh $self->{message};
-    print loc ("Commit message saved in %1.\n", $file);
+    $logger->warn(loc ("Commit message saved in %1.", $file));
 }
 
 # Return the editor according to copath, path, and is_mirror (path)
@@ -136,7 +136,7 @@
     require SVK::Patch;
     my ($m);
     if (($m) = $target->is_mirrored) {
-	print loc("Patching locally against mirror source %1.\n", $m->url);
+	$logger->info(loc("Patching locally against mirror source %1.", $m->url));
     }
     die loc ("Illegal patch name: %1.\n", $self->{patch})
 	if $self->{patch} =~ m!/!;
@@ -165,7 +165,7 @@
     my ($self, $callback) = @_;
 
     return sub {
-	print loc("Committed revision %1.\n", $_[0]);
+	$logger->info(loc("Committed revision %1.", $_[0]));
 	$callback->(@_) if $callback,
     }
 }
@@ -180,13 +180,13 @@
         && !$self->{direct}
         && ( my $m = $target->is_mirrored ) ) {
         if ( $self->{check_only} ) {
-            print loc( "Checking locally against mirror source %1.\n", $m->url )
+            $logger->info(loc( "Checking locally against mirror source %1.", $m->url ))
 		unless $self->{incremental};
         }
         else {
-            print loc("Commit into mirrored path: merging back directly.\n")
+            $logger->warn(loc("Commit into mirrored path: merging back directly."))
                 if ref($self) eq __PACKAGE__;    # XXX: output compat
-            print loc( "Merging back to mirror source %1.\n", $m->url );
+            $logger->info(loc( "Merging back to mirror source %1.", $m->url ));
         }
     }
     else {
@@ -558,8 +558,8 @@
 	  send_delta => !$cb{send_fulltext},
 	  nodelay => $cb{send_fulltext},
 	  $self->exclude_mirror ($target),
-	  cb_exclude => sub { print loc ("%1 is a mirrored path, please commit separately.\n",
-					 abs2rel ($_[1], $target->copath => $target->report)) },
+	  cb_exclude => sub { $logger->error(loc ("%1 is a mirrored path, please commit separately.",
+					 abs2rel ($_[1], $target->copath => $target->report))) },
 	  $self->{import} ?
 	  ( auto_add => 1,
 	    obstruct_as_replace => 1,

Modified: branches/svk-logging/lib/SVK/Command/Copy.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Command/Copy.pm	(original)
+++ branches/svk-logging/lib/SVK/Command/Copy.pm	Thu Nov 16 11:32:45 2006
@@ -4,6 +4,7 @@
 use base qw( SVK::Command::Mkdir );
 use SVK::Util qw( get_anchor get_prompt abs2rel splitdir is_uri make_path );
 use SVK::I18N;
+use SVK::Logger;
 
 sub options {
     ($_[0]->SUPER::options,
@@ -154,7 +155,7 @@
     return loc("Different depots.\n") unless $dst->same_repos(@src);
     my $m = $self->under_mirror($dst);
     if ( $m && !$dst->same_source(@src) ) {
-        print loc("You are trying to copy across different mirrors.\n");
+        $logger->error(loc("You are trying to copy across different mirrors."));
         die loc( "Try create an empty directory %1, and run smerge --baseless %2 %3.\n",
             $dst->report, $src[0]->report, $dst->report )
           if $#src == 0 && $dst->isa('SVK::Path');
@@ -179,7 +180,7 @@
 		    die loc("Invalid argument: copying directory %1 into itself.\n", $_->report);
 		}
 		if ($_->path_anchor eq $cpdst->path_anchor) {
-		    print loc("Ignoring %1 as source.\n", $_->report);
+		    $logger->warn(loc("Ignoring %1 as source.", $_->report));
 		    next;
 		}
 		$cpdst->descend ($_->path_anchor =~ m|/([^/]+)/?$|)

Modified: branches/svk-logging/lib/SVK/Command/Log.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Command/Log.pm	(original)
+++ branches/svk-logging/lib/SVK/Command/Log.pm	Thu Nov 16 11:32:45 2006
@@ -7,6 +7,7 @@
 use SVK::I18N;
 use SVK::Util qw( traverse_history get_encoding reformat_svn_date );
 use List::Util qw(max min);
+use SVK::Logger;
 
 sub options {
     (
@@ -57,7 +58,7 @@
     # establish the output argument (presentation filter)
     my ( $presentation_filter, $filter_xml ) = @{$self}{qw/present_filter xml/};
     if ($filter_xml) {
-        print loc("Ignoring --output $presentation_filter. Using --xml.\n")
+        $logger->warn(loc("Ignoring --output $presentation_filter. Using --xml."))
             if $presentation_filter;
         $presentation_filter = 'xml';
     }
@@ -80,7 +81,7 @@
     my $get_remoterev = _log_remote_rev($target);
 
     if ($target->revision < max ($fromrev, $torev)) {
-	print loc ("Revision too large, show log from %1.\n", $target->revision);
+	$logger->warn(loc ("Revision too large, show log from %1.", $target->revision));
 	$fromrev = min ($target->revision, $fromrev);
 	$torev = min ($target->revision, $torev);
     }

Modified: branches/svk-logging/lib/SVK/Command/Mirror.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Command/Mirror.pm	(original)
+++ branches/svk-logging/lib/SVK/Command/Mirror.pm	Thu Nov 16 11:32:45 2006
@@ -161,6 +161,7 @@
 use base qw(SVK::Command::Mirror);
 use SVK::Util qw( traverse_history get_prompt );
 use SVK::I18N;
+use SVK::Logger;
 
 use constant narg => 1;
 
@@ -187,9 +188,9 @@
         callback    => sub {
             $rev = $_[1];
             $firstrev ||= $rev;
-            print loc("Analyzing revision %1...\n", $rev),
+            $logger->info(loc("Analyzing revision %1...\n", $rev),
                   ('-' x 70),"\n",
-                  $fs->revision_prop ($rev, 'svn:log'), "\n";
+                  $fs->revision_prop ($rev, 'svn:log'));
 
             if ( $headrev = $fs->revision_prop ($rev, 'svm:headrev') ) {
                 ($uuid, $rrev) = split(/[:\n]/, $headrev);
@@ -210,7 +211,7 @@
     }
 
     if (!$skipped) {
-        print loc("No need to revert; it is already the head revision.\n");
+        $logger->warn(loc("No need to revert; it is already the head revision."));
         return;
     }
 

Modified: branches/svk-logging/lib/SVK/Command/Patch.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Command/Patch.pm	(original)
+++ branches/svk-logging/lib/SVK/Command/Patch.pm	Thu Nov 16 11:32:45 2006
@@ -95,14 +95,15 @@
 
 use base qw/SVK::Command::Patch::FileRequired/;
 use SVK::I18N;
+use SVK::Logger;
 
 sub run {
     my ($self, $patch, $not_applicable) = @_;
 
     return $not_applicable if $not_applicable;
     if (my $conflicts = $patch->apply (1)) {
-	print loc("%*(%1,conflict) found.\n", $conflicts);
-	print loc("Please do a merge to resolve conflicts and regen the patch.\n");
+	$logger->error(loc("%*(%1,conflict) found.", $conflicts));
+	$logger->error(loc("Please do a merge to resolve conflicts and regen the patch."));
     }
 
     return;

Modified: branches/svk-logging/lib/SVK/Command/Propset.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Command/Propset.pm	(original)
+++ branches/svk-logging/lib/SVK/Command/Propset.pm	Thu Nov 16 11:32:45 2006
@@ -6,6 +6,7 @@
 use SVK::Util qw ( abs2rel );
 use SVK::XD;
 use SVK::I18N;
+use SVK::Logger;
 
 sub options {
     ($_[0]->SUPER::options,
@@ -38,11 +39,11 @@
         $fs->change_rev_prop ($rev, $propname => $propvalue);
 	unless ($self->{quiet}) {
 	    if (defined $propvalue) {
-		print loc("Property '%1' set on repository revision %2.\n",
-		    $propname, $rev);
+		$logger->info(loc("Property '%1' set on repository revision %2.",
+		    $propname, $rev));
 	    } else {
-		print loc("Property '%1' deleted from repository revision %2.\n",
-		    $propname, $rev);
+		$logger->info(loc("Property '%1' deleted from repository revision %2.",
+		    $propname, $rev));
 	    }
 	}
         return;

Modified: branches/svk-logging/lib/SVK/Command/Revert.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Command/Revert.pm	(original)
+++ branches/svk-logging/lib/SVK/Command/Revert.pm	Thu Nov 16 11:32:45 2006
@@ -7,6 +7,7 @@
 use SVK::XD;
 use SVK::Util qw( slurp_fh is_symlink to_native );
 use SVK::I18N;
+use SVK::Logger;
 
 sub options {
     ("q|quiet"    => 'quiet');
@@ -53,8 +54,8 @@
                           return $self->do_revert($target, $copath, $dpath, $xdroot);
                       } elsif ($st eq '?') {
 			  return unless $target->contains_copath ($copath);
-			  print loc("%1 is not versioned; ignored.\n",
-			      $target->report_copath ($copath));
+			  $logger->warn(loc("%1 is not versioned; ignored.",
+			      $target->report_copath ($copath)));
 			  return;
 		      }
 
@@ -98,7 +99,7 @@
     my ($self, $target, $copath) = @_;
     $self->{xd}{checkout}->store($copath, { $self->_schedule_empty,
 					    '.conflict' => undef }, {override_descendents => 0});
-    print loc("Reverted %1\n", $target->report_copath ($copath))
+    $logger->info(loc("Reverted %1", $target->report_copath ($copath)))
 	unless $self->{quiet};
 
 }

Modified: branches/svk-logging/lib/SVK/Command/Smerge.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Command/Smerge.pm	(original)
+++ branches/svk-logging/lib/SVK/Command/Smerge.pm	Thu Nov 16 11:32:45 2006
@@ -4,6 +4,7 @@
 
 use base qw( SVK::Command::Merge );
 use SVK::XD;
+use SVK::Logger;
 
 sub options {
     ($_[0]->SUPER::options,
@@ -17,7 +18,7 @@
     my ($self, @arg) = @_;
     $self->{auto}++;
     if ($self->{baserev}) {
-	print loc("--baserev is deprecated, use --base instead\n");
+	$logger->warn(loc("--baserev is deprecated, use --base instead"));
 	$self->{base} ||= $self->{baserev};
     }
     $self->SUPER::run (@arg);

Modified: branches/svk-logging/lib/SVK/Command/Sync.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Command/Sync.pm	(original)
+++ branches/svk-logging/lib/SVK/Command/Sync.pm	Thu Nov 16 11:32:45 2006
@@ -4,6 +4,7 @@
 
 use base qw( SVK::Command );
 use SVK::I18N;
+use SVK::Logger;
 
 sub options {
     ('s|skipto=s'	=> 'skip_to',
@@ -33,8 +34,8 @@
             my ( $arg, $path ) = $orig_arg =~ m{^/?([^/]*)/?(.*)?$};
             my ($depot) = eval { $self->{xd}->find_depot($arg) };
             unless ( defined $depot ) {
-                print loc( "%1 does not contain a valid depotname\n",
-                    $orig_arg );
+                $logger->error(loc( "%1 does not contain a valid depotname",
+                    $orig_arg ));
                 next;
             }
 
@@ -42,7 +43,7 @@
                 $depot->mirror->entries;
 
             if ( $path && $explicit{$orig_arg} && !@tempnewarg ) {
-                print loc( "no mirrors found underneath %1\n", $orig_arg );
+                $logger->warn(loc( "no mirrors found underneath %1", $orig_arg ));
                 next;
             }
             push @mirrors, map { $depot->mirror->get($_) } @tempnewarg;
@@ -58,7 +59,7 @@
 	    1;
 	};
         if ( $self->{sync_all} ) {
-            print loc( "Starting to synchronize %1\n", $m->get_svkpath->depotpath );
+            $logger->info(loc( "Starting to synchronize %1", $m->get_svkpath->depotpath ));
             eval { $run_sync->() };
             if ($@) {
                 warn $@;

Modified: branches/svk-logging/lib/SVK/Command/Update.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Command/Update.pm	(original)
+++ branches/svk-logging/lib/SVK/Command/Update.pm	Thu Nov 16 11:32:45 2006
@@ -6,6 +6,7 @@
 use constant opt_recursive => 1;
 use SVK::XD;
 use SVK::I18N;
+use SVK::Logger;
 
 sub options {
     ('r|revision=s'    => 'rev',
@@ -112,9 +113,9 @@
 
     my $content_revision = $update_target->isa('SVK::Path::View') ?
 	$update_target->source->revision : $update_target->revision;
-    print loc("Syncing %1(%2) in %3 to %4.\n", $cotarget->depotpath,
+    $logger->info(loc("Syncing %1(%2) in %3 to %4.", $cotarget->depotpath,
 	      $cotarget->path_anchor, $cotarget->copath,
-	      $content_revision);
+	      $content_revision));
 
     if ($kind == $SVN::Node::file ) {
 	$cotarget->anchorify;


More information about the svk-commit mailing list