git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Célestin Matte" <celestin.matte@ensimag.fr>
To: git@vger.kernel.org
Cc: benoit.person@ensimag.fr, matthieu.moy@grenoble-inp.fr,
	"Célestin Matte" <celestin.matte@ensimag.fr>
Subject: [PATCH 12/18] Brace file handles for print for more clarity
Date: Thu,  6 Jun 2013 21:34:17 +0200	[thread overview]
Message-ID: <1370547263-13558-13-git-send-email-celestin.matte@ensimag.fr> (raw)
In-Reply-To: <1370547263-13558-1-git-send-email-celestin.matte@ensimag.fr>

This follows the following rule:
InputOutput::RequireBracedFileHandleWithPrint (Severity: 1)
    The `print' and `printf' functions have a unique syntax that supports an
    optional file handle argument. Conway suggests wrapping this argument in
    braces to make it visually stand out from the other arguments. When you
    put braces around any of the special package-level file handles like
    `STDOUT', `STDERR', and `DATA', you must the `'*'' sigil or else it
    won't compile under `use strict 'subs''.

      print $FH   "Mary had a little lamb\n";  #not ok
      print {$FH} "Mary had a little lamb\n";  #ok

      print   STDERR   $foo, $bar, $baz;  #not ok
      print  {STDERR}  $foo, $bar, $baz;  #won't compile under 'strict'
      print {*STDERR}  $foo, $bar, $baz;  #perfect!

Signed-off-by: Célestin Matte <celestin.matte@ensimag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
---
 contrib/mw-to-git/git-remote-mediawiki.perl |  184 +++++++++++++--------------
 1 file changed, 92 insertions(+), 92 deletions(-)

diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
index 0e2152d..757a7a3 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -170,7 +170,7 @@ sub parse_commands {
 	} elsif ($cmd[0] eq 'push') {
 		mw_push($cmd[1]);
 	} else {
-		print STDERR "Unknown command. Aborting...\n";
+		print {*STDERR} "Unknown command. Aborting...\n";
 		last;
 	}
 	return;
