aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMatthieu Moy <Matthieu.Moy@imag.fr>2012-07-16 21:46:42 +0200
committerJunio C Hamano <gitster@pobox.com>2012-07-16 12:52:40 -0700
commitebd5fe1c15b8e576042017d6b07b7e0ed96eaf66 (patch)
tree786b6b189ba665eca6cf178870cfe3cd5e1396ab /contrib
parenta393f48823ba619092f8057ed807a20358e0165c (diff)
downloadgit-ebd5fe1c15b8e576042017d6b07b7e0ed96eaf66.tar.gz
git-ebd5fe1c15b8e576042017d6b07b7e0ed96eaf66.tar.xz
git-remote-mediawiki: properly deal with invalid remote revisions
Some wiki, including https://git.wiki.kernel.org/ have invalid revision numbers (i.e. the actual revision numbers are non-contiguous). Don't die when encountering one. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/mw-to-git/git-remote-mediawiki13
1 files changed, 9 insertions, 4 deletions
diff --git a/contrib/mw-to-git/git-remote-mediawiki b/contrib/mw-to-git/git-remote-mediawiki
index 8badff601..5eab96b63 100755
--- a/contrib/mw-to-git/git-remote-mediawiki
+++ b/contrib/mw-to-git/git-remote-mediawiki
@@ -910,6 +910,10 @@ sub mw_import_revids {
my $last_timestamp = 0; # Placeholer in case $rev->timestamp is undefined
foreach my $pagerevid (@$revision_ids) {
+ # Count page even if we skip it, since we display
+ # $n/$total and $total includes skipped pages.
+ $n++;
+
# fetch the content of the pages
my $query = {
action => 'query',
@@ -924,6 +928,11 @@ sub mw_import_revids {
die "Failed to retrieve modified page for revision $pagerevid";
}
+ if (defined($result->{query}->{badrevids}->{$pagerevid})) {
+ # The revision id does not exist on the remote wiki.
+ next;
+ }
+
if (!defined($result->{query}->{pages})) {
die "Invalid revision $pagerevid.";
}
@@ -932,10 +941,6 @@ sub mw_import_revids {
my $result_page = $result_pages[0];
my $rev = $result_pages[0]->{revisions}->[0];
- # Count page even if we skip it, since we display
- # $n/$total and $total includes skipped pages.
- $n++;
-
my $page_title = $result_page->{title};
if (!exists($pages->{$page_title})) {