git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: git@vger.kernel.org, gitster@pobox.com
Cc: Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: [PATCH 10/12] git-remote-mediawiki: extract revision-importing loop to a function
Date: Fri,  6 Jul 2012 12:03:13 +0200	[thread overview]
Message-ID: <1341568995-12467-11-git-send-email-Matthieu.Moy@imag.fr> (raw)
In-Reply-To: <1341568995-12467-1-git-send-email-Matthieu.Moy@imag.fr>


Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 contrib/mw-to-git/git-remote-mediawiki | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/contrib/mw-to-git/git-remote-mediawiki b/contrib/mw-to-git/git-remote-mediawiki
index 47dd574..9305204 100755
--- a/contrib/mw-to-git/git-remote-mediawiki
+++ b/contrib/mw-to-git/git-remote-mediawiki
@@ -822,10 +822,18 @@ sub mw_import_ref {
 	@revisions = sort {$a->{revid} <=> $b->{revid}} @revisions;
 	my @revision_ids = map $_->{revid}, @revisions;
 
-	$n = 0;
+	return mw_import_revids($fetch_from, \@revision_ids, \%pages_hash);
+}
+
+sub mw_import_revids {
+	my $fetch_from = shift;
+	my $revision_ids = shift;
+	my $pages = shift;
+
+	my $n = 0;
 	my $last_timestamp = 0; # Placeholer in case $rev->timestamp is undefined
 
-	foreach my $pagerevid (@revision_ids) {
+	foreach my $pagerevid (@$revision_ids) {
 		# fetch the content of the pages
 		my $query = {
 			action => 'query',
@@ -866,7 +874,7 @@ sub mw_import_ref {
 		# If this is a revision of the media page for new version
 		# of a file do one common commit for both file and media page.
 		# Else do commit only for that page.
-		print STDERR "$n/", scalar(@revision_ids), ": Revision #$rev->{revid} of $commit{title}\n";
+		print STDERR "$n/", scalar(@$revision_ids), ": Revision #$rev->{revid} of $commit{title}\n";
 		import_file_revision(\%commit, ($fetch_from == 1), $n, \%mediafile);
 	}
 
@@ -876,6 +884,8 @@ sub mw_import_ref {
 		# thrown saying that HEAD is refering to unknown object 0000000000000000000
 		# and the clone fails.
 	}
+
+	return $n;
 }
 
 sub error_non_fast_forward {
-- 
1.7.11.1.147.g47a574d

  parent reply	other threads:[~2012-07-06 10:04 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-05  7:36 [PATCH 00/12] git-remote-mediawiki: tests and optimizations Matthieu Moy
2012-07-05  7:36 ` [PATCH 01/12] git-remote-mediawiki: scripts to install, delete and clear a MediaWiki Matthieu Moy
2012-07-05  7:36 ` [PATCH 02/12] git-remote-mediawiki: test environment of git-remote-mediawiki Matthieu Moy
2012-07-05 23:13   ` Junio C Hamano
2012-07-06  8:44     ` Matthieu Moy
2012-07-06 10:03       ` [PATCH 00/12] git-remote-mediawiki: tests and optimizations Matthieu Moy
2012-07-06 10:03         ` [PATCH 01/12] git-remote-mediawiki: scripts to install, delete and clear a MediaWiki Matthieu Moy
2012-07-06 10:03         ` [PATCH 02/12] git-remote-mediawiki: test environment of git-remote-mediawiki Matthieu Moy
2012-07-06 10:03         ` [PATCH 03/12] git-remote-mediawiki (t9360): test git-remote-mediawiki clone Matthieu Moy
2012-07-06 10:03         ` [PATCH 04/12] git-remote-mediawiki (t9361): test git-remote-mediawiki pull and push Matthieu Moy
2012-07-06 10:03         ` [PATCH 05/12] git-remote-mediawiki (t9362): test git-remote-mediawiki with UTF8 characters Matthieu Moy
2012-07-06 10:03         ` [PATCH 06/12] git-remote-mediawiki: support for uploading file in test environment Matthieu Moy
2012-07-06 10:03         ` [PATCH 07/12] git-remote-mediawiki (t9363): test 'File:' import and export Matthieu Moy
2012-07-06 10:03         ` [PATCH 08/12] git-remote-mediawiki: change return type of get_mw_pages Matthieu Moy
2012-07-06 10:03         ` [PATCH 09/12] git-remote-mediawiki: refactor loop over revision ids Matthieu Moy
2012-07-06 10:03         ` Matthieu Moy [this message]
2012-07-06 10:03         ` [PATCH 11/12] git-remote-mediawiki: more efficient 'pull' in the best case Matthieu Moy
2012-07-06 10:03         ` [PATCH 12/12] git-remote-mediawiki: be more defensive when requests fail Matthieu Moy
2012-07-05  7:36 ` [PATCH 03/12] git-remote-mediawiki (t9360): test git-remote-mediawiki clone Matthieu Moy
2012-07-05  7:36 ` [PATCH 04/12] git-remote-mediawiki (t9361): test git-remote-mediawiki pull and push Matthieu Moy
2012-07-05 23:14   ` Junio C Hamano
2012-07-05  7:36 ` [PATCH 05/12] git-remote-mediawiki (t9362): test git-remote-mediawiki with UTF8 characters Matthieu Moy
2012-07-05  7:36 ` [PATCH 06/12] git-remote-mediawiki: support for uploading file in test environment Matthieu Moy
2012-07-05  7:36 ` [PATCH 07/12] git-remote-mediawiki (t9363): test 'File:' import and export Matthieu Moy
2012-07-05  7:36 ` [PATCH 08/12] git-remote-mediawiki: change return type of get_mw_pages Matthieu Moy
2012-07-05 23:18   ` Junio C Hamano
2012-07-05  7:36 ` [PATCH 09/12] git-remote-mediawiki: refactor loop over revision ids Matthieu Moy
2012-07-05  7:36 ` [PATCH 10/12] git-remote-mediawiki: extract revision-importing loop to a function Matthieu Moy
2012-07-05  7:36 ` [PATCH 11/12] git-remote-mediawiki: more efficient 'pull' in the best case Matthieu Moy
2012-07-05  7:36 ` [PATCH 12/12] git-remote-mediawiki: be more defensive when requests fail Matthieu Moy

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=1341568995-12467-11-git-send-email-Matthieu.Moy@imag.fr \
    --to=matthieu.moy@imag.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).