{"thread":{"id":"34122","subject":"[PATCH/RFC V2 0/4] git-remote-mediawiki: new tool to preview local changes without pushing","startedAt":"2013-06-13T10:07:15Z","lastAt":"2013-06-24T17:23:48Z","messageCount":17,"participants":["benoit.person@ensimag.fr","Matthieu Moy","Benoît Person","Junio C Hamano","Jeff King","Benoit Person"],"isPatch":true,"patchVersion":2,"patchTotal":4},"messages":[{"id":"220705","messageId":"1371118039-18925-1-git-send-email-benoit.person@ensimag.fr","threadId":"34122","inReplyTo":null,"subject":"[PATCH/RFC V2 0/4] git-remote-mediawiki: new tool to preview local changes without pushing","fromName":"","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-06-13T10:07:15Z","receivedAt":"2013-06-13T10:07:15Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"From: Benoit Person <benoit.person@ensimag.fr>\n\nThe #7 issue on git-mediawiki's issue tracker [1] states that the ability to\npreview content without pushing would be a nice thing to have.\n\nThis serie is a second attempt to achieve it:\n  - It adds a new GitMediawiki.pm package to share code between the new tool and \n    `git-remote-mediawiki.perl`. (PATCH 1 & 2)\n  - It creates a new \"meta\"-command `git mw` with subcommand handling (PATCH 3)\n  - It adds a new subcommand named `preview` to `git mw` (PATCH 4)\n\nchanges from the V0:\n  - add new package GitMediawiki\n    - move some of git-remote-mediawiki functions into the package\n    - update git-remote-mediawiki to use those \"moved\" functions\n    - add a hacky-way to install it in the Makefile\n    - use it in the new git mw tool\n  - add a way to give to the preview tool blobs as argument\n  - add a fallback when the upstream's branch remote is not a mediawiki remote\n  - update the `autoload` option to use `git web--browse` and not `xdg-open`\n  - update the way we find the upstream's branch remote name\n\nFor now, this PATCH/RFC is based on the 'next' branch merged with the \nbp/mediawiki-credential patch. For the final version, I will try \nto rebase it on celestin's work with perlcritic.\n\n[1] https://github.com/moy/Git-Mediawiki/issues/7\n\nBenoit Person (4):\n  git-mw: Introduction of GitMediawiki.pm\n  git-mw: Moving some functions from git-remote-mediawiki.perl to\n    GitMediawiki.pm\n  git-mw: Adding git-mw.perl script\n  git-mw: Adding preview tool in git-mw.perl\n\n contrib/mw-to-git/GitMediawiki.pm           |  94 +++++++++++\n contrib/mw-to-git/Makefile                  |  22 ++-\n contrib/mw-to-git/git-mw.perl               | 247 ++++++++++++++++++++++++++++\n contrib/mw-to-git/git-remote-mediawiki.perl |  80 ++-------\n 4 files changed, 373 insertions(+), 70 deletions(-)\n create mode 100644 contrib/mw-to-git/GitMediawiki.pm\n create mode 100644 contrib/mw-to-git/git-mw.perl\n\n-- \n1.8.3.GIT\n"},{"id":"220706","messageId":"1371118039-18925-2-git-send-email-benoit.person@ensimag.fr","threadId":"34122","inReplyTo":"1371118039-18925-1-git-send-email-benoit.person@ensimag.fr","subject":"[PATCH/RFC 1/4] git-mw: Introduction of GitMediawiki.pm","fromName":"","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-06-13T10:07:16Z","receivedAt":"2013-06-13T10:07:16Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"From: Benoit Person <benoit.person@ensimag.fr>\n\nThe GitMediawiki.pm goal is to share code betwwen several scripts in\nGit-Mediawiki (for now, git-mw.perl introduced in this patch serie and\ngit-remote-mediawiki.perl)\n\nSigned-off-by: Benoit Person <benoit.person@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n\n---\n contrib/mw-to-git/GitMediawiki.pm | 24 ++++++++++++++++++++++++\n contrib/mw-to-git/Makefile        | 19 +++++++++++++++++--\n 2 files changed, 41 insertions(+), 2 deletions(-)\n create mode 100644 contrib/mw-to-git/GitMediawiki.pm\n\ndiff --git a/contrib/mw-to-git/GitMediawiki.pm b/contrib/mw-to-git/GitMediawiki.pm\nnew file mode 100644\nindex 0000000..8a0ffc7\n--- /dev/null\n+++ b/contrib/mw-to-git/GitMediawiki.pm\n@@ -0,0 +1,24 @@\n+package GitMediawiki;\n+\n+use 5.008;\n+use strict;\n+use Git;\n+\n+BEGIN {\n+\n+our ($VERSION, @ISA, @EXPORT, @EXPORT_OK);\n+\n+# Totally unstable API.\n+$VERSION = '0.01';\n+\n+require Exporter;\n+\n+@ISA = qw(Exporter);\n+\n+@EXPORT = ();\n+\n+# Methods which can be called as standalone functions as well:\n+@EXPORT_OK = ();\n+}\n+\n+1; # Famous last words\n\\ No newline at end of file\ndiff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile\nindex f149719..fe30e7f 100644\n--- a/contrib/mw-to-git/Makefile\n+++ b/contrib/mw-to-git/Makefile\n@@ -4,14 +4,29 @@\n #\n ## Build git-remote-mediawiki\n \n+GIT_MEDIAWIKI_PM=GitMediawiki.pm\n SCRIPT_PERL=git-remote-mediawiki.perl\n GIT_ROOT_DIR=../..\n HERE=contrib/mw-to-git/\n \n SCRIPT_PERL_FULL=$(patsubst %,$(HERE)/%,$(SCRIPT_PERL))\n+INSTLIBDIR=$(shell $(MAKE) -C $(GIT_ROOT_DIR)/perl \\\n+                -s --no-print-directory instlibdir)\n \n all: build\n \n-build install clean:\n+install_pm:\n+\tcp $(GIT_MEDIAWIKI_PM) $(INSTLIBDIR)\n+\n+build:\n+\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=$(SCRIPT_PERL_FULL) \\\n+                build-perl-script\n+\n+install: install_pm\n+\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=$(SCRIPT_PERL_FULL) \\\n+                install-perl-script\n+\n+clean:\n \t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=$(SCRIPT_PERL_FULL) \\\n-                $@-perl-script\n+                clean-perl-script\n+\trm $(INSTLIBDIR)/$(GIT_MEDIAWIKI_PM)\n\\ No newline at end of file\n-- \n1.8.3.GIT\n"},{"id":"220707","messageId":"1371118039-18925-3-git-send-email-benoit.person@ensimag.fr","threadId":"34122","inReplyTo":"1371118039-18925-1-git-send-email-benoit.person@ensimag.fr","subject":"[PATCH/RFC 2/4] git-mw: Moving some functions from git-remote-mediawiki.perl to GitMediawiki.pm","fromName":"","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-06-13T10:07:17Z","receivedAt":"2013-06-13T10:07:17Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"From: Benoit Person <benoit.person@ensimag.fr>\n\nMoving mediawiki_clean_filename, mediawiki_smudge_filename and mw_connect_maybe\nSince we have a clean namespace in a perl module, we also rename them into more\nconcise ones (clean_filename, smudge_filename and connect_maybe). It also\ndelete the side effects of mw_connect_maybe requiring it to be called with\nparameters and returning the new instance of the Mediawiki::Api if it needs to\nbe created\n\nSigned-off-by: Benoit Person <benoit.person@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n\n---\n contrib/mw-to-git/GitMediawiki.pm           | 72 +++++++++++++++++++++++++-\n contrib/mw-to-git/git-remote-mediawiki.perl | 80 +++++------------------------\n 2 files changed, 84 insertions(+), 68 deletions(-)\n\ndiff --git a/contrib/mw-to-git/GitMediawiki.pm b/contrib/mw-to-git/GitMediawiki.pm\nindex 8a0ffc7..acf4e43 100644\n--- a/contrib/mw-to-git/GitMediawiki.pm\n+++ b/contrib/mw-to-git/GitMediawiki.pm\n@@ -18,7 +18,77 @@ require Exporter;\n @EXPORT = ();\n \n # Methods which can be called as standalone functions as well:\n-@EXPORT_OK = ();\n+@EXPORT_OK = qw(clean_filename smudge_filename connect_maybe);\n+}\n+\n+# Mediawiki filenames can contain forward slashes. This variable decides by which pattern they should be replaced\n+use constant SLASH_REPLACEMENT => '%2F';\n+\n+sub clean_filename {\n+\tmy $filename = shift;\n+\t$filename =~ s{@{[SLASH_REPLACEMENT]}}{/}g;\n+\t# [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded.\n+\t# Do a variant of URL-encoding, i.e. looks like URL-encoding,\n+\t# but with _ added to prevent MediaWiki from thinking this is\n+\t# an actual special character.\n+\t$filename =~ s/[\\[\\]\\{\\}\\|]/sprintf(\"_%%_%x\", ord($&))/ge;\n+\t# If we use the uri escape before\n+\t# we should unescape here, before anything\n+\n+\treturn $filename;\n+}\n+\n+sub smudge_filename {\n+\tmy $filename = shift;\n+\t$filename =~ s{/}{@{[SLASH_REPLACEMENT]}}g;\n+\t$filename =~ s/ /_/g;\n+\t# Decode forbidden characters encoded in clean_filename\n+\t$filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf('%c', hex($1))/ge;\n+\treturn $filename;\n+}\n+\n+sub connect_maybe {\n+\tmy $wiki = shift;\n+\tif ($wiki) {\n+\t\treturn $wiki;\n+\t}\n+\n+\tmy $remote_name = shift;\n+\tmy $remote_url = shift;\n+\tmy ($wiki_login, $wiki_password, $wiki_domain);\n+\n+\tgit_cmd_try {\n+\t\t$wiki_login = Git::config(\"remote.${remote_name}.mwLogin\");\n+\t\t$wiki_password = Git::config(\"remote.${remote_name}.mwPassword\");\n+\t\t$wiki_domain = Git::config(\"remote.${remote_name}.mwDomain\");}\n+\t\t\"%s failed w/ code %d\";\n+\n+\t$wiki = MediaWiki::API->new;\n+\t$wiki->{config}->{api_url} = \"${remote_url}/api.php\";\n+\tif ($wiki_login) {\n+\t\tmy %credential = (\n+\t\t\t'url' => $remote_url,\n+\t\t\t'username' => $wiki_login,\n+\t\t\t'password' => $wiki_password\n+\t\t);\n+\t\tGit::credential(\\%credential);\n+\t\tmy $request = {lgname => $credential{username},\n+\t\t\t       lgpassword => $credential{password},\n+\t\t\t       lgdomain => $wiki_domain};\n+\t\tif ($wiki->login($request)) {\n+\t\t\tGit::credential(\\%credential, 'approve');\n+\t\t\tprint {*STDERR} qq(Logged in mediawiki user \"$credential{username}\".\\n);\n+\t\t} else {\n+\t\t\tprint {*STDERR} qq(Failed to log in mediawiki user \"$credential{username}\" on ${remote_url}\\n);\n+\t\t\tprint {*STDERR} '  (error ' .\n+\t\t\t\t$wiki->{error}->{code} . ': ' .\n+\t\t\t\t$wiki->{error}->{details} . \")\\n\";\n+\t\t\tGit::credential(\\%credential, 'reject');\n+\t\t\texit 1;\n+\t\t}\n+\t}\n+\n+\treturn $wiki;\n }\n \n 1; # Famous last words\n\\ No newline at end of file\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex be17e89..d679035 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -13,6 +13,8 @@\n \n use strict;\n use MediaWiki::API;\n+use Git;\n+use GitMediawiki qw(clean_filename smudge_filename connect_maybe);\n use DateTime::Format::ISO8601;\n \n # By default, use UTF-8 to communicate with Git and the user\n@@ -24,9 +26,6 @@ use IPC::Open2;\n \n use warnings;\n \n-# Mediawiki filenames can contain forward slashes. This variable decides by which pattern they should be replaced\n-use constant SLASH_REPLACEMENT => \"%2F\";\n-\n # It's not always possible to delete pages (may require some\n # privileges). Deleted pages are replaced with this content.\n use constant DELETED_CONTENT => \"[[Category:Deleted]]\\n\";\n@@ -159,36 +158,6 @@ while (<STDIN>) {\n # MediaWiki API instance, created lazily.\n my $mediawiki;\n \n-sub mw_connect_maybe {\n-\tif ($mediawiki) {\n-\t\treturn;\n-\t}\n-\t$mediawiki = MediaWiki::API->new;\n-\t$mediawiki->{config}->{api_url} = \"$url/api.php\";\n-\tif ($wiki_login) {\n-\t\tmy %credential = (\n-\t\t\t'url' => $url,\n-\t\t\t'username' => $wiki_login,\n-\t\t\t'password' => $wiki_passwd\n-\t\t);\n-\t\tGit::credential(\\%credential);\n-\t\tmy $request = {lgname => $credential{username},\n-\t\t\t       lgpassword => $credential{password},\n-\t\t\t       lgdomain => $wiki_domain};\n-\t\tif ($mediawiki->login($request)) {\n-\t\t\tGit::credential(\\%credential, 'approve');\n-\t\t\tprint STDERR \"Logged in mediawiki user \\\"$credential{username}\\\".\\n\";\n-\t\t} else {\n-\t\t\tprint STDERR \"Failed to log in mediawiki user \\\"$credential{username}\\\" on $url\\n\";\n-\t\t\tprint STDERR \"  (error \" .\n-\t\t\t\t$mediawiki->{error}->{code} . ': ' .\n-\t\t\t\t$mediawiki->{error}->{details} . \")\\n\";\n-\t\t\tGit::credential(\\%credential, 'reject');\n-\t\t\texit 1;\n-\t\t}\n-\t}\n-}\n-\n sub fatal_mw_error {\n \tmy $action = shift;\n \tprint STDERR \"fatal: could not $action.\\n\";\n@@ -293,7 +262,7 @@ sub get_mw_first_pages {\n \n # Get the list of pages to be fetched according to configuration.\n sub get_mw_pages {\n-\tmw_connect_maybe();\n+\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \n \tprint STDERR \"Listing pages on remote wiki...\\n\";\n \n@@ -480,7 +449,7 @@ my %basetimestamps;\n # avoid a loop onto all tracked pages. This is useful for the fetch-by-rev\n # option.\n sub get_last_global_remote_rev {\n-\tmw_connect_maybe();\n+\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \n \tmy $query = {\n \t\taction => 'query',\n@@ -496,7 +465,7 @@ sub get_last_global_remote_rev {\n # Get the last remote revision concerning the tracked pages and the tracked\n # categories.\n sub get_last_remote_revision {\n-\tmw_connect_maybe();\n+\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \n \tmy %pages_hash = get_mw_pages();\n \tmy @pages = values(%pages_hash);\n@@ -552,29 +521,6 @@ sub mediawiki_smudge {\n \treturn $string.\"\\n\";\n }\n \n-sub mediawiki_clean_filename {\n-\tmy $filename = shift;\n-\t$filename =~ s/@{[SLASH_REPLACEMENT]}/\\//g;\n-\t# [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded.\n-\t# Do a variant of URL-encoding, i.e. looks like URL-encoding,\n-\t# but with _ added to prevent MediaWiki from thinking this is\n-\t# an actual special character.\n-\t$filename =~ s/[\\[\\]\\{\\}\\|]/sprintf(\"_%%_%x\", ord($&))/ge;\n-\t# If we use the uri escape before\n-\t# we should unescape here, before anything\n-\n-\treturn $filename;\n-}\n-\n-sub mediawiki_smudge_filename {\n-\tmy $filename = shift;\n-\t$filename =~ s/\\//@{[SLASH_REPLACEMENT]}/g;\n-\t$filename =~ s/ /_/g;\n-\t# Decode forbidden characters encoded in mediawiki_clean_filename\n-\t$filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf(\"%c\", hex($1))/ge;\n-\treturn $filename;\n-}\n-\n sub literal_data {\n \tmy ($content) = @_;\n \tprint STDOUT \"data \", bytes::length($content), \"\\n\", $content;\n@@ -775,7 +721,7 @@ sub mw_import_ref {\n \t\treturn;\n \t}\n \n-\tmw_connect_maybe();\n+\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \n \tprint STDERR \"Searching revisions...\\n\";\n \tmy $last_local = get_last_local_revision();\n@@ -888,7 +834,7 @@ sub mw_import_revids {\n \t\tmy %commit;\n \t\t$commit{author} = $rev->{user} || 'Anonymous';\n \t\t$commit{comment} = $rev->{comment} || EMPTY_MESSAGE;\n-\t\t$commit{title} = mediawiki_smudge_filename($page_title);\n+\t\t$commit{title} = smudge_filename($page_title);\n \t\t$commit{mw_revision} = $rev->{revid};\n \t\t$commit{content} = mediawiki_smudge($rev->{'*'});\n \n@@ -949,7 +895,7 @@ sub mw_upload_file {\n \t}\n \t# Deleting and uploading a file requires a priviledged user\n \tif ($file_deleted) {\n-\t\tmw_connect_maybe();\n+\t\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \t\tmy $query = {\n \t\t\taction => 'delete',\n \t\t\ttitle => $path,\n@@ -965,7 +911,7 @@ sub mw_upload_file {\n \t\t# Don't let perl try to interpret file content as UTF-8 => use \"raw\"\n \t\tmy $content = run_git(\"cat-file blob $new_sha1\", \"raw\");\n \t\tif ($content ne \"\") {\n-\t\t\tmw_connect_maybe();\n+\t\t\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \t\t\t$mediawiki->{config}->{upload_url} =\n \t\t\t\t\"$url/index.php/Special:Upload\";\n \t\t\t$mediawiki->edit({\n@@ -1013,7 +959,7 @@ sub mw_push_file {\n \tmy $old_sha1 = $diff_info_split[2];\n \tmy $page_created = ($old_sha1 eq NULL_SHA1);\n \tmy $page_deleted = ($new_sha1 eq NULL_SHA1);\n-\t$complete_file_name = mediawiki_clean_filename($complete_file_name);\n+\t$complete_file_name = clean_filename($complete_file_name);\n \n \tmy ($title, $extension) = $complete_file_name =~ /^(.*)\\.([^\\.]*)$/;\n \tif (!defined($extension)) {\n@@ -1036,7 +982,7 @@ sub mw_push_file {\n \t\t\t$file_content = run_git(\"cat-file blob $new_sha1\");\n \t\t}\n \n-\t\tmw_connect_maybe();\n+\t\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \n \t\tmy $result = $mediawiki->edit( {\n \t\t\taction => 'edit',\n@@ -1220,7 +1166,7 @@ sub mw_push_revision {\n }\n \n sub get_allowed_file_extensions {\n-\tmw_connect_maybe();\n+\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \n \tmy $query = {\n \t\taction => 'query',\n@@ -1244,7 +1190,7 @@ my %cached_mw_namespace_id;\n # Return MediaWiki id for a canonical namespace name.\n # Ex.: \"File\", \"Project\".\n sub get_mw_namespace_id {\n-\tmw_connect_maybe();\n+\t$mediawiki = connect_maybe($mediawiki, $remotename, $url);\n \tmy $name = shift;\n \n \tif (!exists $namespace_id{$name}) {\n-- \n1.8.3.GIT\n"},{"id":"220708","messageId":"1371118039-18925-4-git-send-email-benoit.person@ensimag.fr","threadId":"34122","inReplyTo":"1371118039-18925-1-git-send-email-benoit.person@ensimag.fr","subject":"[PATCH/RFC 3/4] git-mw: Adding git-mw.perl script","fromName":"","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-06-13T10:07:18Z","receivedAt":"2013-06-13T10:07:18Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"From: Benoit Person <benoit.person@ensimag.fr>\n\nThis script will be used for all tools and command related to a mediawiki\nremote. In this commit we introduce the tool, the way it parses argument\nand subcommands and an example of subcommand: \"help\". It also updates\nthe Makefile so that the new tool is installed properly.\n\nSigned-off-by: Benoit Person <benoit.person@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n\n---\n contrib/mw-to-git/Makefile    |  7 ++++---\n contrib/mw-to-git/git-mw.perl | 46 +++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 50 insertions(+), 3 deletions(-)\n create mode 100644 contrib/mw-to-git/git-mw.perl\n\ndiff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile\nindex fe30e7f..c0633b1 100644\n--- a/contrib/mw-to-git/Makefile\n+++ b/contrib/mw-to-git/Makefile\n@@ -6,6 +6,7 @@\n \n GIT_MEDIAWIKI_PM=GitMediawiki.pm\n SCRIPT_PERL=git-remote-mediawiki.perl\n+SCRIPT_PERL+=git-mw.perl\n GIT_ROOT_DIR=../..\n HERE=contrib/mw-to-git/\n \n@@ -19,14 +20,14 @@ install_pm:\n \tcp $(GIT_MEDIAWIKI_PM) $(INSTLIBDIR)\n \n build:\n-\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=$(SCRIPT_PERL_FULL) \\\n+\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=\"$(SCRIPT_PERL_FULL)\" \\\n                 build-perl-script\n \n install: install_pm\n-\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=$(SCRIPT_PERL_FULL) \\\n+\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=\"$(SCRIPT_PERL_FULL)\" \\\n                 install-perl-script\n \n clean:\n-\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=$(SCRIPT_PERL_FULL) \\\n+\t$(MAKE) -C $(GIT_ROOT_DIR) SCRIPT_PERL=\"$(SCRIPT_PERL_FULL)\" \\\n                 clean-perl-script\n \trm $(INSTLIBDIR)/$(GIT_MEDIAWIKI_PM)\n\\ No newline at end of file\ndiff --git a/contrib/mw-to-git/git-mw.perl b/contrib/mw-to-git/git-mw.perl\nnew file mode 100644\nindex 0000000..a2f0aa1\n--- /dev/null\n+++ b/contrib/mw-to-git/git-mw.perl\n@@ -0,0 +1,46 @@\n+#!/usr/bin/perl\n+\n+# Copyright (C) 2013\n+#     Benoit Person <benoit.person@ensimag.imag.fr>\n+#     Celestin Matte <celestin.matte@ensimag.imag.fr>\n+# License: GPL v2 or later\n+\n+# Set of tools for git repo with a mediawiki remote.\n+# Documentation & bugtracker: https://github.com/moy/Git-Mediawiki/\n+\n+use strict;\n+use warnings;\n+\n+use Getopt::Long;\n+\n+my %commands = (\n+\t'help' =>\n+\t\t[\\&help, {}, \\&help]\n+);\n+\n+# Search for sub-command\n+my $cmd = $commands{'help'};\n+for (my $i = 0; $i < @ARGV; $i++) {\n+\tif (defined $commands{$ARGV[$i]}) {\n+\t\t$cmd = $commands{$ARGV[$i]};\n+\t\tsplice @ARGV, $i, 1;\n+\t\tlast;\n+\t}\n+};\n+GetOptions( %{$cmd->[1]},\n+\t'help|h' => \\&{$cmd->[2]});\n+\n+# Launch command\n+&{$cmd->[0]};\n+\n+############################## Help Functions ##################################\n+\n+sub help {\n+\tprint <<'END';\n+usage: git mw <command> <args>\n+\n+git mw commands are:\n+    Help        Display help information about git mw\n+END\n+\texit;\n+}\n\\ No newline at end of file\n-- \n1.8.3.GIT\n"},{"id":"220709","messageId":"1371118039-18925-5-git-send-email-benoit.person@ensimag.fr","threadId":"34122","inReplyTo":"1371118039-18925-1-git-send-email-benoit.person@ensimag.fr","subject":"[PATCH/RFC 4/4] git-mw: Adding preview tool in git-mw.perl","fromName":"","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-06-13T10:07:19Z","receivedAt":"2013-06-13T10:07:19Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"From: Benoit Person <benoit.person@ensimag.fr>\n\nThis final commit adds the preview subcommand to git mw. It works as such:\n1- Find the remote name of the current branch's upstream and check if it's a\nmediawiki one.\n1b- If it's not found or if it's not a mediawiki one. It will list all the\nmediawiki remotes configured and ask the user to replay the command with the\n--remote option set.\n2- Parse the content of the local file (or blob) (given as argument) using\nthe distant mediawiki's API\n3- Retrieve the current page on the distant mediawiki\n4- Replaces all content in that page with the newly parsed one\n5- Convert relative links into absolute\n6- Save the result on disk\n\nThe command accepts those options:\n  --autoload | -a tries to launch the newly generated file in the user's\n                  default browser (using git web--browse)\n  --remote | -r provides a way to select the distant mediawiki in which\n                the user wants to preview his file (or blob)\n  --output | -o enables the user to choose the output filename. Default\n                output filename is based on the input filename in which\n                the extension '.mw' is replaced with '.html'\n  --blob | -b tells the script that the last argument is a blob and not\n              a filename\n\nSigned-off-by: Benoit Person <benoit.person@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n\n---\n contrib/mw-to-git/git-mw.perl | 203 +++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 202 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/mw-to-git/git-mw.perl b/contrib/mw-to-git/git-mw.perl\nindex a2f0aa1..79c6cd0 100644\n--- a/contrib/mw-to-git/git-mw.perl\n+++ b/contrib/mw-to-git/git-mw.perl\n@@ -12,10 +12,37 @@ use strict;\n use warnings;\n \n use Getopt::Long;\n+use URI::URL qw(url);\n+use IO::File;\n+use LWP::Simple;\n+use HTML::TreeBuilder;\n+\n+use Git;\n+use MediaWiki::API;\n+use GitMediawiki qw(smudge_filename connect_maybe);\n+\n+#preview parameters\n+my $file_name;\n+my $remote_name = '';\n+my $preview_file_name = '';\n+my $autoload = 0;\n+my $blob = 0;\n+sub file {\n+\t$file_name = shift;\n+\treturn $file_name;\n+}\n \n my %commands = (\n \t'help' =>\n-\t\t[\\&help, {}, \\&help]\n+\t\t[\\&help, {}, \\&help],\n+\t'preview' =>\n+\t\t[\\&preview, {\n+\t\t\t'<>' => \\&file,\n+\t\t\t'output|o=s' => \\$preview_file_name,\n+\t\t\t'remote|r=s' => \\$remote_name,\n+\t\t\t'autoload|a' => \\$autoload,\n+\t\t\t'blob|b' => \\$blob\n+\t\t}, \\&preview_help]\n );\n \n # Search for sub-command\n@@ -33,6 +60,179 @@ GetOptions( %{$cmd->[1]},\n # Launch command\n &{$cmd->[0]};\n \n+############################# Preview Functions ################################\n+\n+sub preview_help {\n+\tprint <<'END';\n+usage: git mw preview [--remote|-r <remote name>] [--autoload|-a]\n+                      [--output|-o <output filename>] <filename>\n+\n+    -r, --remote    Specify which mediawiki should be used\n+    -o, --output    Name of the output file\n+    -a, --autoload  Autoload the page in your default web browser\n+END\n+\texit;\n+}\n+\n+sub preview {\n+\tmy $wiki;\n+\tmy ($remote_url, $wiki_page_name);\n+\tmy ($content, $content_tree, $template, $html_tree, $mw_content_text);\n+\tmy $file_content;\n+\n+\t# file_name argumeent is mandatory\n+\tif (! defined $file_name) {\n+\t\tdie \"File not set, see `git mw help` \\n\";\n+\t}\n+\n+\tif ($blob) { # blob mode\n+\t\t$blob = $file_name;\n+\t\tif ($blob =~ /(.+):(.+)/) {\n+\t\t\t$file_name = $2;\n+\t\t}\n+\t} else { # file mode\n+\t\tif (! -e $file_name) {\n+\t\t\tdie \"File $file_name does not exists \\n\";\n+\t\t}\n+\t}\n+\n+\t# Default preview_file_name is file_name with .html ext\n+\tif ($preview_file_name eq '') {\n+\t\t$preview_file_name = $file_name;\n+\t\t$preview_file_name =~ s/\\.[^.]+$/.html/;\n+\t}\n+\n+\t# Transform file_name into a mediawiki page name\n+\t$wiki_page_name = smudge_filename($file_name);\n+\t$wiki_page_name =~ s/\\.[^.]+$//;\n+\n+\tif ($remote_name eq '') {\n+\t\t# Search current branch upstream branch remote\n+\t\t$remote_name = git_cmd_try {\n+\t\t\tmy $current_branch = \n+\t\t\t\tGit::command_oneline('symbolic-ref', '--short', 'HEAD');\n+\t\t\tGit::config(\"branch.$current_branch.remote\") }\n+\t\t\t\"%s failed w/ code %d\";\n+\n+\t\tif ($remote_name) {\n+\t\t\t$remote_url = mediawiki_remote_url_maybe($remote_name);\n+\t\t}\n+\n+\t\t# Search all possibles mediawiki remotes\n+\t\tif (! $remote_url) {\n+\t\t\tmy @remotes = git_cmd_try {\n+\t\t\t\tGit::command('remote'); }\n+\t\t\t\t\"%s failed w/ code%d\";\n+\n+\t\t\tmy @valid_remotes = ();\n+\t\t\tforeach my $remote (@remotes) {\n+\t\t\t\t$remote_url = mediawiki_remote_url_maybe($remote);\n+\t\t\t\tif ($remote_url) {\n+\t\t\t\t\tpush(@valid_remotes, $remote);\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t\tif ($#valid_remotes == 0) {\n+\t\t\t\tprint \"Can not find any mediawiki remote in this repo. \\n\";\n+\t\t\t\texit 1;\n+\t\t\t} else {\n+\t\t\t\tprint \"There are multiple mediawiki remotes, which of:\\n\";\n+\t\t\t\tforeach my $remote (@remotes) {\n+\t\t\t\t\tprint \"\\t$remote\\n\";\n+\t\t\t\t}\n+\t\t\t\tprint \"do you want ? Use the -r option to specify the remote\\n\";\n+\t\t\t}\n+\n+\t\t\texit 0;\n+\t\t}\n+\t} else {\n+\t\t# Check remote name\n+\t\tmy @remotes = git_cmd_try {\n+\t\t\tGit::command('remote') }\n+\t\t\t\"%s failed w/ code %d\";\n+\t\tgrep { $_ eq $remote_name } @remotes\n+\t\t\tor die \"$remote_name is not a remote\";\n+\t\n+\t\t# Find remote url\n+\t\t$remote_url = mediawiki_remote_url_maybe($remote_name);\n+\t\tif (! $remote_url) {\n+\t\t\tdie \"the remote you selected is not a mediawiki remote\";\n+\t\t}\n+\t}\n+\n+\t# Create and connect to the wiki if necessary\n+\t$wiki = connect_maybe($wiki, $remote_name, $remote_url);\n+\n+\t# Read file content\n+\tif ($blob) {\n+\t\t$file_content = git_cmd_try {\n+\t\t\tGit::command('cat-file', 'blob', $blob); }\n+\t\t\t\"%s failed w/ code %d\";\n+\t} else {\n+\t\topen my $read_fh, \"<\", $file_name\n+\t\t\tor die \"could not open $file_name: $!\";\n+\t\t$file_content = do { local $/ = undef; <$read_fh> };\n+\t\tclose $read_fh;\n+\t}\n+\n+\t# Load template page\n+\t$template = get(\"$remote_url/index.php?title=$wiki_page_name\")\n+\t\tor die \"You need to create $wiki_page_name before previewing it\";\n+\t$html_tree = HTML::TreeBuilder->new;\n+\t$html_tree->parse($template);\n+\n+\t# Load new content\n+\t$content = $wiki->api({\n+\t\taction => 'parse',\n+\t\ttext => $file_content,\n+\t\ttitle => $wiki_page_name\n+\t}) or die 'No response from distant mediawiki';\n+\t$content = $content->{'parse'}->{'text'}->{'*'};\n+\t$content_tree = HTML::TreeBuilder->new;\n+\t$content_tree->parse($content);\n+\n+\t# Replace old content with new one\n+\t$mw_content_text = $html_tree->look_down('id', 'mw-content-text');\n+\t$mw_content_text->delete_content();\n+\t$mw_content_text->push_content($content_tree);\n+\n+\t# Transform relative links into absolute ones\n+\tfor (@{ $html_tree->extract_links() }) {\n+\t\tmy ($link, $element, $attr) = @$_;\n+\t\tmy $url = url($link)->canonical;\n+\t\t$element->attr($attr, URI->new_abs($url, $remote_url));\n+\t}\n+\n+\t# Save the preview file\n+\tmy $save_fh = IO::File->new($preview_file_name, 'w')\n+\t\tor die \"Could not open: $!\";\n+\t$save_fh->print($html_tree->as_HTML);\n+\n+\t# Auto-loading in browser\n+\tif ($autoload) {\n+\t\tsystem('git', 'web--browse', $preview_file_name);\n+\t} else {\n+\t\tprint \"preview file saved as: $preview_file_name\\n\";\n+\t}\n+\n+\texit;\n+}\n+\n+sub mediawiki_remote_url_maybe {\n+\tmy $remote = shift;\n+\n+\t# Find remote url\n+\tmy $remote_url = git_cmd_try {\n+\t\tGit::config(\"remote.$remote.url\") }\n+\t\t\"%s failed w/ code %d\";\n+\tif ($remote_url =~ s/mediawiki::(.*)/$1/) {\n+\t\treturn url($remote_url)->canonical;\n+\t} else {\n+\t\treturn undef;\n+\t}\n+\n+}\n+\n ############################## Help Functions ##################################\n \n sub help {\n@@ -41,6 +241,7 @@ usage: git mw <command> <args>\n \n git mw commands are:\n     Help        Display help information about git mw\n+    Preview \tParse and render local file into HTML\n END\n \texit;\n }\n\\ No newline at end of file\n-- \n1.8.3.GIT\n"},{"id":"220712","messageId":"vpqa9muuudi.fsf@anie.imag.fr","threadId":"34122","inReplyTo":"1371118039-18925-1-git-send-email-benoit.person@ensimag.fr","subject":"Re: [PATCH/RFC V2 0/4] git-remote-mediawiki: new tool to preview local changes without pushing","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-13T11:23:37Z","receivedAt":"2013-06-13T11:23:37Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"benoit.person@ensimag.fr writes:\n\n> For now, this PATCH/RFC is based on the 'next' branch merged with the \n> bp/mediawiki-credential patch. For the final version, I will try \n> to rebase it on celestin's work with perlcritic.\n\nActually, it seems based on an old \"next\" branch. This hunk\n\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -13,6 +13,8 @@\n \n use strict;\n use MediaWiki::API;\n+use Git;\n\nFails to apply because \"use Git;\" is already there in today's next.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"220715","messageId":"vpq8v2etetz.fsf@anie.imag.fr","threadId":"34122","inReplyTo":"1371118039-18925-2-git-send-email-benoit.person@ensimag.fr","subject":"Re: [PATCH/RFC 1/4] git-mw: Introduction of GitMediawiki.pm","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-13T11:44:40Z","receivedAt":"2013-06-13T11:44:40Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"benoit.person@ensimag.fr writes:\n\n> +install_pm:\n> +\tcp $(GIT_MEDIAWIKI_PM) $(INSTLIBDIR)\n\nBetter use \"install\", which is roughly like \"cp\".\n\nAlso, this fails if the target dir does not exist, ie. if one did not\nrun \"make install\" at the toplevel Git. It's OK, but perhaps you should\nadd a comment in the Makefile like '# Run \"make install\" from Git's\ntoplevel before using this'.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"220716","messageId":"vpq61xiryxm.fsf@anie.imag.fr","threadId":"34122","inReplyTo":"1371118039-18925-5-git-send-email-benoit.person@ensimag.fr","subject":"Re: [PATCH/RFC 4/4] git-mw: Adding preview tool in git-mw.perl","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-13T12:13:25Z","receivedAt":"2013-06-13T12:13:25Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"benoit.person@ensimag.fr writes:\n\n> From: Benoit Person <benoit.person@ensimag.fr>\n>\n> This final commit adds the preview subcommand to git mw. It works as such:\n> 1- Find the remote name of the current branch's upstream and check if it's a\n> mediawiki one.\n> 1b- If it's not found or if it's not a mediawiki one. It will list all the\n> mediawiki remotes configured and ask the user to replay the command with the\n> --remote option set.\n> 2- Parse the content of the local file (or blob) (given as argument) using\n> the distant mediawiki's API\n> 3- Retrieve the current page on the distant mediawiki\n> 4- Replaces all content in that page with the newly parsed one\n> 5- Convert relative links into absolute\n> 6- Save the result on disk\n>\n> The command accepts those options:\n>   --autoload | -a tries to launch the newly generated file in the user's\n>                   default browser (using git web--browse)\n>   --remote | -r provides a way to select the distant mediawiki in which\n>                 the user wants to preview his file (or blob)\n>   --output | -o enables the user to choose the output filename. Default\n>                 output filename is based on the input filename in which\n>                 the extension '.mw' is replaced with '.html'\n>   --blob | -b tells the script that the last argument is a blob and not\n>               a filename\n\nA commit messages that answers the \"what?\" and \"how?\" questions (as\nopposed to \"why?\") is always suspicious: doesn't the message belong\nelsewhere?\n\nHere, you have a nice user documentation for command-line options, and\nthe actual user doc is much poorer:\n\n> +sub preview_help {\n> +\tprint <<'END';\n> +usage: git mw preview [--remote|-r <remote name>] [--autoload|-a]\n> +                      [--output|-o <output filename>] <filename>\n> +\n> +    -r, --remote    Specify which mediawiki should be used\n> +    -o, --output    Name of the output file\n> +    -a, --autoload  Autoload the page in your default web browser\n> +END\n\n(shorter description, missing --blob)\n\n> +\t} else { # file mode\n> +\t\tif (! -e $file_name) {\n> +\t\t\tdie \"File $file_name does not exists \\n\";\n\nWe're just setting a convention to use ${var} in string interpolation\n(Celestin's perlcritic patch series), so better do it right now ;-).\n\nDid you try \"make perlcritic\" on your code?\n\n> +\t# Default preview_file_name is file_name with .html ext\n> +\tif ($preview_file_name eq '') {\n\nEMPTY ?\n\n> +\tif ($remote_name eq '') {\n\nEMPTY ?\n\n> +\t# Load template page\n> +\t$template = get(\"$remote_url/index.php?title=$wiki_page_name\")\n> +\t\tor die \"You need to create $wiki_page_name before previewing it\";\n\nI got hit again by the HTTPS certificate validation failure. It would\nmake sense to have a more detailed error message, including the URL,\nbecause having the same error:\n\nYou need to create Accueil before previewing it at /home/moy/local/usr-wheezy/libexec/git-core/git-mw line 182.\n\nfor any kind of HTTP failure is a painful. Doesn't \"get\" return an HTTP\ncode? If so, your message would make sense for 404 errors, but not for\nthe others.\n\n> +\t$mw_content_text = $html_tree->look_down('id', 'mw-content-text');\n\nUnfortunately, this doesn't seem standard. It doesn't work on\nhttps://ensiwiki.ensimag.fr/index.php/Accueil at least (which is my main\nuse-case :-( ).\n\nAt least, you should check $mw_content_text and have a nice error\nmessage here. As much as possible, you should allow a way to solve it\n(make the lookup configurable in .git/config, or allow the user to\nspecify an arbitrary HTML template to plug onto, or display the raw,\nincomplete, HTML).\n\nI replaced 'mw-content-text' with 'bodyContent' and it worked.\n\nThen I got\n\nWide character in print at /usr/lib/perl/5.14/IO/Handle.pm line 159.\n\nbut the file was generated. There are encoding problems: the title says\n\"Le Wiki des &Atilde;&copy;tudiants et enseignants\" (it should be a É).\n\nI guess you fed the API with an improper encoding (double UTF-8\nencoding, or UTF-8 announced as latin-1 or so), and the API returned you\nsome hard-coded, badly encoded, rendered HTML.\n\n> @@ -41,6 +241,7 @@ usage: git mw <command> <args>\n>  \n>  git mw commands are:\n>      Help        Display help information about git mw\n> +    Preview \tParse and render local file into HTML\n>  END\n\nLower-case help and preview.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"220719","messageId":"vpq4nd2rwq1.fsf@anie.imag.fr","threadId":"34122","inReplyTo":"1371118039-18925-4-git-send-email-benoit.person@ensimag.fr","subject":"Re: [PATCH/RFC 3/4] git-mw: Adding git-mw.perl script","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-13T13:01:10Z","receivedAt":"2013-06-13T13:01:10Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"benoit.person@ensimag.fr writes:\n\n> From: Benoit Person <benoit.person@ensimag.fr>\n>\n> This script will be used for all tools and command related to a mediawiki\n> remote. In this commit we introduce the tool, the way it parses argument\n> and subcommands and an example of subcommand: \"help\". It also updates\n> the Makefile so that the new tool is installed properly.\n\nHow does the \"make\" Vs \"make install\" work? How does a developer run the\ntool without installing?\n\nI first tried:\n\n$ ../../bin-wrappers/git mw\ngit: 'mw' is not a git command. See 'git --help'.\n\nThen, this first seem OK:\n\n$ ./git-mw \nusage: git mw <command> <args>\n\ngit mw commands are:\n    Help        Display help information about git mw\n    Preview     Parse and render local file into HTML\n\nBUT, this will take the installed GitMediawiki.pm if it is available,\nand we don't want this (if one hacks GitMediawiki.pm locally, one wants\nthe new hacked to be taken into account without \"make install\"ing it).\n\nTo understand better how it works, try adding this in git-mw.perl:\n\n  print \"$_\\n\" for @INC;\n\nI get this:\n\n/home/moy/local/usr-squeeze/share/perl/5.14.2\n/home/moy/local/usr-squeeze/src/MediaWiki-API-0.39/blib/lib\n/etc/perl\n/usr/local/lib/perl/5.14.2\n/usr/local/share/perl/5.14.2\n/usr/lib/perl5\n/usr/share/perl5\n/usr/lib/perl/5.14\n/usr/share/perl/5.14\n/usr/local/lib/site_perl\n.\n\nThe '.' is there, but it comes after the hardcoded\n/home/moy/local/usr-squeeze/share/perl/5.14.2 (which has to comes first,\nto let the install version be robust to whatever comes after).\n\nI think you need an equivalent of Git's toplevel bin-wrappers/git, or\nperhaps use the same bin-wrapper/git but let \"make install\" in\ncontrib/mw-to-git/ install GitMediawiki.pm in perl/blib/lib\n\nBTW, I just noticed we had a Git::SVN, so perhaps GitMediawiki should be\nGit::MediaWiki.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"220947","messageId":"CAETqRCidQpBu-Ws7wQ3xx73ozu0OQeeM7atptYg=ei8ZUXRbsA@mail.gmail.com","threadId":"34122","inReplyTo":"vpq4nd2rwq1.fsf@anie.imag.fr","subject":"Re: [PATCH/RFC 3/4] git-mw: Adding git-mw.perl script","fromName":"Benoît Person","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-06-15T13:22:18Z","receivedAt":"2013-06-15T13:22:18Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"The V3 is ready, but I am still not sure about what is the best way to\ndo it for this issue though.\n\nOn 13 June 2013 15:01, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:\n> benoit.person@ensimag.fr writes:\n> How does the \"make\" Vs \"make install\" work? How does a developer run the\n> tool without installing?\nWell it does not work without installing but I think you know that now :)\n\n> I first tried:\n>\n> $ ../../bin-wrappers/git mw\n> git: 'mw' is not a git command. See 'git --help'.\n>\n> Then, this first seem OK:\n>\n> $ ./git-mw\n> usage: git mw <command> <args>\n>\n> git mw commands are:\n>     Help        Display help information about git mw\n>     Preview     Parse and render local file into HTML\n>\n> BUT, this will take the installed GitMediawiki.pm if it is available,\n> and we don't want this (if one hacks GitMediawiki.pm locally, one wants\n> the new hacked to be taken into account without \"make install\"ing it).\n>\n> To understand better how it works, try adding this in git-mw.perl:\n>\n>   print \"$_\\n\" for @INC;\n>\n> I get this:\n>\n> /home/moy/local/usr-squeeze/share/perl/5.14.2\n> /home/moy/local/usr-squeeze/src/MediaWiki-API-0.39/blib/lib\n> /etc/perl\n> /usr/local/lib/perl/5.14.2\n> /usr/local/share/perl/5.14.2\n> /usr/lib/perl5\n> /usr/share/perl5\n> /usr/lib/perl/5.14\n> /usr/share/perl/5.14\n> /usr/local/lib/site_perl\n> .\n>\n> The '.' is there, but it comes after the hardcoded\n> /home/moy/local/usr-squeeze/share/perl/5.14.2 (which has to comes first,\n> to let the install version be robust to whatever comes after).\nThanks for the explanations\n\n> I think you need an equivalent of Git's toplevel bin-wrappers/git, or\n> perhaps use the same bin-wrapper/git but let \"make install\" in\n> contrib/mw-to-git/ install GitMediawiki.pm in perl/blib/lib\nTypo s/make install/make/ ?\n\nFor now, I have implemented that one : each time you do `make`, if\nthere is changes in GitMediawiki.pm, it gets copied to $GITPERLLIB\n(perl/blib/lib). But I am not sure it's the best approach here. If we\nwant something entirely self-contained for GitMediawiki, creating a\nnew git wrapper seems like the best way. But then, we could say that\nsince GitMediawiki Makefile uses Git toplevel Makefile, it's not\nentirely self-contained :/ maybe it's the \"copying file\" that makes it\nweird ?\n\n> BTW, I just noticed we had a Git::SVN, so perhaps GitMediawiki should be\n> Git::MediaWiki.\nFor that one, I am not really sure Git::Mediawiki makes more sense\nthan GitMediawiki. The point of the GitMediawiki.pm package is to\ncontain all the stuff for the bidirectionnal-thingy. So they are not\nreally Git-related, nor Mediawiki-related. Making it part of a \"Git\"\ndirectory / namespace does not really feels right, even if it's how\nit's done for SVN :/ .\n\nThank you for the all the reviews, (it works for Ensiwiki now \\o/)\n\nBenoit Person\n"},{"id":"221014","messageId":"vpq1u81hlne.fsf@anie.imag.fr","threadId":"34122","inReplyTo":"CAETqRCidQpBu-Ws7wQ3xx73ozu0OQeeM7atptYg=ei8ZUXRbsA@mail.gmail.com","subject":"Re: [PATCH/RFC 3/4] git-mw: Adding git-mw.perl script","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-16T19:59:33Z","receivedAt":"2013-06-16T19:59:33Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Benoît Person <benoit.person@ensimag.fr> writes:\n\n>> I think you need an equivalent of Git's toplevel bin-wrappers/git, or\n>> perhaps use the same bin-wrapper/git but let \"make install\" in\n>> contrib/mw-to-git/ install GitMediawiki.pm in perl/blib/lib\n> Typo s/make install/make/ ?\n\nYes.\n\n> For that one, I am not really sure Git::Mediawiki makes more sense\n> than GitMediawiki. The point of the GitMediawiki.pm package is to\n> contain all the stuff for the bidirectionnal-thingy. So they are not\n> really Git-related, nor Mediawiki-related.\n\nI'd say they are related to both, not to neither.\n\n> Making it part of a \"Git\" directory / namespace does not really feels\n> right, even if it's how it's done for SVN :/ .\n\nWell, it's the part of Git's perl library which deals with SVN\ninteraction, so it makes sense to have it be a subdirectory of Git. I'd\nsay it makes as much sense for Mediawiki interaction.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"221797","messageId":"vpqsj07vb3m.fsf@anie.imag.fr","threadId":"34122","inReplyTo":"1371118039-18925-4-git-send-email-benoit.person@ensimag.fr","subject":"Re: [PATCH/RFC 3/4] git-mw: Adding git-mw.perl script","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-24T14:26:21Z","receivedAt":"2013-06-24T14:26:21Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"benoit.person@ensimag.fr writes:\n\n> diff --git a/contrib/mw-to-git/git-mw.perl b/contrib/mw-to-git/git-mw.perl\n> new file mode 100644\n> index 0000000..a2f0aa1\n> --- /dev/null\n> +++ b/contrib/mw-to-git/git-mw.perl\n\n*.perl scripts are usually executable in Git's tree (although it's\nusually better to run the non-*.perl version).\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"221830","messageId":"7vfvw7bh0u.fsf@alter.siamese.dyndns.org","threadId":"34122","inReplyTo":"vpqsj07vb3m.fsf@anie.imag.fr","subject":"Re: [PATCH/RFC 3/4] git-mw: Adding git-mw.perl script","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-24T16:38:41Z","receivedAt":"2013-06-24T16:38:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> benoit.person@ensimag.fr writes:\n>\n>> diff --git a/contrib/mw-to-git/git-mw.perl b/contrib/mw-to-git/git-mw.perl\n>> new file mode 100644\n>> index 0000000..a2f0aa1\n>> --- /dev/null\n>> +++ b/contrib/mw-to-git/git-mw.perl\n>\n> *.perl scripts are usually executable in Git's tree (although it's\n> usually better to run the non-*.perl version).\n\nGood eyes.  But if we encourage people to run non-*.perl version,\nperhaps we should drop the executable bit from the source, no?\n"},{"id":"221853","messageId":"vpqy59zsb0u.fsf@anie.imag.fr","threadId":"34122","inReplyTo":"7vfvw7bh0u.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH/RFC 3/4] git-mw: Adding git-mw.perl script","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-24T16:56:17Z","receivedAt":"2013-06-24T16:56:17Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>\n>> benoit.person@ensimag.fr writes:\n>>\n>>> diff --git a/contrib/mw-to-git/git-mw.perl b/contrib/mw-to-git/git-mw.perl\n>>> new file mode 100644\n>>> index 0000000..a2f0aa1\n>>> --- /dev/null\n>>> +++ b/contrib/mw-to-git/git-mw.perl\n>>\n>> *.perl scripts are usually executable in Git's tree (although it's\n>> usually better to run the non-*.perl version).\n>\n> Good eyes.  But if we encourage people to run non-*.perl version,\n> perhaps we should drop the executable bit from the source, no?\n\nBut by default, I'd say consistency is most important so if other *.perl\nare executable, we should do the same (otherwise my \"ls\" shows different\ncolors and it's ugly ;-) ).\n\nBut it may make sense to change the convention, i.e. run a \"chmod -x\n*.perl\" in Git's tree (in any case, people can still run \"perl\nfoo.perl\").\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"221854","messageId":"20130624170056.GA24251@sigill.intra.peff.net","threadId":"34122","inReplyTo":"vpqy59zsb0u.fsf@anie.imag.fr","subject":"Re: [PATCH/RFC 3/4] git-mw: Adding git-mw.perl script","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-06-24T17:00:57Z","receivedAt":"2013-06-24T17:00:57Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jun 24, 2013 at 06:56:17PM +0200, Matthieu Moy wrote:\n\n> > Good eyes.  But if we encourage people to run non-*.perl version,\n> > perhaps we should drop the executable bit from the source, no?\n> \n> But by default, I'd say consistency is most important so if other *.perl\n> are executable, we should do the same (otherwise my \"ls\" shows different\n> colors and it's ugly ;-) ).\n> \n> But it may make sense to change the convention, i.e. run a \"chmod -x\n> *.perl\" in Git's tree (in any case, people can still run \"perl\n> foo.perl\").\n\nYou'd probably want to also change the shell scripts, too, which are\nmarked executable in the repo (but the source-able shell \"libraries\" are\nnot).\n\nI don't remember the details, but I think there may be some magic with\nthe --valgrind test option that depends on the executable bit to\ndistinguish those two.\n\n-Peff\n"},{"id":"221856","messageId":"2b5734ad750f9ec566215f353b6bb0b5@ensibm.imag.fr","threadId":"34122","inReplyTo":"vpqy59zsb0u.fsf@anie.imag.fr","subject":"Re: [PATCH/RFC 3/4] git-mw: Adding git-mw.perl script","fromName":"Benoit Person","fromEmail":"benoit.person@ensimag.fr","sentAt":"2013-06-24T17:05:29Z","receivedAt":"2013-06-24T17:05:29Z","isPatch":true,"sender":{"key":"benoit.person@ensimag.fr","avatar":null},"body":"Le 2013-06-24 18:56, Matthieu Moy a écrit :\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>>\n>>> benoit.person@ensimag.fr writes:\n>>>\n>>>> diff --git a/contrib/mw-to-git/git-mw.perl \n>>>> b/contrib/mw-to-git/git-mw.perl\n>>>> new file mode 100644\n>>>> index 0000000..a2f0aa1\n>>>> --- /dev/null\n>>>> +++ b/contrib/mw-to-git/git-mw.perl\n>>>\n>>> *.perl scripts are usually executable in Git's tree (although it's\n>>> usually better to run the non-*.perl version).\n>>\n>> Good eyes.  But if we encourage people to run non-*.perl version,\n>> perhaps we should drop the executable bit from the source, no?\n>\n> But by default, I'd say consistency is most important so if other \n> *.perl\n> are executable, we should do the same (otherwise my \"ls\" shows \n> different\n> colors and it's ugly ;-) ).\nSo it's really a *nice* catch then :) .\n\n> But it may make sense to change the convention, i.e. run a \"chmod -x\n> *.perl\" in Git's tree (in any case, people can still run \"perl\n> foo.perl\").\nFor what I've seen so far of git.git, the best way would be to make it\nexecutable in this patch serie and send another patch applying that\n'chmod -x'-thingy ?\n"},{"id":"221861","messageId":"7vsj07a0d7.fsf@alter.siamese.dyndns.org","threadId":"34122","inReplyTo":"vpqy59zsb0u.fsf@anie.imag.fr","subject":"Re: [PATCH/RFC 3/4] git-mw: Adding git-mw.perl script","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-24T17:23:48Z","receivedAt":"2013-06-24T17:23:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>>\n>>> benoit.person@ensimag.fr writes:\n>>>\n>>>> diff --git a/contrib/mw-to-git/git-mw.perl b/contrib/mw-to-git/git-mw.perl\n>>>> new file mode 100644\n>>>> index 0000000..a2f0aa1\n>>>> --- /dev/null\n>>>> +++ b/contrib/mw-to-git/git-mw.perl\n>>>\n>>> *.perl scripts are usually executable in Git's tree (although it's\n>>> usually better to run the non-*.perl version).\n>>\n>> Good eyes.  But if we encourage people to run non-*.perl version,\n>> perhaps we should drop the executable bit from the source, no?\n>\n> But by default, I'd say consistency is most important so if other *.perl\n> are executable, we should do the same.\n\nAh, I should have been more clear.  I meant \"perhaps we should drop\nexecutable bits from existing *.perl source files.\"\n\n> But it may make sense to change the convention, i.e. run a \"chmod -x\n> *.perl\" in Git's tree (in any case, people can still run \"perl\n> foo.perl\").\n\nYes, that is exactly what I meant.\n"}]}