Re: [PATCH v2 16/22] git-remote-mediawiki: Modify strings for a better coding-style

2013-06-08 Thread Célestin Matte
Le 08/06/2013 02:39, Eric Sunshine a écrit :
 On Fri, Jun 7, 2013 at 5:42 PM, Célestin Matte
 celestin.ma...@ensimag.fr wrote:
 - strings which don't need interpolation are single-quoted for more clarity 
 and
 slight gain of performance
 - interpolation is preferred over concatenation in many cases, for more 
 clarity
 - variables are always used with the ${} operator inside strings
 - strings including double-quotes are written with qq() so that the quotes do
 not have to be escaped
 
 Distinct changes could (IMHO) be split into separate patches for easier 
 review.

This commit is a real pain to cut into 3 distinctive ones. Is this
really necessary?
I will do it if it is, of course.


-- 
Célestin Matte
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 16/22] git-remote-mediawiki: Modify strings for a better coding-style

2013-06-08 Thread Eric Sunshine
On Sat, Jun 8, 2013 at 4:32 PM, Célestin Matte
celestin.ma...@ensimag.fr wrote:
 Le 08/06/2013 02:39, Eric Sunshine a écrit :
 On Fri, Jun 7, 2013 at 5:42 PM, Célestin Matte
 celestin.ma...@ensimag.fr wrote:
 - strings which don't need interpolation are single-quoted for more clarity 
 and
 slight gain of performance
 - interpolation is preferred over concatenation in many cases, for more 
 clarity
 - variables are always used with the ${} operator inside strings
 - strings including double-quotes are written with qq() so that the quotes 
 do
 not have to be escaped

 Distinct changes could (IMHO) be split into separate patches for easier 
 review.

 This commit is a real pain to cut into 3 distinctive ones. Is this
 really necessary?
 I will do it if it is, of course.

[I think you meant that it would be split into 4 patches.]

The final decision is up to the submitter (you) and the people signing
off on and accepting the patch (Matthieu and Junio).

Speaking merely as a person reviewing the patch series, I can say that
mixing conceptually unrelated changes into a single patch makes review
more onerous since it requires repeatedly switching mental gears
(often from line to line or even within a single line). Patches
involving simple mechanical changes typically are easy to review,
even when the patches are lengthy. In this case, however, that length
coupled with the mental gear switching, makes the review process more
burdensome that it need be.

Even if you decide ultimately not to bother splitting the patch,
ease-of-review and one-conceptual-change-per-patch are useful notions
to keep in mind for future submissions.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 16/22] git-remote-mediawiki: Modify strings for a better coding-style

2013-06-07 Thread Eric Sunshine
On Fri, Jun 7, 2013 at 5:42 PM, Célestin Matte
celestin.ma...@ensimag.fr wrote:
 - strings which don't need interpolation are single-quoted for more clarity 
 and
 slight gain of performance
 - interpolation is preferred over concatenation in many cases, for more 
 clarity
 - variables are always used with the ${} operator inside strings
 - strings including double-quotes are written with qq() so that the quotes do
 not have to be escaped

Distinct changes could (IMHO) be split into separate patches for easier review.

 Signed-off-by: Célestin Matte celestin.ma...@ensimag.fr
 Signed-off-by: Matthieu Moy matthieu@grenoble-inp.fr

 Conflicts:

 contrib/mw-to-git/git-remote-mediawiki.perl

Conflict information is not interesting to reviewers or even in final
commit messages since (hopefully) you will have resolved conflicts
before committing. They can be stripped.

More below.

 ---
  contrib/mw-to-git/git-remote-mediawiki.perl |  244 
 +--
  1 file changed, 121 insertions(+), 123 deletions(-)

 diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl 
 b/contrib/mw-to-git/git-remote-mediawiki.perl
 index f37488b..2d4ea1d 100755
 --- a/contrib/mw-to-git/git-remote-mediawiki.perl
 +++ b/contrib/mw-to-git/git-remote-mediawiki.perl
 @@ -199,10 +199,10 @@ sub mw_connect_maybe {
lgdomain = $wiki_domain};
 if ($mediawiki-login($request)) {
 Git::credential \%credential, 'approve';
 -   print STDERR Logged in mediawiki user 
 \$credential{username}\.\n;
 +   print STDERR qq(Logged in mediawiki user 
 $credential{username}.\n);
 } else {
 -   print STDERR Failed to log in mediawiki user 
 \$credential{username}\ on $url\n;
 -   print STDERR   (error  .
 +   print {*STDERR} qq(Failed to log in mediawiki user 
 $credential{username} on ${url}\n);
 +   print {*STDERR} '  (error ' .

This change from patch 17/22 (adding braces around file handles)
sneaked in early with this patch (16/22).

 $mediawiki-{error}-{code} . ': ' .
 $mediawiki-{error}-{details} . )\n;
 Git::credential \%credential, 'reject';
 @@ -473,27 +473,27 @@ sub download_mw_mediafile {
 if ($response-code == 200) {
 return $response-decoded_content;
 } else {
 -   print STDERR Error downloading mediafile from :\n;
 -   print STDERR URL: $download_url\n;
 -   print STDERR Server response:  . $response-code .   . 
 $response-message . \n;
 +   print {*STDERR} Error downloading mediafile from :\n;
 +   print {*STDERR} URL: ${download_url}\n;
 +   print {*STDERR} 'Server response: ' . $response-code . q{ } 
 . $response-message . \n;

Ditto: Sneak in from 17/22.

 exit 1;
 }
  }

  sub get_last_local_revision {
 # Get note regarding last mediawiki revision
 -   my $note = run_git(notes --ref=$remotename/mediawiki show 
 refs/mediawiki/$remotename/master 2/dev/null);
 +   my $note = run_git(notes --ref=${remotename}/mediawiki show 
 refs/mediawiki/${remotename}/master 2/dev/null);
 my @note_info = split(/ /, $note);

 my $lastrevision_number;
 -   if (!(defined($note_info[0])  $note_info[0] eq 
 mediawiki_revision:)) {
 -   print STDERR No previous mediawiki revision found;
 +   if (!(defined($note_info[0])  $note_info[0] eq 
 'mediawiki_revision:')) {
 +   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;
  }
 @@ -690,8 +690,7 @@ sub fetch_mw_revisions {
 my $n = 1;
 foreach my $page (@pages) {
 my $id = $page-{pageid};
 -
 -   print STDERR page $n/, scalar(@pages), : . $page-{title} 
 .\n;
 +   print {*STDERR} page ${n}/, scalar(@pages), ': ', 
 $page-{title}, \n;

Again 17/22.

 $n++;
 my @page_revs = fetch_mw_revisions_for_page($page, $id, 
 $fetch_from);
 @revisions = (@page_revs, @revisions);
 @@ -705,7 +704,7 @@ sub fe_escape_path {
  $path =~ s/\\//g;
  $path =~ s//\\/g;
  $path =~ s/\n/\\n/g;
 -return '' . $path . '';
 +return qq(${path});
  }

  sub import_file_revision {
--
To unsubscribe from this list: send the line unsubscribe git in
the body