summaryrefslogtreecommitdiff
path: root/contrib/mw-to-git/git-remote-mediawiki.perl
diff options
context:
space:
mode:
authorAntoine Beaupré <anarcat@debian.org>2017-11-07 16:06:58 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-11-08 02:06:33 (GMT)
commitdb3364352da98f20915e1b838616688f388fad8b (patch)
tree74c6b85cfa988aa344915196b6c6cd956ea1abbf /contrib/mw-to-git/git-remote-mediawiki.perl
parent09eebbadca58dbf8e415678eeef8de54c0be6534 (diff)
downloadgit-db3364352da98f20915e1b838616688f388fad8b.zip
git-db3364352da98f20915e1b838616688f388fad8b.tar.gz
git-db3364352da98f20915e1b838616688f388fad8b.tar.bz2
remote-mediawiki: skip virtual namespaces
Virtual namespaces do not correspond to pages in the database and are automatically generated by MediaWiki. It makes little sense, therefore, to fetch pages from those namespaces and the MW API doesn't support listing those pages. According to the documentation, those virtual namespaces are currently "Special" (-1) and "Media" (-2) but we treat all negative namespaces as "virtual" as a future-proofing mechanism. Signed-off-by: Antoine Beaupré <anarcat@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/mw-to-git/git-remote-mediawiki.perl')
-rwxr-xr-xcontrib/mw-to-git/git-remote-mediawiki.perl5
1 files changed, 4 insertions, 1 deletions
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
index 5e88458..611a04c 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -264,10 +264,13 @@ sub get_mw_tracked_categories {
sub get_mw_tracked_namespaces {
my $pages = shift;
foreach my $local_namespace (@tracked_namespaces) {
+ my $namespace_id = get_mw_namespace_id($local_namespace);
+ # virtual namespaces don't support allpages
+ next if !defined($namespace_id) || $namespace_id < 0;
my $mw_pages = $mediawiki->list( {
action => 'query',
list => 'allpages',
- apnamespace => get_mw_namespace_id($local_namespace),
+ apnamespace => $namespace_id,
aplimit => 'max' } )
|| die $mediawiki->{error}->{code} . ': '
. $mediawiki->{error}->{details} . "\n";