patches: more minor updates
[git-osx-installer.git] / patches / mediawiki / q / t_mediawiki_namespaces.diff
blob1389f071a0526919dd13e4bd1f11d23e4f9fb63e
1 Subject: [PATCH] git-remote-mediawiki: support namespaces
3 By default git-remote-mediawiki only supports pages in the
4 'Main' (NS_MAIN = 0) namespace plus media files that can
5 be found in the 'File' (NS_FILE = 6) namespace if that's
6 enabled with the remote.<remote-name>.mediaimport config option.
8 When importing using 'by_page' (the default), all pages are
9 listed, but only in the NS_MAIN namespace, and then revisions
10 for each are imported.
12 When importing using 'by_rev' each revision is fetched but if
13 it refers to a page not in the pages list it will be skipped
14 even if all pages are requested. Since the list of all pages
15 is generated only for the NS_MAIN namespace, pages in other
16 namespaces end up being skipped even though 'by_rev' was
17 requested via the remote.<remote-name>.fetchStrategy config option.
19 Fix this problem by allowing import of any page when fetching
20 using 'by_rev' and no user-specified pages or categories have
21 been given.
23 Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
25 ---
26 contrib/mw-to-git/git-remote-mediawiki.perl | 4 +++-
27 1 file changed, 3 insertions(+), 1 deletion(-)
29 diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
30 index e4603da7..89cb879f 100755
31 --- a/contrib/mw-to-git/git-remote-mediawiki.perl
32 +++ b/contrib/mw-to-git/git-remote-mediawiki.perl
33 @@ -862,6 +862,8 @@ sub mw_import_revids {
34 my $n_actual = 0;
35 my $last_timestamp = 0; # Placeholer in case $rev->timestamp is undefined
37 + my $user_defined = @tracked_pages || @tracked_categories;
39 foreach my $pagerevid (@{$revision_ids}) {
40 # Count page even if we skip it, since we display
41 # $n/$total and $total includes skipped pages.
42 @@ -896,7 +898,7 @@ sub mw_import_revids {
44 my $page_title = $result_page->{title};
46 - if (!exists($pages->{$page_title})) {
47 + if ($user_defined && !exists($pages->{$page_title})) {
48 print {*STDERR} "${n}/", scalar(@{$revision_ids}),
49 ": Skipping revision #$rev->{revid} of ${page_title}\n";
50 next;
51 ---