Skip to content

Commit da2a180

Browse files
anarcatgitster
authored andcommitted
remote-mediawiki: support fetching from (Main) namespace
When we specify a list of namespaces to fetch from, by default the MW API will not fetch from the default namespace, refered to as "(Main)" in the documentation: https://www.mediawiki.org/wiki/Manual:Namespace#Built-in_namespaces I haven't found a way to address that "(Main)" namespace when getting the namespace ids: indeed, when listing namespaces, there is no "canonical" field for the main namespace, although there is a "*" field that is set to "" (empty). So in theory, we could specify the empty namespace to get the main namespace, but that would make specifying namespaces harder for the user: we would need to teach users about the "empty" default namespace. It would also make the code more complicated: we'd need to parse quotes in the configuration. So we simply override the query here and allow the user to specify "(Main)" since that is the publicly documented name. Signed-off-by: Antoine Beaupré <anarcat@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent db33643 commit da2a180

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

contrib/mw-to-git/git-remote-mediawiki.perl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,12 @@ sub get_mw_tracked_categories {
264264
sub get_mw_tracked_namespaces {
265265
my $pages = shift;
266266
foreach my $local_namespace (@tracked_namespaces) {
267-
my $namespace_id = get_mw_namespace_id($local_namespace);
267+
my $namespace_id;
268+
if ($local_namespace eq "(Main)") {
269+
$namespace_id = 0;
270+
} else {
271+
$namespace_id = get_mw_namespace_id($local_namespace);
272+
}
268273
# virtual namespaces don't support allpages
269274
next if !defined($namespace_id) || $namespace_id < 0;
270275
my $mw_pages = $mediawiki->list( {

0 commit comments

Comments
 (0)