Merge branch 'jk/diff-algo' into maint
[gitweb.git] / contrib / mw-to-git / git-remote-mediawiki.perl
index f8d7d2ca6c0926912200ddcadf8359c1b9bfef44..85d0c422961f990aa70a6cc5ed70ab319b5ca99a 100755 (executable)
@@ -622,6 +622,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;
@@ -637,8 +640,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";