{"thread":{"id":"34168","subject":"[PATCH RFC] git-remote-mediawiki: push-by-rev","startedAt":"2013-06-16T20:28:18Z","lastAt":"2013-06-16T20:49:16Z","messageCount":3,"participants":["Célestin Matte","Matthieu Moy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"221016","messageId":"1371414499-13027-1-git-send-email-celestin.matte@ensimag.fr","threadId":"34168","inReplyTo":null,"subject":"[PATCH RFC] git-remote-mediawiki: push-by-rev","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-16T20:28:18Z","receivedAt":"2013-06-16T20:28:18Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"From: Célestin Matte <celestin.matte@ensimag.fr>\n\nThis patch intends to introduce the by_rev strategy for the push command, as\nalready available for the fetch one.\nThis uses subroutines used by the fetch-by-rev strategy. I'm not sure it's\nactually complete: can it be that simple? However, I tested on a local wiki and\nit seemed to work perfectly. \nShould I add associate tests?\n\nCélestin Matte (1):\n  git-remote-mediawiki: push-by-rev\n\n contrib/mw-to-git/git-remote-mediawiki.perl | 24 ++++++++++++++++++++++--\n 1 file changed, 22 insertions(+), 2 deletions(-)\n\n-- \n1.8.3.1.522.gd761f2b.dirty\n"},{"id":"221017","messageId":"1371414499-13027-2-git-send-email-celestin.matte@ensimag.fr","threadId":"34168","inReplyTo":"1371414499-13027-1-git-send-email-celestin.matte@ensimag.fr","subject":"[PATCH RFC] git-remote-mediawiki: push-by-rev","fromName":"Célestin Matte","fromEmail":"celestin.matte@ensimag.fr","sentAt":"2013-06-16T20:28:19Z","receivedAt":"2013-06-16T20:28:19Z","isPatch":true,"sender":{"key":"celestin.matte@ensimag.fr","avatar":"https://avatars.githubusercontent.com/u/2753554?v=4"},"body":"From: Célestin Matte <celestin.matte@ensimag.fr>\n\nAdd the push-by-rev option\nThis allows one to look for changes by revision instead of by page.\nThe result is a much faster push on little-activity wikis. Indeed, instead of\nsending one request by page to check that the remote revision is our local\nlatest revision, we only send one request for every new local revision.\n\nSigned-off-by: Célestin Matte <celestin.matte@ensimag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>\n---\n contrib/mw-to-git/git-remote-mediawiki.perl | 24 ++++++++++++++++++++++--\n 1 file changed, 22 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl\nindex 9ff45fd..fa49882 100755\n--- a/contrib/mw-to-git/git-remote-mediawiki.perl\n+++ b/contrib/mw-to-git/git-remote-mediawiki.perl\n@@ -102,6 +102,15 @@ if (!$fetch_strategy) {\n \t$fetch_strategy = 'by_page';\n }\n \n+my $push_strategy = run_git(\"config --get remote.${remotename}.pushStrategy\");\n+if (!$push_strategy) {\n+\t$push_strategy = run_git('config --get mediawiki.pushStrategy');\n+}\n+chomp($push_strategy);\n+if (!$push_strategy) {\n+\t$push_strategy = 'by_page';\n+}\n+\n # Remember the timestamp corresponding to a revision id.\n my %basetimestamps;\n \n@@ -512,7 +521,7 @@ sub get_last_local_revision {\n # Get the last remote revision without taking in account which pages are\n # tracked or not. This function makes a single request to the wiki thus\n # avoid a loop onto all tracked pages. This is useful for the fetch-by-rev\n-# option.\n+# and the push-by-rev options.\n sub get_last_global_remote_rev {\n \tmw_connect_maybe();\n \n@@ -1160,8 +1169,19 @@ sub mw_push_revision {\n \tmy $local = shift;\n \tmy $remote = shift; # actually, this has to be \"refs/heads/master\" at this point.\n \tmy $last_local_revid = get_last_local_revision();\n+\tmy $last_remote_revid;\n \tprint {*STDERR} \".\\n\"; # Finish sentence started by get_last_local_revision()\n-\tmy $last_remote_revid = get_last_remote_revision();\n+\tif ($push_strategy eq 'by_page') {\n+\t\tprint {*STDERR} \"Pushing export data by pages...\\n\";\n+\t\t$last_remote_revid = get_last_remote_revision();\n+\t} elsif ($push_strategy eq 'by_rev') {\n+\t\tprint {*STDERR} \"Pushing export data by revs...\\n\";\n+\t\t$last_remote_revid = get_last_global_remote_rev();\n+\t} else {\n+\t\tprint {*STDERR} qq(fatal: invalid push strategy \"${push_strategy}\".\\n);\n+\t\tprint {*STDERR} \"Check your configuration variables remote.${remotename}.pushStrategy and mediawiki.pushStrategy\\n\";\n+\t\texit 1;\n+\t}\n \tmy $mw_revision = $last_remote_revid;\n \n \t# Get sha1 of commit pointed by local HEAD\n-- \n1.8.3.1.522.gd761f2b.dirty\n"},{"id":"221019","messageId":"vpq8v29eq7n.fsf@anie.imag.fr","threadId":"34168","inReplyTo":"1371414499-13027-1-git-send-email-celestin.matte@ensimag.fr","subject":"Re: [PATCH RFC] git-remote-mediawiki: push-by-rev","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-16T20:49:16Z","receivedAt":"2013-06-16T20:49:16Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Célestin Matte <celestin.matte@ensimag.fr> writes:\n\n> This uses subroutines used by the fetch-by-rev strategy. I'm not sure it's\n> actually complete: can it be that simple?\n\nThe function says:\n\n  # Get the last remote revision without taking in account which pages are\n  # tracked or not. This function makes a single request to the wiki thus\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  ...\n\nSo I don't think this would work when you track only a subset of pages.\nIf an untracked page has been modified, then the global last revision\nhas increased and you'll get a non-fast forward. If you try to pull,\nit'll tell you there's nothing to import.\n\nYou'd have to iterate through revisions between the one given by\nget_last_global_remote_rev and the last one the local repo knows about,\nand remove ones touching untracked pages from the list.\n\n> However, I tested on a local wiki and it seemed to work perfectly.\n> Should I add associate tests?\n\nSee what t/t9364-pull-by-rev.sh does. You can set pushStrategy too in\nthe same file (this won't test all push/pull combinations, but push and\npull should be independant enough, so testing both unset and both set\nshould be enough).\n\nNot sure we have enough test for push with a subset of pages though.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}