git-remote-mediawiki: brace file handles for print for more clarity

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Célestin Matte committed Jun 14, 2013 at 15:50 UTC e83d36b66fc578d8aa965be15037bc1155f163cd
1 file changed +95 -95
contrib/mw-to-git/git-remote-mediawiki.perl
+95 -95
@@ -159,7 +159,7 @@ sub parse_command {
159 } elsif ($cmd[0] eq 'push') {
160 mw_push($cmd[1]);
161 } else {
162 - print STDERR "Unknown command. Aborting...\n";
162 + print {*STDERR} "Unknown command. Aborting...\n";
163 return 0;
164 }
165 return 1;
@@ -186,10 +186,10 @@ sub mw_connect_maybe {
186 lgdomain => $wiki_domain};
187 if ($mediawiki->login($request)) {
188 Git::credential(\%credential, 'approve');
189 - print STDERR qq(Logged in mediawiki user "$credential{username}".\n);
189 + print {*STDERR} qq(Logged in mediawiki user "$credential{username}".\n);
190 } else {
191 - print STDERR qq(Failed to log in mediawiki user "$credential{username}" on ${url}\n);
192 - print STDERR ' (error ' .
191 + print {*STDERR} qq(Failed to log in mediawiki user "$credential{username}" on ${url}\n);
192 + print {*STDERR} ' (error ' .
193 $mediawiki->{error}->{code} . ': ' .
194 $mediawiki->{error}->{details} . ")\n";
195 Git::credential(\%credential, 'reject');
@@ -298,7 +298,7 @@ sub get_mw_first_pages {
298 }
299 while (my ($id, $page) = each(%{$mw_pages->{query}->{pages}})) {
300 if ($id < 0) {
301 - print STDERR "Warning: page $page->{title} not found on wiki\n";
301 + print {*STDERR} "Warning: page $page->{title} not found on wiki\n";
302 } else {
303 $pages->{$page->{title}} = $page;
304 }
@@ -310,7 +310,7 @@ sub get_mw_first_pages {
310 sub get_mw_pages {
311 mw_connect_maybe();
312
313 - print STDERR "Listing pages on remote wiki...\n";
313 + print {*STDERR} "Listing pages on remote wiki...\n";
314
315 my %pages; # hash on page titles to avoid duplicates
316 my $user_defined;
@@ -328,14 +328,14 @@ sub get_mw_pages {
328 get_mw_all_pages(\%pages);
329 }
330 if ($import_media) {
331 - print STDERR "Getting media files for selected pages...\n";
331 + print {*STDERR} "Getting media files for selected pages...\n";
332 if ($user_defined) {
333 get_linked_mediafiles(\%pages);
334 } else {
335 get_all_mediafiles(\%pages);
336 }
337 }
338 - print STDERR (scalar keys %pages) . " pages found.\n";
338 + print {*STDERR} (scalar keys %pages) . " pages found.\n";
339 return %pages;
340 }
341
@@ -368,9 +368,9 @@ sub get_all_mediafiles {
368 aplimit => 'max'
369 });
370 if (!defined($mw_pages)) {
371 - print STDERR "fatal: could not get the list of pages for media files.\n";
372 - print STDERR "fatal: '$url' does not appear to be a mediawiki\n";
373 - print STDERR "fatal: make sure '$url/api.php' is a valid page.\n";
371 + print {*STDERR} "fatal: could not get the list of pages for media files.\n";
372 + print {*STDERR} "fatal: '$url' does not appear to be a mediawiki\n";
373 + print {*STDERR} "fatal: make sure '$url/api.php' is a valid page.\n";
374 exit 1;
375 }
376 foreach my $page (@{$mw_pages}) {
@@ -457,7 +457,7 @@ sub get_mw_mediafile_for_page_revision {
457 $mediafile{timestamp} = $fileinfo->{timestamp};
458 # Mediawiki::API's download function doesn't support https URLs
459 # and can't download old versions of files.
460 - print STDERR "\tDownloading file $mediafile{title}, version $mediafile{timestamp}\n";
460 + print {*STDERR} "\tDownloading file $mediafile{title}, version $mediafile{timestamp}\n";
461 $mediafile{content} = download_mw_mediafile($fileinfo->{url});
462 }
463 return %mediafile;
@@ -470,9 +470,9 @@ sub download_mw_mediafile {
470 if ($response->code == 200) {
471 return $response->decoded_content;
472 } else {
473 - print STDERR "Error downloading mediafile from :\n";
474 - print STDERR "URL: ${download_url}\n";
475 - print STDERR 'Server response: ' . $response->code . q{ } . $response->message . "\n";
473 + print {*STDERR} "Error downloading mediafile from :\n";
474 + print {*STDERR} "URL: ${download_url}\n";
475 + print {*STDERR} 'Server response: ' . $response->code . q{ } . $response->message . "\n";
476 exit 1;
477 }
478 }
@@ -484,13 +484,13 @@ sub get_last_local_revision {
484
485 my $lastrevision_number;
486 if (!(defined($note_info[0]) && $note_info[0] eq 'mediawiki_revision:')) {
487 - print STDERR 'No previous mediawiki revision found';
487 + print {*STDERR} 'No previous mediawiki revision found';
488 $lastrevision_number = 0;
489 } else {
490 # Notes are formatted : mediawiki_revision: #number
491 $lastrevision_number = $note_info[1];
492 chomp($lastrevision_number);
493 - print STDERR "Last local mediawiki revision found is ${lastrevision_number}";
493 + print {*STDERR} "Last local mediawiki revision found is ${lastrevision_number}";
494 }
495 return $lastrevision_number;
496 }
@@ -523,7 +523,7 @@ sub get_last_remote_revision {
523
524 my $max_rev_num = 0;
525
526 - print STDERR "Getting last revision id on tracked pages...\n";
526 + print {*STDERR} "Getting last revision id on tracked pages...\n";
527
528 foreach my $page (@pages) {
529 my $id = $page->{pageid};
@@ -544,7 +544,7 @@ sub get_last_remote_revision {
544 $max_rev_num = ($lastrev->{revid} > $max_rev_num ? $lastrev->{revid} : $max_rev_num);
545 }
546
547 - print STDERR "Last remote revision found is $max_rev_num.\n";
547 + print {*STDERR} "Last remote revision found is $max_rev_num.\n";
548 return $max_rev_num;
549 }
550
@@ -597,7 +597,7 @@ sub mediawiki_smudge_filename {
597
598 sub literal_data {
599 my ($content) = @_;
600 - print STDOUT 'data ', bytes::length($content), "\n", $content;
600 + print {*STDOUT} 'data ', bytes::length($content), "\n", $content;
601 return;
602 }
603
@@ -606,9 +606,9 @@ sub literal_data_raw {
606 my ($content) = @_;
607 # Avoid confusion between size in bytes and in characters
608 utf8::downgrade($content);
609 - binmode STDOUT, ':raw';
610 - print STDOUT 'data ', bytes::length($content), "\n", $content;
611 - binmode STDOUT, ':encoding(UTF-8)';
609 + binmode {*STDOUT}, ':raw';
610 + print {*STDOUT} 'data ', bytes::length($content), "\n", $content;
611 + binmode {*STDOUT}, ':encoding(UTF-8)';
612 return;
613 }
614
@@ -616,26 +616,26 @@ sub mw_capabilities {
616 # Revisions are imported to the private namespace
617 # refs/mediawiki/$remotename/ by the helper and fetched into
618 # refs/remotes/$remotename later by fetch.
619 - print STDOUT "refspec refs/heads/*:refs/mediawiki/${remotename}/*\n";
620 - print STDOUT "import\n";
621 - print STDOUT "list\n";
622 - print STDOUT "push\n";
623 - print STDOUT "\n";
619 + print {*STDOUT} "refspec refs/heads/*:refs/mediawiki/${remotename}/*\n";
620 + print {*STDOUT} "import\n";
621 + print {*STDOUT} "list\n";
622 + print {*STDOUT} "push\n";
623 + print {*STDOUT} "\n";
624 return;
625 }
626
627 sub mw_list {
628 # MediaWiki do not have branches, we consider one branch arbitrarily
629 # called master, and HEAD pointing to it.
630 - print STDOUT "? refs/heads/master\n";
631 - print STDOUT "\@refs/heads/master HEAD\n";
632 - print STDOUT "\n";
630 + print {*STDOUT} "? refs/heads/master\n";
631 + print {*STDOUT} "\@refs/heads/master HEAD\n";
632 + print {*STDOUT} "\n";
633 return;
634 }
635
636 sub mw_option {
637 - print STDERR "remote-helper command 'option $_[0]' not yet implemented\n";
638 - print STDOUT "unsupported\n";
637 + print {*STDERR} "remote-helper command 'option $_[0]' not yet implemented\n";
638 + print {*STDOUT} "unsupported\n";
639 return;
640 }
641
@@ -671,11 +671,11 @@ sub fetch_mw_revisions_for_page {
671 $query->{rvstartid} = $result->{'query-continue'}->{revisions}->{rvstartid};
672 }
673 if ($shallow_import && @page_revs) {
674 - print STDERR " Found 1 revision (shallow import).\n";
674 + print {*STDERR} " Found 1 revision (shallow import).\n";
675 @page_revs = sort {$b->{revid} <=> $a->{revid}} (@page_revs);
676 return $page_revs[0];
677 }
678 - print STDERR " Found ${revnum} revision(s).\n";
678 + print {*STDERR} " Found ${revnum} revision(s).\n";
679 return @page_revs;
680 }
681
@@ -687,7 +687,7 @@ sub fetch_mw_revisions {
687 my $n = 1;
688 foreach my $page (@pages) {
689 my $id = $page->{pageid};
690 - print STDERR "page ${n}/", scalar(@pages), ': ', $page->{title}, "\n";
690 + print {*STDERR} "page ${n}/", scalar(@pages), ': ', $page->{title}, "\n";
691 $n++;
692 my @page_revs = fetch_mw_revisions_for_page($page, $id, $fetch_from);
693 @revisions = (@page_revs, @revisions);
@@ -721,42 +721,42 @@ sub import_file_revision {
721 my $author = $commit{author};
722 my $date = $commit{date};
723
724 - print STDOUT "commit refs/mediawiki/${remotename}/master\n";
725 - print STDOUT "mark :${n}\n";
726 - print STDOUT "committer ${author} <${author}\@${wiki_name}> " . $date->epoch . " +0000\n";
724 + print {*STDOUT} "commit refs/mediawiki/${remotename}/master\n";
725 + print {*STDOUT} "mark :${n}\n";
726 + print {*STDOUT} "committer ${author} <${author}\@${wiki_name}> " . $date->epoch . " +0000\n";
727 literal_data($comment);
728
729 # If it's not a clone, we need to know where to start from
730 if (!$full_import && $n == 1) {
731 - print STDOUT "from refs/mediawiki/${remotename}/master^0\n";
731 + print {*STDOUT} "from refs/mediawiki/${remotename}/master^0\n";
732 }
733 if ($content ne DELETED_CONTENT) {
734 - print STDOUT 'M 644 inline ' .
734 + print {*STDOUT} 'M 644 inline ' .
735 fe_escape_path("${title}.mw") . "\n";
736 literal_data($content);
737 if (%mediafile) {
738 - print STDOUT 'M 644 inline '
738 + print {*STDOUT} 'M 644 inline '
739 . fe_escape_path($mediafile{title}) . "\n";
740 literal_data_raw($mediafile{content});
741 }
742 - print STDOUT "\n\n";
742 + print {*STDOUT} "\n\n";
743 } else {
744 - print STDOUT 'D ' . fe_escape_path("${title}.mw") . "\n";
744 + print {*STDOUT} 'D ' . fe_escape_path("${title}.mw") . "\n";
745 }
746
747 # mediawiki revision number in the git note
748 if ($full_import && $n == 1) {
749 - print STDOUT "reset refs/notes/${remotename}/mediawiki\n";
749 + print {*STDOUT} "reset refs/notes/${remotename}/mediawiki\n";
750 }
751 - print STDOUT "commit refs/notes/${remotename}/mediawiki\n";
752 - print STDOUT "committer ${author} <${author}\@${wiki_name}> " . $date->epoch . " +0000\n";
751 + print {*STDOUT} "commit refs/notes/${remotename}/mediawiki\n";
752 + print {*STDOUT} "committer ${author} <${author}\@${wiki_name}> " . $date->epoch . " +0000\n";
753 literal_data('Note added by git-mediawiki during import');
754 if (!$full_import && $n == 1) {
755 - print STDOUT "from refs/notes/${remotename}/mediawiki^0\n";
755 + print {*STDOUT} "from refs/notes/${remotename}/mediawiki^0\n";
756 }
757 - print STDOUT "N inline :${n}\n";
757 + print {*STDOUT} "N inline :${n}\n";
758 literal_data("mediawiki_revision: $commit{mw_revision}");
759 - print STDOUT "\n\n";
759 + print {*STDOUT} "\n\n";
760 return;
761 }
762
@@ -787,7 +787,7 @@ sub mw_import {
787 foreach my $ref (@refs) {
788 mw_import_ref($ref);
789 }
790 - print STDOUT "done\n";
790 + print {*STDOUT} "done\n";
791 return;
792 }
793
@@ -804,30 +804,30 @@ sub mw_import_ref {
804
805 mw_connect_maybe();
806
807 - print STDERR "Searching revisions...\n";
807 + print {*STDERR} "Searching revisions...\n";
808 my $last_local = get_last_local_revision();
809 my $fetch_from = $last_local + 1;
810 if ($fetch_from == 1) {
811 - print STDERR ", fetching from beginning.\n";
811 + print {*STDERR} ", fetching from beginning.\n";
812 } else {
813 - print STDERR ", fetching from here.\n";
813 + print {*STDERR} ", fetching from here.\n";
814 }
815
816 my $n = 0;
817 if ($fetch_strategy eq 'by_rev') {
818 - print STDERR "Fetching & writing export data by revs...\n";
818 + print {*STDERR} "Fetching & writing export data by revs...\n";
819 $n = mw_import_ref_by_revs($fetch_from);
820 } elsif ($fetch_strategy eq 'by_page') {
821 - print STDERR "Fetching & writing export data by pages...\n";
821 + print {*STDERR} "Fetching & writing export data by pages...\n";
822 $n = mw_import_ref_by_pages($fetch_from);
823 } else {
824 - print STDERR qq(fatal: invalid fetch strategy "${fetch_strategy}".\n);
825 - print STDERR "Check your configuration variables remote.${remotename}.fetchStrategy and mediawiki.fetchStrategy\n";
824 + print {*STDERR} qq(fatal: invalid fetch strategy "${fetch_strategy}".\n);
825 + print {*STDERR} "Check your configuration variables remote.${remotename}.fetchStrategy and mediawiki.fetchStrategy\n";
826 exit 1;
827 }
828
829 if ($fetch_from == 1 && $n == 0) {
830 - print STDERR "You appear to have cloned an empty MediaWiki.\n";
830 + print {*STDERR} "You appear to have cloned an empty MediaWiki.\n";
831 # Something has to be done remote-helper side. If nothing is done, an error is
832 # thrown saying that HEAD is referring to unknown object 0000000000000000000
833 # and the clone fails.
@@ -906,7 +906,7 @@ sub mw_import_revids {
906 my $page_title = $result_page->{title};
907
908 if (!exists($pages->{$page_title})) {
909 - print STDERR "${n}/", scalar(@$revision_ids),
909 + print {*STDERR} "${n}/", scalar(@$revision_ids),
910 ": Skipping revision #$rev->{revid} of ${page_title}\n";
911 next;
912 }
@@ -939,7 +939,7 @@ sub mw_import_revids {
939 # If this is a revision of the media page for new version
940 # of a file do one common commit for both file and media page.
941 # Else do commit only for that page.
942 - print STDERR "${n}/", scalar(@$revision_ids), ": Revision #$rev->{revid} of $commit{title}\n";
942 + print {*STDERR} "${n}/", scalar(@$revision_ids), ": Revision #$rev->{revid} of $commit{title}\n";
943 import_file_revision(\%commit, ($fetch_from == 1), $n_actual, \%mediafile);
944 }
945
@@ -953,11 +953,11 @@ sub error_non_fast_forward {
953 # Native git-push would show this after the summary.
954 # We can't ask it to display it cleanly, so print it
955 # ourselves before.
956 - print STDERR "To prevent you from losing history, non-fast-forward updates were rejected\n";
957 - print STDERR "Merge the remote changes (e.g. 'git pull') before pushing again. See the\n";
958 - print STDERR "'Note about fast-forwards' section of 'git push --help' for details.\n";
956 + print {*STDERR} "To prevent you from losing history, non-fast-forward updates were rejected\n";
957 + print {*STDERR} "Merge the remote changes (e.g. 'git pull') before pushing again. See the\n";
958 + print {*STDERR} "'Note about fast-forwards' section of 'git push --help' for details.\n";
959 }
960 - print STDOUT qq(error $_[0] "non-fast-forward"\n);
960 + print {*STDOUT} qq(error $_[0] "non-fast-forward"\n);
961 return 0;
962 }
963
@@ -971,8 +971,8 @@ sub mw_upload_file {
971 my $path = "File:${complete_file_name}";
972 my %hashFiles = get_allowed_file_extensions();
973 if (!exists($hashFiles{$extension})) {
974 - print STDERR "${complete_file_name} is not a permitted file on this wiki.\n";
975 - print STDERR "Check the configuration of file uploads in your mediawiki.\n";
974 + print {*STDERR} "${complete_file_name} is not a permitted file on this wiki.\n";
975 + print {*STDERR} "Check the configuration of file uploads in your mediawiki.\n";
976 return $newrevid;
977 }
978 # Deleting and uploading a file requires a priviledged user
@@ -984,9 +984,9 @@ sub mw_upload_file {
984 reason => $summary
985 };
986 if (!$mediawiki->edit($query)) {
987 - print STDERR "Failed to delete file on remote wiki\n";
988 - print STDERR "Check your permissions on the remote site. Error code:\n";
989 - print STDERR $mediawiki->{error}->{code} . ':' . $mediawiki->{error}->{details};
987 + print {*STDERR} "Failed to delete file on remote wiki\n";
988 + print {*STDERR} "Check your permissions on the remote site. Error code:\n";
989 + print {*STDERR} $mediawiki->{error}->{code} . ':' . $mediawiki->{error}->{details};
990 exit 1;
991 }
992 } else {
@@ -1010,9 +1010,9 @@ sub mw_upload_file {
1010 . $mediawiki->{error}->{details} . "\n";
1011 my $last_file_page = $mediawiki->get_page({title => $path});
1012 $newrevid = $last_file_page->{revid};
1013 - print STDERR "Pushed file: ${new_sha1} - ${complete_file_name}.\n";
1013 + print {*STDERR} "Pushed file: ${new_sha1} - ${complete_file_name}.\n";
1014 } else {
1015 - print STDERR "Empty file ${complete_file_name} not pushed.\n";
1015 + print {*STDERR} "Empty file ${complete_file_name} not pushed.\n";
1016 }
1017 }
1018 return $newrevid;
@@ -1050,7 +1050,7 @@ sub mw_push_file {
1050 if ($extension eq 'mw') {
1051 my $ns = get_mw_namespace_id_for_page($complete_file_name);
1052 if ($ns && $ns == get_mw_namespace_id('File') && (!$export_media)) {
1053 - print STDERR "Ignoring media file related page: ${complete_file_name}\n";
1053 + print {*STDERR} "Ignoring media file related page: ${complete_file_name}\n";
1054 return ($oldrevid, 'ok');
1055 }
1056 my $file_content;
@@ -1078,7 +1078,7 @@ sub mw_push_file {
1078 if (!$result) {
1079 if ($mediawiki->{error}->{code} == 3) {
1080 # edit conflicts, considered as non-fast-forward
1081 - print STDERR 'Warning: Error ' .
1081 + print {*STDERR} 'Warning: Error ' .
1082 $mediawiki->{error}->{code} .
1083 ' from mediwiki: ' . $mediawiki->{error}->{details} .
1084 ".\n";
@@ -1091,13 +1091,13 @@ sub mw_push_file {
1091 }
1092 }
1093 $newrevid = $result->{edit}->{newrevid};
1094 - print STDERR "Pushed file: ${new_sha1} - ${title}\n";
1094 + print {*STDERR} "Pushed file: ${new_sha1} - ${title}\n";
1095 } elsif ($export_media) {
1096 $newrevid = mw_upload_file($complete_file_name, $new_sha1,
1097 $extension, $page_deleted,
1098 $summary);
1099 } else {
1100 - print STDERR "Ignoring media file ${title}\n";
1100 + print {*STDERR} "Ignoring media file ${title}\n";
1101 }
1102 $newrevid = ($newrevid or $oldrevid);
1103 return ($newrevid, 'ok');
@@ -1111,16 +1111,16 @@ sub mw_push {
1111 my ($force, $local, $remote) = $refspec =~ /^(\+)?([^:]*):([^:]*)$/
1112 or die("Invalid refspec for push. Expected <src>:<dst> or +<src>:<dst>\n");
1113 if ($force) {
1114 - print STDERR "Warning: forced push not allowed on a MediaWiki.\n";
1114 + print {*STDERR} "Warning: forced push not allowed on a MediaWiki.\n";
1115 }
1116 if ($local eq "") {
1117 - print STDERR "Cannot delete remote branch on a MediaWiki\n";
1118 - print STDOUT "error ${remote} cannot delete\n";
1117 + print {*STDERR} "Cannot delete remote branch on a MediaWiki\n";
1118 + print {*STDOUT} "error ${remote} cannot delete\n";
1119 next;
1120 }
1121 if ($remote ne 'refs/heads/master') {
1122 - print STDERR "Only push to the branch 'master' is supported on a MediaWiki\n";
1123 - print STDOUT "error ${remote} only master allowed\n";
1122 + print {*STDERR} "Only push to the branch 'master' is supported on a MediaWiki\n";
1123 + print {*STDOUT} "error ${remote} only master allowed\n";
1124 next;
1125 }
1126 if (mw_push_revision($local, $remote)) {
@@ -1129,15 +1129,15 @@ sub mw_push {
1129 }
1130
1131 # Notify Git that the push is done
1132 - print STDOUT "\n";
1132 + print {*STDOUT} "\n";
1133
1134 if ($pushed && $dumb_push) {
1135 - print STDERR "Just pushed some revisions to MediaWiki.\n";
1136 - print STDERR "The pushed revisions now have to be re-imported, and your current branch\n";
1137 - print STDERR "needs to be updated with these re-imported commits. You can do this with\n";
1138 - print STDERR "\n";
1139 - print STDERR " git pull --rebase\n";
1140 - print STDERR "\n";
1135 + print {*STDERR} "Just pushed some revisions to MediaWiki.\n";
1136 + print {*STDERR} "The pushed revisions now have to be re-imported, and your current branch\n";
1137 + print {*STDERR} "needs to be updated with these re-imported commits. You can do this with\n";
1138 + print {*STDERR} "\n";
1139 + print {*STDERR} " git pull --rebase\n";
1140 + print {*STDERR} "\n";
1141 }
1142 return;
1143 }
@@ -1146,7 +1146,7 @@ sub mw_push_revision {
1146 my $local = shift;
1147 my $remote = shift; # actually, this has to be "refs/heads/master" at this point.
1148 my $last_local_revid = get_last_local_revision();
1149 - print STDERR ".\n"; # Finish sentence started by get_last_local_revision()
1149 + print {*STDERR} ".\n"; # Finish sentence started by get_last_local_revision()
1150 my $last_remote_revid = get_last_remote_revision();
1151 my $mw_revision = $last_remote_revid;
1152
@@ -1173,7 +1173,7 @@ sub mw_push_revision {
1173 if ($last_local_revid > 0) {
1174 my $parsed_sha1 = $remoteorigin_sha1;
1175 # Find a path from last MediaWiki commit to pushed commit
1176 - print STDERR "Computing path from local to remote ...\n";
1176 + print {*STDERR} "Computing path from local to remote ...\n";
1177 my @local_ancestry = split(/\n/, run_git("rev-list --boundary --parents ${local} ^${parsed_sha1}"));
1178 my %local_ancestry;
1179 foreach my $line (@local_ancestry) {
@@ -1188,7 +1188,7 @@ sub mw_push_revision {
1188 while ($parsed_sha1 ne $HEAD_sha1) {
1189 my $child = $local_ancestry{$parsed_sha1};
1190 if (!$child) {
1191 - printf STDERR "Cannot find a path in history from remote commit to last commit\n";
1191 + print {*STDERR} "Cannot find a path in history from remote commit to last commit\n";
1192 return error_non_fast_forward($remote);
1193 }
1194 push(@commit_pairs, [$parsed_sha1, $child]);
@@ -1197,7 +1197,7 @@ sub mw_push_revision {
1197 } else {
1198 # No remote mediawiki revision. Export the whole
1199 # history (linearized with --first-parent)
1200 - print STDERR "Warning: no common ancestor, pushing complete history\n";
1200 + print {*STDERR} "Warning: no common ancestor, pushing complete history\n";
1201 my $history = run_git("rev-list --first-parent --children ${local}");
1202 my @history = split(/\n/, $history);
1203 @history = @history[1..$#history];
@@ -1245,7 +1245,7 @@ sub mw_push_revision {
1245 }
1246 }
1247
1248 - print STDOUT "ok ${remote}\n";
1248 + print {*STDOUT} "ok ${remote}\n";
1249 return 1;
1250 }
1251
@@ -1296,7 +1296,7 @@ sub get_mw_namespace_id {
1296 }
1297
1298 if (!exists $namespace_id{$name}) {
1299 - print STDERR "Namespace ${name} not found in cache, querying the wiki ...\n";
1299 + print {*STDERR} "Namespace ${name} not found in cache, querying the wiki ...\n";
1300 # NS not found => get namespace id from MW and store it in
1301 # configuration file.
1302 my $query = {
@@ -1321,7 +1321,7 @@ sub get_mw_namespace_id {
1321 my $id;
1322
1323 unless (defined $ns) {
1324 - print STDERR "No such namespace ${name} on MediaWiki.\n";
1324 + print {*STDERR} "No such namespace ${name} on MediaWiki.\n";
1325 $ns = {is_namespace => 0};
1326 $namespace_id{$name} = $ns;
1327 }