[svk-commit] r2144 - in branches/svk-logging/lib/SVK: . Editor

stig at bestpractical.com stig at bestpractical.com
Wed Nov 15 13:58:18 EST 2006


Author: stig
Date: Wed Nov 15 13:58:17 2006
New Revision: 2144

Modified:
   branches/svk-logging/lib/SVK/Editor/Merge.pm
   branches/svk-logging/lib/SVK/Merge.pm
   branches/svk-logging/lib/SVK/Mirror.pm
   branches/svk-logging/lib/SVK/Patch.pm
   branches/svk-logging/lib/SVK/Resolve.pm
   branches/svk-logging/lib/SVK/Resolve/Emacs.pm
   branches/svk-logging/lib/SVK/Util.pm

Log:
convert more "print loc" to use svk::logger instead

Modified: branches/svk-logging/lib/SVK/Editor/Merge.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Editor/Merge.pm	(original)
+++ branches/svk-logging/lib/SVK/Editor/Merge.pm	Wed Nov 15 13:58:17 2006
@@ -4,6 +4,7 @@
 
 use base 'SVK::Editor';
 use SVK::I18N;
+use SVK::Logger;
 use autouse 'SVK::Util'
     => qw( slurp_fh md5_fh tmpfile devnull abs2rel );
 
@@ -941,7 +942,7 @@
 	$self->{storage}->close_edit(@arg);
     }
     else {
-	print loc("Empty merge.\n") unless $self->{notify}{quiet};
+	$logger->warn(loc("Empty merge.")) unless $self->{notify}{quiet};
 	$self->{storage}->abort_edit(@arg);
     }
 }

Modified: branches/svk-logging/lib/SVK/Merge.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Merge.pm	(original)
+++ branches/svk-logging/lib/SVK/Merge.pm	Wed Nov 15 13:58:17 2006
@@ -6,6 +6,7 @@
 use SVK::Editor::Rename;
 use SVK::Editor::Translate;
 use SVK::Editor::Delay;
+use SVK::Logger;
 use List::Util qw(min);
 
 =head1 NAME
@@ -301,7 +302,7 @@
     my $newinfo = $dstinfo->union ($srcinfo)->del_target ($self->{dst});
     unless ($self->{quiet}) {
 	for (sort keys %$newinfo) {
-	    print loc("New merge ticket: %1:%2\n", $_, $newinfo->{$_}{rev})
+	    $logger->info(loc("New merge ticket: %1:%2", $_, $newinfo->{$_}{rev}))
 		if !$dstinfo->{$_} || $newinfo->{$_}{rev} > $dstinfo->{$_}{rev};
 	}
     }
@@ -563,10 +564,10 @@
 	      no_recurse => $self->{no_recurse}, editor => $editor,
 	    );
     unless ($self->{quiet}) {
-	print loc("%*(%1,conflict) found.\n", $meditor->{conflicts})
+	$logger->warn(loc("%*(%1,conflict) found.", $meditor->{conflicts}))
 	    if $meditor->{conflicts};
-	print loc("%*(%1,file) skipped, you might want to rerun merge with --track-rename.\n",
-		  $meditor->{skipped}) if $meditor->{skipped} && !$self->{track_rename} && !$self->{auto};
+	$logger->warn(loc("%*(%1,file) skipped, you might want to rerun merge with --track-rename.",
+		  $meditor->{skipped})) if $meditor->{skipped} && !$self->{track_rename} && !$self->{auto};
     }
 
     return $meditor->{conflicts};

Modified: branches/svk-logging/lib/SVK/Mirror.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Mirror.pm	(original)
+++ branches/svk-logging/lib/SVK/Mirror.pm	Wed Nov 15 13:58:17 2006
@@ -3,6 +3,7 @@
 use warnings;
 
 use SVN::Core;
+use SVK::Logger;
 
 use Sys::Hostname;
 use SVK::I18N;
@@ -323,12 +324,12 @@
     my ($self, $torev) = @_;
     return $self->run_svnmirror_sync({ torev => $torev }) unless $self->_backend->has_replay;
 
-    print loc("Syncing %1", $self->url).($self->_backend->_relayed ? loc(" via %1\n", $self->server_url) : "\n");
+    $logger->info(loc("Syncing %1", $self->url).($self->_backend->_relayed ? loc(" via %1", $self->server_url) : ""));
 
     $self->mirror_changesets($torev,
         sub {
             my ( $changeset, $rev ) = @_;
-            print "Committed revision $rev from revision $changeset.\n";
+            $logger->info("Committed revision $rev from revision $changeset.");
         }
     );
     die $@ if $@;
