Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
* maint:
  git-remote-mediawiki: bugfix for pages w/ >500 revisions
  • Loading branch information
Jonathan Nieder committed Sep 25, 2013
2 parents ccba805 + 1d905f7 commit 962393b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
14 changes: 12 additions & 2 deletions contrib/mw-to-git/git-remote-mediawiki.perl
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ sub fetch_mw_revisions_for_page {
rvstartid => $fetch_from,
rvlimit => 500,
pageids => $id,

# Let MediaWiki know that we support the latest API.
continue => '',
};

my $revnum = 0;
Expand All @@ -640,8 +643,15 @@ sub fetch_mw_revisions_for_page {
push(@page_revs, $page_rev_ids);
$revnum++;
}
last if (!$result->{'query-continue'});
$query->{rvstartid} = $result->{'query-continue'}->{revisions}->{rvstartid};

if ($result->{'query-continue'}) { # For legacy APIs
$query->{rvstartid} = $result->{'query-continue'}->{revisions}->{rvstartid};
} elsif ($result->{continue}) { # For newer APIs
$query->{rvstartid} = $result->{continue}->{rvcontinue};
$query->{continue} = $result->{continue}->{continue};
} else {
last;
}
}
if ($shallow_import && @page_revs) {
print {*STDERR} " Found 1 revision (shallow import).\n";
Expand Down
23 changes: 23 additions & 0 deletions contrib/mw-to-git/t/t9365-continuing-queries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

test_description='Test the Git Mediawiki remote helper: queries w/ more than 500 results'

. ./test-gitmw-lib.sh
. $TEST_DIRECTORY/test-lib.sh

test_check_precond

test_expect_success 'creating page w/ >500 revisions' '
wiki_reset &&
for i in `test_seq 501`
do
echo "creating revision $i" &&
wiki_editpage foo "revision $i<br/>" true
done
'

test_expect_success 'cloning page w/ >500 revisions' '
git clone mediawiki::'"$WIKI_URL"' mw_dir
'

test_done

0 comments on commit 962393b

Please sign in to comment.