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 v2 07/22] git-remote-mediawiki: Change style of some regular expressions
Date: Fri, 7 Jun 2013 23:42:08 +0200 [thread overview]
Message-ID: <1370641344-4253-8-git-send-email-celestin.matte@ensimag.fr> (raw)
In-Reply-To: <1370641344-4253-1-git-send-email-celestin.matte@ensimag.fr>
- Remove m modifier when useless (m// and // was used randomly; this makes the
code more coherent)
- Remove stringy split (split('c', ...) instead of split(/c/, ...))
- Use {}{} instead of /// when slashes are used inside the regexp so as not to
escape it.
A "split ' '" is turned into a "split / /", which changes its behaviour: the old
method matched a run of whtespaces (/\s*/), while the new one will match a
single whitespace, which is what we want here.
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 | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
index a5c963b..482cd95 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -121,7 +121,7 @@ chomp($dumb_push);
$dumb_push = ($dumb_push eq "true");
my $wiki_name = $url;
-$wiki_name =~ s/[^\/]*:\/\///;
+$wiki_name =~ s{[^/]*://}{};
# If URL is like http://user:password@example.com/, we clearly don't
# want the password in $wiki_name. While we're there, also remove user
# and '@' sign, to avoid author like MWUser@HTTPUser@host.com
@@ -565,7 +565,7 @@ sub mediawiki_smudge {
sub mediawiki_clean_filename {
my $filename = shift;
- $filename =~ s/@{[SLASH_REPLACEMENT]}/\//g;
+ $filename =~ s{$SLASH_REPLACEMENT}{/}g;
# [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded.
# Do a variant of URL-encoding, i.e. looks like URL-encoding,
# but with _ added to prevent MediaWiki from thinking this is
@@ -579,7 +579,7 @@ sub mediawiki_clean_filename {
sub mediawiki_smudge_filename {
my $filename = shift;
- $filename =~ s/\//@{[SLASH_REPLACEMENT]}/g;
+ $filename =~ s{/}{$SLASH_REPLACEMENT}g;
$filename =~ s/ /_/g;
# Decode forbidden characters encoded in mediawiki_clean_filename
$filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf("%c", hex($1))/ge;
@@ -762,7 +762,7 @@ sub get_more_refs {
my @refs;
while (1) {
my $line = <STDIN>;
- if ($line =~ m/^$cmd (.*)$/) {
+ if ($line =~ /^$cmd (.*)$/) {
push(@refs, $1);
} elsif ($line eq "\n") {
return @refs;
@@ -1168,11 +1168,11 @@ sub mw_push_revision {
my @local_ancestry = split(/\n/, run_git("rev-list --boundary --parents $local ^$parsed_sha1"));
my %local_ancestry;
foreach my $line (@local_ancestry) {
- if (my ($child, $parents) = $line =~ m/^-?([a-f0-9]+) ([a-f0-9 ]+)/) {
- foreach my $parent (split(' ', $parents)) {
+ if (my ($child, $parents) = $line =~ /^-?([a-f0-9]+) ([a-f0-9 ]+)/) {
+ foreach my $parent (split(/ /, $parents)) {
$local_ancestry{$parent} = $child;
}
- } elsif (!$line =~ m/^([a-f0-9]+)/) {
+ } elsif (!$line =~ /^([a-f0-9]+)/) {
die "Unexpected output from git rev-list: $line";
}
}
@@ -1190,10 +1190,10 @@ sub mw_push_revision {
# history (linearized with --first-parent)
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);
+ my @history = split(/\n/, $history);
@history = @history[1..$#history];
foreach my $line (reverse @history) {
- my @commit_info_split = split(/ |\n/, $line);
+ my @commit_info_split = split(/[ \n]/, $line);
push(@commit_pairs, \@commit_info_split);
}
}
@@ -1272,7 +1272,7 @@ sub get_mw_namespace_id {
# Look at configuration file, if the record for that namespace is
# already cached. Namespaces are stored in form:
# "Name_of_namespace:Id_namespace", ex.: "File:6".
- my @temp = split(/[\n]/, run_git("config --get-all remote."
+ my @temp = split(/\n/, run_git("config --get-all remote."
. $remotename .".namespaceCache"));
chomp(@temp);
foreach my $ns (@temp) {
--
1.7.9.5
next prev parent reply other threads:[~2013-06-07 21:43 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-07 21:42 [PATCH v2 00/22] git-remote-mediawiki: Follow perlcritic's recommandations Célestin Matte
2013-06-07 21:42 ` [PATCH v2 01/22] git-remote-mediawiki: Replace :utf8 by :encoding(UTF-8) Célestin Matte
2013-06-07 21:42 ` [PATCH v2 02/22] git-remote-mediawiki: Use the Readonly module instead of the constant pragma Célestin Matte
2013-06-08 3:23 ` Jeff King
2013-06-08 8:51 ` Benoît Person
2013-06-08 13:01 ` Célestin Perdu
2013-06-08 17:31 ` Jeff King
2013-06-08 18:27 ` Matthieu Moy
2013-06-07 21:42 ` [PATCH v2 03/22] git-remote-mediawiki: Always end a subroutine with a return Célestin Matte
2013-06-07 21:42 ` [PATCH v2 04/22] git-remote-mediawiki: Move a variable declaration at the top of the code Célestin Matte
2013-06-07 21:42 ` [PATCH v2 05/22] git-remote-mediawiki: Change syntax of map calls Célestin Matte
2013-06-07 21:42 ` [PATCH v2 06/22] git-remote-mediawiki: Rewrite unclear line of instructions Célestin Matte
2013-06-07 21:42 ` Célestin Matte [this message]
2013-06-08 0:12 ` [PATCH v2 07/22] git-remote-mediawiki: Change style of some regular expressions Eric Sunshine
2013-06-07 21:42 ` [PATCH v2 08/22] git-remote-mediawiki: Add newline in the end of die() error messages Célestin Matte
2013-06-07 21:42 ` [PATCH v2 09/22] git-remote-mediawiki: Change the name of a variable Célestin Matte
2013-06-07 21:42 ` [PATCH v2 10/22] git-remote-mediawiki: Turn double-negated expressions into simple expressions Célestin Matte
2013-06-07 21:42 ` [PATCH v2 11/22] git-remote-mediawiki: Remove unused variable $entry Célestin Matte
2013-06-07 21:42 ` [PATCH v2 12/22] git-remote-mediawiki: Rename a variable ($last) which has the name of a keyword Célestin Matte
2013-06-07 21:42 ` [PATCH v2 13/22] git-remote-mediawiki: Assign a variable as undef and make proper indentation Célestin Matte
2013-06-07 21:42 ` [PATCH v2 14/22] git-remote-mediawiki: Check return value of open + remove import of unused open2 Célestin Matte
2013-06-08 0:14 ` Eric Sunshine
2013-06-08 15:54 ` Célestin Matte
2013-06-08 18:41 ` Matthieu Moy
2013-06-08 18:45 ` Célestin Matte
2013-06-08 19:04 ` Matthieu Moy
2013-06-09 4:52 ` Eric Sunshine
2013-06-07 21:42 ` [PATCH v2 15/22] git-remote-mediawiki: Put long code into a subroutine Célestin Matte
2013-06-08 0:27 ` Eric Sunshine
2013-06-07 21:42 ` [PATCH v2 16/22] git-remote-mediawiki: Modify strings for a better coding-style Célestin Matte
2013-06-08 0:39 ` Eric Sunshine
2013-06-08 20:32 ` Célestin Matte
2013-06-09 4:44 ` Eric Sunshine
2013-06-07 21:42 ` [PATCH v2 17/22] git-remote-mediawiki: Brace file handles for print for more clarity Célestin Matte
2013-06-08 0:42 ` Eric Sunshine
2013-06-07 21:42 ` [PATCH v2 18/22] git-remote-mediawiki: Replace "unless" statements with negated "if" statements Célestin Matte
2013-06-07 21:42 ` [PATCH v2 19/22] git-remote-mediawiki: Don't use quotes for empty strings Célestin Matte
2013-06-07 21:42 ` [PATCH v2 20/22] git-remote-mediawiki: Put non-trivial numeric values in constants Célestin Matte
2013-06-07 21:42 ` [PATCH v2 21/22] git-remote-mediawiki: Fix a typo ("mediwiki" instead of "mediawiki") Célestin Matte
2013-06-07 21:42 ` [PATCH v2 22/22] git-remote-mediawiki: Clearly rewrite double dereference Célestin Matte
2013-06-07 23:34 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1370641344-4253-8-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.
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 NNTP newsgroup(s).