@@ -336,7 +337,7 @@
 
 sub sync_snapshot {
     my ($self, $snapshot) = @_;
-    print loc("
+    $logger->warn(loc("
 svk is now taking a snapshot of the repository at:
   %1
 
@@ -344,7 +345,7 @@
 url contains directories like trunk and branches.  If this isn't what
 you mean, please hit ^C.
 
-", $self->url);
+", $self->url));
 
     $self->run_svnmirror_sync( { skip_to => $snapshot });
 }
@@ -355,9 +356,9 @@
     my $i = 0;
     sub {
 	my ($mirror, $who) = @_;
-	print loc("Waiting for lock on %1: %2.\n", $target->depotpath, $who);
+	$logger->warn(loc("Waiting for lock on %1: %2.", $target->depotpath, $who));
 	if (++$i % 3 == 0) {
-	    print loc ("
+	    $logger->error(loc ("
 The mirror is currently locked. This might be because the mirror is
 in the middle of a sensitive operation or because a process holding
 the lock hung or died.  To check if the mirror lock is stalled,  see
@@ -365,7 +366,7 @@
 
 If the mirror lock is stalled, please interrupt this process and run:
     svk mirror --unlock %1
-", $target->depotpath);
+", $target->depotpath));
 	}
     }
 }

Modified: branches/svk-logging/lib/SVK/Patch.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Patch.pm	(original)
+++ branches/svk-logging/lib/SVK/Patch.pm	Wed Nov 15 13:58:17 2006
@@ -3,6 +3,7 @@
 use SVK::I18N;
 use SVK::Util qw( read_file write_file );
 use SVK::Version;  our $VERSION = $SVK::VERSION;
+use SVK::Logger;
 
 =head1 NAME
 
@@ -262,7 +263,7 @@
 				     SVK::Editor::Merge->cb_for_root
 				     ($target->root, $target->path, $target->revision))) {
 
-	print loc("Conflicts.\n");
+	$logger->error(loc("Conflicts."));
 	return $conflict;
     }
 
@@ -277,7 +278,7 @@
     my $target = $self->{_target}
 	or die loc("Target not local nor mirrored, unable to regen patch.\n");
     unless ($self->{level} == 0 || $self->{_source_updated}) {
-	print loc("Source of patch %1 not updated or not local, no need to regen patch.\n", $self->{name});
+	$logger->warn(loc("Source of patch %1 not updated or not local, no need to regen patch.", $self->{name}));
 	return;
     }
     my $source = $self->{_source}->new->refresh_revision;
@@ -330,6 +331,7 @@
 package SVK::Patch::CommitEditor;
 use base qw(SVK::Editor::Patch);
 use SVK::I18N;
+use SVK::Logger;
 
 sub close_edit {
     my $self = shift;
@@ -340,7 +342,7 @@
     ++$patch->{level};
     $patch->store ($filename);
     return if $filename eq '-';
-    print loc ("Patch %1 created.\n", $patch->{name});
+    $logger->warn(loc ("Patch %1 created.", $patch->{name}));
 }
 
 =head1 AUTHORS

Modified: branches/svk-logging/lib/SVK/Resolve.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Resolve.pm	(original)
+++ branches/svk-logging/lib/SVK/Resolve.pm	Wed Nov 15 13:58:17 2006
@@ -6,6 +6,7 @@
     read_file can_run is_executable bsd_glob
 );
 use File::Copy ();
+use SVK::Logger;
 
 use constant Actions => {qw(
     a   accept      e   edit        d   diff
@@ -122,12 +123,12 @@
     ) : $self->get_resolver);
 
     if (!$resolver) {
-        print loc("Cannot launch an external merge tool for %1.\n", $path);
+        $logger->error(loc("Cannot launch an external merge tool for %1.", $path));
         return;
     }
 
     # maybe some message here
-    print loc("Invoking merge tool '%1' for %2.\n", $resolver->name, $path);
+    $logger->info(loc("Invoking merge tool '%1' for %2.", $resolver->name, $path));
 
     if ($resolver->run_resolver($cmd, @args)) {
         $self->{has_conflict} = (

Modified: branches/svk-logging/lib/SVK/Resolve/Emacs.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Resolve/Emacs.pm	(original)
+++ branches/svk-logging/lib/SVK/Resolve/Emacs.pm	Wed Nov 15 13:58:17 2006
@@ -3,6 +3,7 @@
 use base 'SVK::Resolve';
 use SVK::I18N;
 use SVK::Util qw( devnull );
+use SVK::Logger;
 
 sub commands { 'gnuclient-emacs' }
 
@@ -47,7 +48,7 @@
     my ($self, $cmd, @args) = @_;
 
     local $SIG{$self->{signal}} = sub {
-        print loc("Emerge %1 done.\n");
+        $logger->info(loc("Emerge %1 done."));
         $self->{finished} = 1;
     };
 
@@ -56,10 +57,10 @@
         die loc("Cannot fork: %1", $!);
     }
     elsif ($pid) {
-        print loc(
-            "Started %1, Try 'kill -%2 %3' to terminate if things mess up.\n",
+        $logger->warn(loc(
+            "Started %1, Try 'kill -%2 %3' to terminate if things mess up.",
             $pid, $self->{signal}, $$,
-        );
+        ));
         sleep 1 until $self->{finished};
     }
     else {

Modified: branches/svk-logging/lib/SVK/Util.pm
==============================================================================
--- branches/svk-logging/lib/SVK/Util.pm	(original)
+++ branches/svk-logging/lib/SVK/Util.pm	Wed Nov 15 13:58:17 2006
@@ -29,6 +29,7 @@
 
 
 use Config ();
+use SVK::Logger;
 use SVK::I18N;
 use SVN::Core;
 use autouse 'Encode'            => qw(resolve_alias($) decode encode);
@@ -38,6 +39,7 @@
                                qw(catdir catpath splitpath splitdir tmpdir);
 
 
+
 =head1 NAME
 
 SVK::Util - Utility functions for SVK classes
@@ -202,7 +204,7 @@
 			: DEFAULT_EDITOR; # fall back to something
     my @editor = split (/ /, $editor);
 
-    print loc("Waiting for editor...\n");
+    $logger->info(loc("Waiting for editor..."));
 
     # XXX: check $?
     system {$editor[0]} (@editor, $file) and die loc("Aborted: %1\n", $!);
@@ -773,10 +775,10 @@
         File::Copy::move ($source => $target) and return;
     }
 
-    print loc(
-        "Cannot rename %1 to %2; please move it manually.\n",
+    $logger->error(loc(
+        "Cannot rename %1 to %2; please move it manually.",
         catfile($source), catfile($target),
-    );
+    ));
 }
 
 =head3 traverse_history (root => $fs_root, path => $path,


More information about the svk-commit mailing list