@@ -197,7 +197,7 @@ sub mw_connect_maybe {
 			       lgdomain => $wiki_domain};
 		if ($mediawiki->login($request)) {
 			Git::credential \%credential, 'approve';
-			print STDERR qq(Logged in mediawiki user "$credential{username}".\n);
+			print {*STDERR} qq(Logged in mediawiki user "$credential{username}".\n);
 		} else {
 			print {*STDERR} qq(Failed to log in mediawiki user "$credential{username}" on ${url}\n);
 			print {*STDERR} '  (error ' .
@@ -265,9 +265,9 @@ sub get_mw_all_pages {
 		aplimit => 'max'
 	});
 	if (!defined($mw_pages)) {
-		print STDERR "fatal: could not get the list of wiki pages.\n";
-		print STDERR "fatal: '${url}' does not appear to be a mediawiki\n";
-		print STDERR "fatal: make sure '${url}/api.php' is a valid page.\n";
+		print {*STDERR} "fatal: could not get the list of wiki pages.\n";
+		print {*STDERR} "fatal: '${url}' does not appear to be a mediawiki\n";
+		print {*STDERR} "fatal: make sure '${url}/api.php' is a valid page.\n";
 		exit 1;
 	}
 	foreach my $page (@{$mw_pages}) {
@@ -292,14 +292,14 @@ sub get_mw_first_pages {
 		titles => $titles,
 	});
 	if (!defined($mw_pages)) {
-		print STDERR "fatal: could not query the list of wiki pages.\n";
-		print STDERR "fatal: '${url}' does not appear to be a mediawiki\n";
-		print STDERR "fatal: make sure '${url}/api.php' is a valid page.\n";
+		print {*STDERR} "fatal: could not query the list of wiki pages.\n";
+		print {*STDERR} "fatal: '${url}' does not appear to be a mediawiki\n";
+		print {*STDERR} "fatal: make sure '${url}/api.php' is a valid page.\n";
 		exit 1;
 	}
 	while (my ($id, $page) = each(%{$mw_pages->{query}->{pages}})) {
 		if ($id < 0) {
-			print STDERR "Warning: page $page->{title} not found on wiki\n";
+			print {*STDERR} "Warning: page $page->{title} not found on wiki\n";
 		} else {
 			$pages->{$page->{title}} = $page;
 		}
@@ -311,7 +311,7 @@ sub get_mw_first_pages {
 sub get_mw_pages {
 	mw_connect_maybe();
 
-	print STDERR "Listing pages on remote wiki...\n";
+	print {*STDERR} "Listing pages on remote wiki...\n";
 
 	my %pages; # hash on page titles to avoid duplicates
 	my $user_defined;
@@ -329,14 +329,14 @@ sub get_mw_pages {
 		get_mw_all_pages(\%pages);
 	}
 	if ($import_media) {
-		print STDERR "Getting media files for selected pages...\n";
+		print {*STDERR} "Getting media files for selected pages...\n";
 		if ($user_defined) {
 			get_linked_mediafiles(\%pages);
 		} else {
 			get_all_mediafiles(\%pages);
 		}
 	}
-	print STDERR (scalar keys %pages) . " pages found.\n";
+	print {*STDERR} (scalar keys %pages) . " pages found.\n";
 	return %pages;
 }
 
@@ -369,9 +369,9 @@ sub get_all_mediafiles {
 		aplimit => 'max'
 	});
 	if (!defined($mw_pages)) {
-		print STDERR "fatal: could not get the list of pages for media files.\n";
-		print STDERR "fatal: '$url' does not appear to be a mediawiki\n";
-		print STDERR "fatal: make sure '$url/api.php' is a valid page.\n";
+		print {*STDERR} "fatal: could not get the list of pages for media files.\n";
+		print {*STDERR} "fatal: '$url' does not appear to be a mediawiki\n";
+		print {*STDERR} "fatal: make sure '$url/api.php' is a valid page.\n";
 		exit 1;
 	}
 	foreach my $page (@{$mw_pages}) {
@@ -458,7 +458,7 @@ sub get_mw_mediafile_for_page_revision {
 		$mediafile{timestamp} = $fileinfo->{timestamp};
 		# Mediawiki::API's download function doesn't support https URLs
 		# and can't download old versions of files.
-		print STDERR "\tDownloading file $mediafile{title}, version $mediafile{timestamp}\n";
+		print {*STDERR} "\tDownloading file $mediafile{title}, version $mediafile{timestamp}\n";
 		$mediafile{content} = download_mw_mediafile($fileinfo->{url});
 	}
 	return %mediafile;
@@ -485,13 +485,13 @@ sub get_last_local_revision {
 
 	my $lastrevision_number;
 	if (!(defined($note_info[0]) && $note_info[0] eq 'mediawiki_revision:')) {
-		print STDERR 'No previous mediawiki revision found';
+		print {*STDERR} 'No previous mediawiki revision found';
 		$lastrevision_number = 0;
 	} else {
 		# Notes are formatted : mediawiki_revision: #number
 		$lastrevision_number = $note_info[1];
 		chomp($lastrevision_number);
-		print STDERR "Last local mediawiki revision found is ${lastrevision_number}";
+		print {*STDERR} "Last local mediawiki revision found is ${lastrevision_number}";
 	}
 	return $lastrevision_number;
 }
@@ -524,7 +524,7 @@ sub get_last_remote_revision {
 
 	my $max_rev_num = 0;
 
-	print STDERR "Getting last revision id on tracked pages...\n";
+	print {*STDERR} "Getting last revision id on tracked pages...\n";
 
 	foreach my $page (@pages) {
 		my $id = $page->{pageid};
@@ -545,7 +545,7 @@ sub get_last_remote_revision {
 		$max_rev_num = ($lastrev->{revid} > $max_rev_num ? $lastrev->{revid} : $max_rev_num);
 	}
 
-	print STDERR "Last remote revision found is $max_rev_num.\n";
+	print {*STDERR} "Last remote revision found is $max_rev_num.\n";
 	return $max_rev_num;
 }
 
@@ -598,7 +598,7 @@ sub mediawiki_smudge_filename {
 
 sub literal_data {
 	my ($content) = @_;
-	print STDOUT 'data ', bytes::length($content), "\n", $content;
+	print {*STDOUT} 'data ', bytes::length($content), "\n", $content;
 	return;
 }
 
@@ -608,7 +608,7 @@ sub literal_data_raw {
 	# Avoid confusion between size in bytes and in characters
 	utf8::downgrade($content);
 	binmode STDOUT, ':raw';
-	print STDOUT 'data ', bytes::length($content), "\n", $content;
+	print {*STDOUT} 'data ', bytes::length($content), "\n", $content;
 	binmode STDOUT, ':encoding(UTF-8)';
 	return;
 }
@@ -617,26 +617,26 @@ sub mw_capabilities {
 	# Revisions are imported to the private namespace
 	# refs/mediawiki/$remotename/ by the helper and fetched into
 	# refs/remotes/$remotename later by fetch.
-	print STDOUT "refspec refs/heads/*:refs/mediawiki/${remotename}/*\n";
-	print STDOUT "import\n";
-	print STDOUT "list\n";
-	print STDOUT "push\n";
-	print STDOUT "\n";
+	print {*STDOUT} "refspec refs/heads/*:refs/mediawiki/${remotename}/*\n";
+	print {*STDOUT} "import\n";
+	print {*STDOUT} "list\n";
+	print {*STDOUT} "push\n";
+	print {*STDOUT} "\n";
 	return;
 }
 
 sub mw_list {
 	# MediaWiki do not have branches, we consider one branch arbitrarily
 	# called master, and HEAD pointing to it.
-	print STDOUT "? refs/heads/master\n";
-	print STDOUT "\@refs/heads/master HEAD\n";
-	print STDOUT "\n";
+	print {*STDOUT} "? refs/heads/master\n";
+	print {*STDOUT} "\@refs/heads/master HEAD\n";
+	print {*STDOUT} "\n";
 	return;
 }
 
 sub mw_option {
-	print STDERR "remote-helper command 'option $_[0]' not yet implemented\n";
-	print STDOUT "unsupported\n";
+	print {*STDERR} "remote-helper command 'option $_[0]' not yet implemented\n";
+	print {*STDOUT} "unsupported\n";
 	return;
 }
 
@@ -672,11 +672,11 @@ sub fetch_mw_revisions_for_page {
 		$query->{rvstartid} = $result->{'query-continue'}->{revisions}->{rvstartid};
 	}
 	if ($shallow_import && @page_revs) {
-		print STDERR "  Found 1 revision (shallow import).\n";
+		print {*STDERR} "  Found 1 revision (shallow import).\n";
 		@page_revs = sort {$b->{revid} <=> $a->{revid}} (@page_revs);
 		return $page_revs[0];
 	}
-	print STDERR "  Found ${revnum} revision(s).\n";
+	print {*STDERR} "  Found ${revnum} revision(s).\n";
 	return @page_revs;
 }
 
@@ -722,42 +722,42 @@ sub import_file_revision {
 	my $author = $commit{author};
 	my $date = $commit{date};
 
-	print STDOUT "commit refs/mediawiki/${remotename}/master\n";
-	print STDOUT "mark :${n}\n";
-	print STDOUT "committer ${author} <${author}\@${wiki_name}> " . $date->epoch . " +0000\n";
+	print {*STDOUT} "commit refs/mediawiki/${remotename}/master\n";
+	print {*STDOUT} "mark :${n}\n";
+	print {*STDOUT} "committer ${author} <${author}\@${wiki_name}> " . $date->epoch . " +0000\n";
 	literal_data($comment);
 
 	# If it's not a clone, we need to know where to start from
 	if (!$full_import && $n == 1) {
-		print STDOUT "from refs/mediawiki/${remotename}/master^0\n";
+		print {*STDOUT} "from refs/mediawiki/${remotename}/master^0\n";
 	}
 	if ($content ne $DELETED_CONTENT) {
 		print {*STDOUT} 'M 644 inline ' .
 		    fe_escape_path("${title}.mw") . "\n";
 		literal_data($content);
 		if (%mediafile) {
-			print STDOUT 'M 644 inline '
+			print {*STDOUT} 'M 644 inline '
 			    . fe_escape_path($mediafile{title}) . "\n";
 			literal_data_raw($mediafile{content});
 		}
-		print STDOUT "\n\n";
+		print {*STDOUT} "\n\n";
 	} else {
-		print STDOUT 'D ' . fe_escape_path("${title}.mw") . "\n";
+		print {*STDOUT} 'D ' . fe_escape_path("${title}.mw") . "\n";
 	}
 
 	# mediawiki revision number in the git note
 	if ($full_import && $n == 1) {
-		print STDOUT "reset refs/notes/${remotename}/mediawiki\n";
+		print {*STDOUT} "reset refs/notes/${remotename}/mediawiki\n";
 	}
-	print STDOUT "commit refs/notes/${remotename}/mediawiki\n";
-	print STDOUT "committer ${author} <${author}\@${wiki_name}> " . $date->epoch . " +0000\n";
+	print {*STDOUT} "commit refs/notes/${remotename}/mediawiki\n";
+	print {*STDOUT} "committer ${author} <${author}\@${wiki_name}> " . $date->epoch . " +0000\n";
 	literal_data('Note added by git-mediawiki during import');
 	if (!$full_import && $n == 1) {
-		print STDOUT "from refs/notes/${remotename}/mediawiki^0\n";
+		print {*STDOUT} "from refs/notes/${remotename}/mediawiki^0\n";
 	}
-	print STDOUT "N inline :${n}\n";
+	print {*STDOUT} "N inline :${n}\n";
 	literal_data("mediawiki_revision: $commit{mw_revision}");
-	print STDOUT "\n\n";
+	print {*STDOUT} "\n\n";
 	return;
 }
 
@@ -788,7 +788,7 @@ sub mw_import {
 	foreach my $ref (@refs) {
 		mw_import_ref($ref);
 	}
-	print STDOUT "done\n";
+	print {*STDOUT} "done\n";
 	return;
 }
 
@@ -805,30 +805,30 @@ sub mw_import_ref {
 
 	mw_connect_maybe();
 
-	print STDERR "Searching revisions...\n";
+	print {*STDERR} "Searching revisions...\n";
 	my $last_local = get_last_local_revision();
 	my $fetch_from = $last_local + 1;
 	if ($fetch_from == 1) {
-		print STDERR ", fetching from beginning.\n";
+		print {*STDERR} ", fetching from beginning.\n";
 	} else {
-		print STDERR ", fetching from here.\n";
+		print {*STDERR} ", fetching from here.\n";
 	}
 
 	my $n = 0;
 	if ($fetch_strategy eq 'by_rev') {
-		print STDERR "Fetching & writing export data by revs...\n";
+		print {*STDERR} "Fetching & writing export data by revs...\n";
 		$n = mw_import_ref_by_revs($fetch_from);
 	} elsif ($fetch_strategy eq 'by_page') {
-		print STDERR "Fetching & writing export data by pages...\n";
+		print {*STDERR} "Fetching & writing export data by pages...\n";
 		$n = mw_import_ref_by_pages($fetch_from);
 	} else {
-		print STDERR qq(fatal: invalid fetch strategy "${fetch_strategy}".\n);
-		print STDERR "Check your configuration variables remote.${remotename}.fetchStrategy and mediawiki.fetchStrategy\n";
+		print {*STDERR} qq(fatal: invalid fetch strategy "${fetch_strategy}".\n);
+		print {*STDERR} "Check your configuration variables remote.${remotename}.fetchStrategy and mediawiki.fetchStrategy\n";
 		exit 1;
 	}
 
 	if ($fetch_from == 1 && $n == 0) {
-		print STDERR "You appear to have cloned an empty MediaWiki.\n";
+		print {*STDERR} "You appear to have cloned an empty MediaWiki.\n";
 		# Something has to be done remote-helper side. If nothing is done, an error is
 		# thrown saying that HEAD is referring to unknown object 0000000000000000000
 		# and the clone fails.
@@ -907,7 +907,7 @@ sub mw_import_revids {
 		my $page_title = $result_page->{title};
 
 		if (!exists($pages->{$page_title})) {
-			print STDERR "${n}/", scalar(@$revision_ids),
+			print {*STDERR} "${n}/", scalar(@$revision_ids),
 				": Skipping revision #$rev->{revid} of ${page_title}\n";
 			next;
 		}
@@ -940,7 +940,7 @@ sub mw_import_revids {
 		# If this is a revision of the media page for new version
 		# of a file do one common commit for both file and media page.
 		# Else do commit only for that page.
-		print STDERR "${n}/", scalar(@$revision_ids), ": Revision #$rev->{revid} of $commit{title}\n";
+		print {*STDERR} "${n}/", scalar(@$revision_ids), ": Revision #$rev->{revid} of $commit{title}\n";
 		import_file_revision(\%commit, ($fetch_from == 1), $n_actual, \%mediafile);
 	}
 
@@ -954,11 +954,11 @@ sub error_non_fast_forward {
 		# Native git-push would show this after the summary.
 		# We can't ask it to display it cleanly, so print it
 		# ourselves before.
-		print STDERR "To prevent you from losing history, non-fast-forward updates were rejected\n";
-		print STDERR "Merge the remote changes (e.g. 'git pull') before pushing again. See the\n";
-		print STDERR "'Note about fast-forwards' section of 'git push --help' for details.\n";
+		print {*STDERR} "To prevent you from losing history, non-fast-forward updates were rejected\n";
+		print {*STDERR} "Merge the remote changes (e.g. 'git pull') before pushing again. See the\n";
+		print {*STDERR} "'Note about fast-forwards' section of 'git push --help' for details.\n";
 	}
-	print STDOUT qq(error $_[0] "non-fast-forward"\n);
+	print {*STDOUT} qq(error $_[0] "non-fast-forward"\n);
 	return 0;
 }
 
@@ -972,8 +972,8 @@ sub mw_upload_file {
 	my $path = "File:${complete_file_name}";
 	my %hashFiles = get_allowed_file_extensions();
 	if (!exists($hashFiles{$extension})) {
-		print STDERR "${complete_file_name} is not a permitted file on this wiki.\n";
-		print STDERR "Check the configuration of file uploads in your mediawiki.\n";
+		print {*STDERR} "${complete_file_name} is not a permitted file on this wiki.\n";
+		print {*STDERR} "Check the configuration of file uploads in your mediawiki.\n";
 		return $newrevid;
 	}
 	# Deleting and uploading a file requires a priviledged user
@@ -985,9 +985,9 @@ sub mw_upload_file {
 			reason => $summary
 		};
 		if (!$mediawiki->edit($query)) {
-			print STDERR "Failed to delete file on remote wiki\n";
-			print STDERR "Check your permissions on the remote site. Error code:\n";
-			print STDERR $mediawiki->{error}->{code} . ':' . $mediawiki->{error}->{details};
+			print {*STDERR} "Failed to delete file on remote wiki\n";
+			print {*STDERR} "Check your permissions on the remote site. Error code:\n";
+			print {*STDERR} $mediawiki->{error}->{code} . ':' . $mediawiki->{error}->{details};
 			exit 1;
 		}
 	} else {
@@ -1011,9 +1011,9 @@ sub mw_upload_file {
 				 . $mediawiki->{error}->{details} . "\n";
 			my $last_file_page = $mediawiki->get_page({title => $path});
 			$newrevid = $last_file_page->{revid};
-			print STDERR "Pushed file: ${new_sha1} - ${complete_file_name}.\n";
+			print {*STDERR} "Pushed file: ${new_sha1} - ${complete_file_name}.\n";
 		} else {
-			print STDERR "Empty file ${complete_file_name} not pushed.\n";
+			print {*STDERR} "Empty file ${complete_file_name} not pushed.\n";
 		}
 	}
 	return $newrevid;
@@ -1051,7 +1051,7 @@ sub mw_push_file {
 	if ($extension eq 'mw') {
 		my $ns = get_mw_namespace_id_for_page($complete_file_name);
 		if ($ns && $ns == get_mw_namespace_id('File') && (!$export_media)) {
-			print STDERR "Ignoring media file related page: ${complete_file_name}\n";
+			print {*STDERR} "Ignoring media file related page: ${complete_file_name}\n";
 			return ($oldrevid, 'ok');
 		}
 		my $file_content;
@@ -1079,7 +1079,7 @@ sub mw_push_file {
 		if (!$result) {
 			if ($mediawiki->{error}->{code} == 3) {
 				# edit conflicts, considered as non-fast-forward
-				print STDERR 'Warning: Error ' .
+				print {*STDERR} 'Warning: Error ' .
 				    $mediawiki->{error}->{code} .
 				    ' from mediwiki: ' . $mediawiki->{error}->{details} .
 				    ".\n";
@@ -1092,13 +1092,13 @@ sub mw_push_file {
 			}
 		}
 		$newrevid = $result->{edit}->{newrevid};
-		print STDERR "Pushed file: ${new_sha1} - ${title}\n";
+		print {*STDERR} "Pushed file: ${new_sha1} - ${title}\n";
 	} elsif ($export_media) {
 		$newrevid = mw_upload_file($complete_file_name, $new_sha1,
 					   $extension, $page_deleted,
 					   $summary);
 	} else {
-		print STDERR "Ignoring media file ${title}\n";
+		print {*STDERR} "Ignoring media file ${title}\n";
 	}
 	$newrevid = ($newrevid or $oldrevid);
 	return ($newrevid, 'ok');
@@ -1112,16 +1112,16 @@ sub mw_push {
 		my ($force, $local, $remote) = $refspec =~ /^(\+)?([^:]*):([^:]*)$/
 		    or die("Invalid refspec for push. Expected <src>:<dst> or +<src>:<dst>\n");
 		if ($force) {
-			print STDERR "Warning: forced push not allowed on a MediaWiki.\n";
+			print {*STDERR} "Warning: forced push not allowed on a MediaWiki.\n";
 		}
 		if ($local eq "") {
-			print STDERR "Cannot delete remote branch on a MediaWiki\n";
-			print STDOUT "error ${remote} cannot delete\n";
+			print {*STDERR} "Cannot delete remote branch on a MediaWiki\n";
+			print {*STDOUT} "error ${remote} cannot delete\n";
 			next;
 		}
 		if ($remote ne 'refs/heads/master') {
-			print STDERR "Only push to the branch 'master' is supported on a MediaWiki\n";
-			print STDOUT "error ${remote} only master allowed\n";
+			print {*STDERR} "Only push to the branch 'master' is supported on a MediaWiki\n";
+			print {*STDOUT} "error ${remote} only master allowed\n";
 			next;
 		}
 		if (mw_push_revision($local, $remote)) {
@@ -1130,15 +1130,15 @@ sub mw_push {
 	}
 
 	# Notify Git that the push is done
-	print STDOUT "\n";
+	print {*STDOUT} "\n";
 
 	if ($pushed && $dumb_push) {
-		print STDERR "Just pushed some revisions to MediaWiki.\n";
-		print STDERR "The pushed revisions now have to be re-imported, and your current branch\n";
-		print STDERR "needs to be updated with these re-imported commits. You can do this with\n";
-		print STDERR "\n";
-		print STDERR "  git pull --rebase\n";
-		print STDERR "\n";
+		print {*STDERR} "Just pushed some revisions to MediaWiki.\n";
+		print {*STDERR} "The pushed revisions now have to be re-imported, and your current branch\n";
+		print {*STDERR} "needs to be updated with these re-imported commits. You can do this with\n";
+		print {*STDERR} "\n";
+		print {*STDERR} "  git pull --rebase\n";
+		print {*STDERR} "\n";
 	}
 	return;
 }
@@ -1147,7 +1147,7 @@ sub mw_push_revision {
 	my $local = shift;
 	my $remote = shift; # actually, this has to be "refs/heads/master" at this point.
 	my $last_local_revid = get_last_local_revision();
-	print STDERR ".\n"; # Finish sentence started by get_last_local_revision()
+	print {*STDERR} ".\n"; # Finish sentence started by get_last_local_revision()
 	my $last_remote_revid = get_last_remote_revision();
 	my $mw_revision = $last_remote_revid;
 
@@ -1174,7 +1174,7 @@ sub mw_push_revision {
 	if ($last_local_revid > 0) {
 		my $parsed_sha1 = $remoteorigin_sha1;
 		# Find a path from last MediaWiki commit to pushed commit
-		print STDERR "Computing path from local to remote ...\n";
+		print {*STDERR} "Computing path from local to remote ...\n";
 		my @local_ancestry = split(/\n/, run_git("rev-list --boundary --parents ${local} ^${parsed_sha1}"));
 		my %local_ancestry;
 		foreach my $line (@local_ancestry) {
@@ -1189,7 +1189,7 @@ sub mw_push_revision {
 		while ($parsed_sha1 ne $HEAD_sha1) {
 			my $child = $local_ancestry{$parsed_sha1};
 			if (!$child) {
-				printf STDERR "Cannot find a path in history from remote commit to last commit\n";
+				print {*STDERR} "Cannot find a path in history from remote commit to last commit\n";
 				return error_non_fast_forward($remote);
 			}
 			push(@commit_pairs, [$parsed_sha1, $child]);
@@ -1198,7 +1198,7 @@ sub mw_push_revision {
 	} else {
 		# No remote mediawiki revision. Export the whole
 		# history (linearized with --first-parent)
-		print STDERR "Warning: no common ancestor, pushing complete history\n";
+		print {*STDERR} "Warning: no common ancestor, pushing complete history\n";
 		my $history = run_git("rev-list --first-parent --children ${local}");
 		my @history = split(/\n/, $history);
 		@history = @history[1..$#history];
@@ -1246,7 +1246,7 @@ sub mw_push_revision {
 		}
 	}
 
-	print STDOUT "ok ${remote}\n";
+	print {*STDOUT} "ok ${remote}\n";
 	return 1;
 }
 
@@ -1296,7 +1296,7 @@ sub get_mw_namespace_id {
 	}
 
 	if (!exists $namespace_id{$name}) {
-		print STDERR "Namespace ${name} not found in cache, querying the wiki ...\n";
+		print {*STDERR} "Namespace ${name} not found in cache, querying the wiki ...\n";
 		# NS not found => get namespace id from MW and store it in
 	        # configuration file.
 	        my $query = {
@@ -1321,7 +1321,7 @@ sub get_mw_namespace_id {
 	my $id;
 
 	unless (defined $ns) {
-		print STDERR "No such namespace ${name} on MediaWiki.\n";
+		print {*STDERR} "No such namespace ${name} on MediaWiki.\n";
 		$ns = {is_namespace => 0};
 		$namespace_id{$name} = $ns;
 	}
-- 
1.7.9.5

  parent reply	other threads:[~2013-06-06 19:35 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-06 19:34 [PATCH 00/18] git-remote-mediawiki: Follow perlcritic's recommandations Célestin Matte
2013-06-06 19:34 ` [PATCH 01/18] Follow perlcritic's recommendations - level 5 and 4 Célestin Matte
2013-06-07  1:42   ` Eric Sunshine
2013-06-07  8:10   ` Matthieu Moy
2013-06-07 12:11     ` Célestin Matte
2013-06-07 17:43       ` Matthieu Moy
2013-06-06 19:34 ` [PATCH 02/18] Change style of some regular expressions to make them clearer Célestin Matte
2013-06-07  1:54   ` Eric Sunshine
2013-06-07  2:30     ` Junio C Hamano
2013-06-07  4:39       ` Eric Sunshine
2013-06-07  4:51         ` Junio C Hamano
2013-06-07 10:40   ` Peter Krefting
2013-06-06 19:34 ` [PATCH 03/18] Add newline in the end of die() error messages Célestin Matte
2013-06-06 19:34 ` [PATCH 04/18] Prevent local variable $url to have the same name as a global variable Célestin Matte
2013-06-06 19:34 ` [PATCH 05/18] Turn double-negated expressions into simple expressions Célestin Matte
2013-06-07  4:12   ` Eric Sunshine
2013-06-07 17:04     ` Célestin Matte
2013-06-07 20:25       ` Eric Sunshine
2013-06-07 20:32         ` Célestin Matte
2013-06-06 19:34 ` [PATCH 06/18] Remove unused variable Célestin Matte
2013-06-06 19:34 ` [PATCH 07/18] Rename a variable ($last) so that it does not have the name of a keyword Célestin Matte
2013-06-06 19:34 ` [PATCH 08/18] Explicitely assign local variable as undef and make a proper one-instruction-by- line indentation Célestin Matte
2013-06-07  1:19   ` Eric Sunshine
2013-06-07  8:18   ` Matthieu Moy
2013-06-06 19:34 ` [PATCH 09/18] Check return value of open and remove import of unused open2 Célestin Matte
2013-06-07  8:21   ` Matthieu Moy
2013-06-06 19:34 ` [PATCH 10/18] Put long code into a submodule Célestin Matte
2013-06-07  4:01   ` Eric Sunshine
2013-06-07  4:51     ` Junio C Hamano
2013-06-06 19:34 ` [PATCH 11/18] Modify strings for a better coding-style Célestin Matte
2013-06-07  4:31   ` Eric Sunshine
2013-06-06 19:34 ` Célestin Matte [this message]
2013-06-06 19:34 ` [PATCH 13/18] Remove "unless" statements and replace them by negated "if" statements Célestin Matte
2013-06-07  3:41   ` Eric Sunshine
2013-06-06 19:34 ` [PATCH 14/18] Don't use quotes for empty strings Célestin Matte
2013-06-06 19:34 ` [PATCH 15/18] Put non-trivial numeric values (e.g., different from 0, 1 and 2) in constants Célestin Matte
2013-06-06 19:34 ` [PATCH 16/18] Fix a typo ("mediwiki" instead of "mediawiki") Célestin Matte
2013-06-06 19:34 ` [PATCH 17/18] Place the open() call inside the do{} struct and prevent failing close Célestin Matte
2013-06-06 21:13   ` Junio C Hamano
2013-06-06 21:30     ` Célestin Matte
2013-06-06 21:58       ` Junio C Hamano
2013-06-06 22:16         ` Célestin Matte
2013-06-06 19:34 ` [PATCH 18/18] Clearly rewrite double dereference Célestin Matte
2013-06-07  4:04   ` Eric Sunshine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1370547263-13558-13-git-send-email-celestin.matte@ensimag.fr \
    --to=celestin.matte@ensimag.fr \
    --cc=benoit.person@ensimag.fr \
    --cc=git@vger.kernel.org \
    --cc=matthieu.moy@grenoble-inp.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).