This file is indexed.

/usr/bin/mvs is in libwww-mediawiki-client-perl 0.31-2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
#!/usr/bin/perl -w 

eval 'exec /usr/bin/perl -w  -S $0 ${1+"$@"}'
    if 0; # not running under some shell

use strict;
use WWW::Mediawiki::Client;
use Getopt::Long ();
use Pod::Usage;
use Data::Dumper;

##############################################################################
# Fields                                                                     #
##############################################################################

# Options:
our (
	$opt_help, $opt_verbose, $opt_defaults,
	$opt_host, $opt_lang, $opt_username, $opt_password, 
        $opt_version, $opt_wiki_path, $opt_space_sub,
	$opt_message, $opt_watch, $opt_minor, $opt_tls
);
$opt_verbose = 0;

# Multi-state options:
use constant OPTION_STATES => (
	yes     => WWW::Mediawiki::Client->OPT_YES,
	no      => WWW::Mediawiki::Client->OPT_NO,
	keep    => WWW::Mediawiki::Client->OPT_KEEP,
	default => WWW::Mediawiki::Client->OPT_DEFAULT,
);

our $VERSION = $WWW::Mediawiki::Client::VERSION;

my $LOGFILE = '.mediawiki.errors';

##############################################################################
# Subroutines                                                                #
##############################################################################

sub print_defaults {
    my $DEFAULTS = WWW::Mediawiki::Client->DEFAULTS;
    for my $host (keys %$DEFAULTS) {
        print "Hostname: $host\n";
        for my $field (keys %{$DEFAULTS->{$host}}) {
            print "    $field: " . $DEFAULTS->{$host}->{$field} . "\n";
        }
        print "\n";
    }
    exit 1;
}

sub main {
    my ($command, @files) = @_;
    print_defaults if $opt_defaults;
    version_message() if $opt_version;
    pod2usage unless $command;
    my $method= "do_$command";
    # do help if indicated
    pod2usage(-verbose => 1) if $opt_help;
    # create the init array, and maybe pre-populate it
    my $wmc = WWW::Mediawiki::Client->new();
    unless ($wmc->can($method)) {
        print "Command \"$command\" not supported.\n\n";
        pod2usage(-verbose => 1);
    }
    $wmc->host($opt_host) if $opt_host;
    $wmc->protocol('https') if $opt_tls;
    $wmc->commit_message($opt_message) if $opt_message;
    $wmc->language_code($opt_lang) if $opt_lang;
    $wmc->username($opt_username) if $opt_username;
    $wmc->password($opt_password) if $opt_password;
    $wmc->space_substitute($opt_space_sub) if $opt_space_sub;
    $wmc->wiki_path($opt_wiki_path) if $opt_wiki_path;
    $wmc->minor_edit($opt_minor) if defined($opt_minor);
    $wmc->watch($opt_watch) if defined($opt_watch);
    # run command
    my $message = "Doing $command ";
    $message .= @files ? join(' ', @files) . ' ' : '';
    $message .= "with host: " 
              . $wmc->host . " and lang: "
              . $wmc->language_code . "\n";
    my $watch = multistate_text($wmc->watch);
    my $minor = multistate_text($wmc->minor_edit);
    $message .= "    wiki_path: " . $wmc->wiki_path . "\n"
              . "    space_substitute: " . $wmc->space_substitute . "\n"
              . "    watch this page?: $watch\n" 
              . "    minor edit?: $minor\n"
            if $opt_verbose >= 1;
    print $message unless $opt_verbose <= -1;
    eval { $wmc->$method(@files) };

    my $tmp_error = $@;

    if (UNIVERSAL::isa($tmp_error, 'WWW::Mediawiki::Client::Exception')) {
        open (LOG, ">>$LOGFILE");
        print LOG "\n-----------------\n$tmp_error";
        warn "\n-----------------\n$tmp_error" if $opt_verbose >= 1;

        if (UNIVERSAL::isa($tmp_error, 'WWW::Mediawiki::Client::LoginException')) {
            print LOG Data::Dumper->Dump([$tmp_error->res], ['res'] ) . "\n";
            print LOG Data::Dumper->Dump([$tmp_error->cookie_jar], 
					 ['cookie_jar']) . "\n";
            close LOG;
            die $tmp_error->error . "See $LOGFILE for details.\n" ;
        } elsif (UNIVERSAL::isa($tmp_error,
				'WWW::Mediawiki::Client::CommitException')) {
            print LOG Data::Dumper->Dump([$tmp_error->res], ['res']) . "\n";
	    
        } elsif (UNIVERSAL::isa($tmp_error,
				'WWW::Mediawiki::Client::ServerPageException')) {
            print LOG Data::Dumper->Dump([$tmp_error->res], ['res']) . "\n";
        }

        warn $tmp_error->error, "\n", "See $LOGFILE for details.\n";

    } elsif ($tmp_error) {
	die $tmp_error->error;
    }
    return 1 unless $wmc->status;
    my %status = %{$wmc->status};
    foreach my $file (keys %status) {
        print $status{$file} . " $file\n" if $status{$file};
    }
    return 1;
}

sub HELP_MESSAGE {
    pod2usage(-verbose => 1);
}

sub version_message {
    print "Mediawiki versioning system version $VERSION\n";
    exit 1;
}

sub parse_command {
	local @ARGV = @{$_[0]};

	my $command;
	Getopt::Long::Configure('bundling', 'pass_through');
	Getopt::Long::GetOptions('<>' => sub {
		$command = $_[0] unless $command;
	});

	return $command;
}

sub multistate_map {
	my @states = @_;

	my %states = OPTION_STATES;
	my %statemap;
	foreach my $state (@states) {
		$statemap{$state} = $states{$state};
	}
	return \%statemap;
}

sub multistate_text {
	my ($value) = @_;
	return 'not set' unless defined($value);

	my %states = OPTION_STATES;
	my %reverse = map {$states{$_} => $_} keys %states;
	return $reverse{$value} if defined($reverse{$value});
	return 'unknown';
}

sub multistate_option {
	my ($ref, @states) = @_;

	my $statemap = multistate_map(@states);

	return sub {
		my ($name, $value) = @_;
		my $state = $statemap->{lc($value)};
		die "Unknown setting for $name: $value\n"
			. "Valid settings: " . join(', ', @states) . "\n"
			unless defined($state);
		${$ref} = $state;
	};
}

sub parse_options {
	my $command = shift;
	local @ARGV = @{$_[0]};
    $command ||= "";
	my @addit;
	@addit = (
		'host|d=s'	=> \$opt_host,
                'use_tls|T'     => \$opt_tls,
		'lang|l=s'	=> \$opt_lang,
		'username|u=s'	=> \$opt_username,
		'password|p=s'	=> \$opt_password,
		'wikipath|w=s'	=> \$opt_wiki_path,
		'spaces|S=s'	=> \$opt_space_sub,
	) if $command eq 'login';
	@addit = (
		'message|summary|m|s=s'	=> \$opt_message,
		'minor=s'	=> multistate_option(
			\$opt_minor, qw(yes no default)),
		'watch=s'	=> multistate_option(
			\$opt_watch, qw(yes no default keep)),
		'M'		=> sub { $opt_minor = WWW::Mediawiki::Client->OPT_YES },
		'W'		=> sub { $opt_watch = WWW::Mediawiki::Client->OPT_YES },
	) if $command eq 'commit' or $command eq 'com' 
		or $command eq 'preview';

	Getopt::Long::Configure(
		'no_ignore_case', 'bundling', 'no_pass_through');
	Getopt::Long::GetOptions(
		'verbose|v'	=> sub { $opt_verbose++ },
		'quiet|q'	=> sub { $opt_verbose-- },
		'help|h'	=> \$opt_help,
                'version|V'     => \$opt_version,
		@addit,
	) or exit(-1);

	return @ARGV;
}

# parse command line
my $command = parse_command(\@ARGV);
my @args = parse_options($command, \@ARGV);
main (@args);

__END__

=head1 NAME

mvs - A command line Mediawiki client 

=head1 SYNOPSIS

  mvs [Options] command [Options] [filename]

  mvs -h|--help
  mvs --version
  mvs -D

  mkdir wikistuff
  cd wikistuff

  mvs login [-q|-v] [-T] [-d <wikihost>] [-l language_code ] [-u <username>] [-p <password> ] [-w <wiki_path>] 

  mvs update [-q|-v] [<file> ..]
  mvs up [[-q|-v] <file> ..]

  mvs commit [-q|-v] [-M] [-W] -m "commit message" <file>
  mvs com [-q|-v] [-M] [-W] -m "commit message" <file>
  mvs preview [-q|-v] [-M] [-W] [-m "commit message"] <file>

=head1 DESCRIPTION

C<mvs> is a command line client whose purpose is to simplify offline
editing of Wiki content.  It allows you to get any number of pages from a
given Mediawiki site, edit the pages with any editor, get and merge any
concurrent updates of the pages, and then safely commit the users own
changes back to the version of the page on the server.

The C<mvs> commands which take a filename argument only accept a single
filename as so to avoid taking up too much server bandwidth.

B<Note:>Users of C<mvs> from before version 0.27 will notice that in this
documentation the options are mostly listed after the C<mvs> sub-command.
This makes C<mvs> behave more like C<cvs>, C<svn>, or C<tla>, and so should
make it easier for people who are used to using those programs.  If you
prefer to use C<mvs> the old way, that will still work, at least for the
next few versions.

=head1 QUICKSTART

=head2 Step 1:  Create an account on the Mediawiki server.

This should be done the normal way, by visiting the Mediawiki website to
which you want to contribute and creating a new account, setting the
preferences, etc.

It should hopefully go without saying that you will want to become familiar
with the editorial, usage, and copyright guidelines of the site.  You
should probably also make some contributions through the normal UI, and
learn about following recent changes before contributing using mvs.

In addition for the sake of this test you should already have a user page
like User:<username> with something on it, where <username> is the user
name with which you established the account.

=head2 Step 2:  Create a working directory

C<mvs> works with Mediawiki formatted files with a C<.wiki> extension and
which are stored together with server information in a I<working directory>.  
You will have to have I<at least> one working directory for each Mediawiki
site to which you contribute.

Simply use C<mkdir> or the equivalent to make a new directory, and then
before cd into that directory.

  mkdir wikitravel.en
  cd wikitravel.en

All of the operations below should be done from this directory.

=head2 Step 3:  Login using C<mvs login>

To use login you will need to know the I<host>name for the Mediawiki site
to which you want to contribute.  

  www.wikitravel.org

Now use the I<host> with your username and password to login.

  mvs login -d www.wikitravel.org -u <username> -p 'secret'

If C<mvs> knows about your Mediawiki host it will set set the
C<wiki_path> to the correct default for that server.  In this case it will
also be able to select the language version of that Wiki for you if you
specify a C<language_code>:

  mvs login -d www.wikitravel.org -l fr -u <username> -p 'secret' 

The code must match the one which your wiki host uses for a given language,
and of course the language version must exist for the given host.

If your Mediawiki install uses a nonstandard path to the wiki script you
can specify it on login.  The path to the wiki script is the part of the
URL after the host name, and before the '?':

  mvs login \
    -d www.wikitravel.org \
    -u <username> \
    -p 'secret' \
    -w 'mw/wiki.phtml'

You can change the edit and action paths in the created .mediawiki
file after successful login accordingly.

Now anything you submit to the Mediawiki server will be credited to user
"<username>".

B<NOTE:> If you have been using an earlier version of C<mvs> you should
probably delete the .mediawiki file in your working directory.

=head2 Step 4:  Use C<mvs update> to fetch one or more working files

You can fetch existing material off of the site, or create new pages with
C<mvs update>, remembering that your files will need a C<.wiki> extension:

  mvs update User:<username>.wiki User:<username>/Test_Page.wiki

This should produce the output:

  U User:<username>.wiki
  A User:<username>/Test_Page.wiki

The U (for Updated) means that User:<username> was found on the server and
its contents inserted into the local files.  The A (for Added) means that
the User:<username>/Test_Page.wiki page does not yet exist on the server,
and will be added when you run C<mvs commit>.

Note that both of the pages we are working with are within I<your>
User Namespace.  It's probably a good idea to restrict yourself to working
with such pages while you are experimenting with C<mvs>

=head2 Step 5:  Edit the files to make corrections and contributions

Use your favorite text editor to edit the files.  You might want to check
out this page to see if there is a Mediawiki syntax highlighting file for
your editor:

  http://en.wikipedia.org/wiki/Wikipedia:Syntax_highlighting

Of course if you don't find a highlighting file for you editor you are
welcome to create one and submit it to the page above.

=head2 Step 6:  Use C<mvs commit> to submit your changes

When you are done editing a file and would like to submit your changes to
the wiki server use C<mvs commit> to do so:

  mvs commit -m 'commit message' User:<username>.wiki

Where 'commit message' is whatever you want to say about the changes you
are submitting and why.  You must provide a commit message or C<mvs commit>
will fail.  You might also find that C<mvs commit> fails complaining that
the file has changed on the server.  If this is the case you will need to
use C<mvs update> again to get the most recent changes.

=head2 Step 7: Update your wiki files

You can use C<mvs update> again at any time to reconcile any of your files
with the most recent changes from the server.  Your changes I<will not> be
overwritten, but rather C<mvs> will try to merge any server changes into
the files as they exist in your working directory.  Note that update and
commit only work on one file at a time, as so to help prevent accidents and
server congestion.

If for some reason there is a conflict, i.e. you and someone else have made
changes which appear to be incompatible, and cannot be resolved then your
file will contain a I<conflict message>, as detailed in the documentation
for C<mvs update> below.  You I<must> resolve any conflicts I<before>
attempting to use C<mvs commit> on the file.  This is usually a very simple
matter of choosing one version of the change or another.  You should use
your best judgement, consulting the relevant C<Talk:> page to try to work
out an agreement with the other contributor in cases where you just simply
disagree.

=head2 Repeat

You can continue editing and committing changes with the files in your
working directory.  It might be a good idea for you to eventually create
multiple working directories per site, perhaps grouping them by subject.
This will work fine with C<mvs> since it does I<not> need to have a
complete copy of all of the pages from a given server in a given working
directory to work.

=head1 CHARACTER ENCODING

All of your C<.wiki> files should be stored with UTF-8 encoding.  Upon
login to a given server mvs will determine the encoding used by that
server, and will upload in that encoding only.  For servers using non-UTF-8
character sets you should use HTML entities for any character you want to
represent which is outside of the server's character set.  This includes
the english Wikipedia.  Most newer Mediawiki sites however do use UTF-8, on
these sites HTML entities are I<never> needed.

=head1 ARGUMENTS

=head2 Commands

The first argument after the options should be one of the following two
commands:

=over 4

=item mvs login

Allows the user to login to the Mediawiki server using an I<existing> login
and password for that server.  After calling C<login> all C<commit>s from
the same working directory will be logged as from the logged-in user.

=item mvs update

Updates the specified file[s] with content from the Mediawiki server.  If a
file does not exist it is created and populated with the current online
version.  If there is no online version, the file either created and left
blank, or just left as it is.  If there is content in both the specified
file and in the corresponding Wiki page, an attempt is made to merge the
two, line by line.  Files which are the same as the server version are
ignored.

If no filenames are given on the command line, all visible files with the
.wiki extension are processed.

Conflicting changes to a given line are detected on the basis of the date
of the most recent update of the local file and date of the most recent
change to the online Wiki page.  If a line has changed in both the online
page and the local file it is flagged as a conflict, as in CVS, but with a
slightly different syntax:

  ********************Start of conflict 1  Insert to Primary, Insert to Secondary ************************************************************

  The line as it appears on the server

  ****************************************************************************************************

  The line as it appears locally
  ********************End of conflict 1********************************************************************************

C<mvs update> reports the status of files which it touches to STDERR with
a letter indicating the file status, and then name of the file, again like
CVS.  The status letters are:

=over 4

=item = (Unchanged)

The file is the same as the page on the server.

=item A (Added) 

The file will become a new page on the wiki server.

=item M (Modified) 

The file has been modified locally.

=item U (Updated) 

The file has been updated with changes from the wiki server.

=item C (Conflicts) 

The file contains conflict markers.

=item ? (Unknown)

Neither the file, nor a corresponding server page exist.

=back

=item commit

Commits any changes in the specified local file to the Wiki site.  A check
is made first to make sure that there are no changes on the server more
recent than the most recent update.  Nothing will be comitted if the file 
and server version are identical.

When running C<mvs commit> you I<must> use the C<-m> flag to send a commit
message to the Mediawiki server.  e.g.:

  mvs commit -m 'Added Hotel Eldorado' Paris.wiki

=item preview

This command functions identically to C<mvs commit>, except that nothing is
actually committed.  Instead, the file is uploaded and the Mediawiki server
sends back a formatted preview.  The C<-m> flag is optional.  If you set
the L<MVS_BROWSER> environmental variable to the path and filename of your
favorite browser, mvs will launch it with the preview page.

=item clean

This command removes any local version reference files relating to
pages you've deleted.

  rm Paris.wiki
  mvs clean

=back

=head2 File names

Any additional arguments are taken as I<local> filenames to be processed.
The local filename of a given Mediawiki page will be the same as its URL
encoded name with the extension ".wiki".  If no arguments are given then
any filenames with the "wiki" extension and under the current directory are
processed.

=head1 OPTIONS

=head2 -h

Display usage information.

=head2 -D

Print information about known Mediawiki servers, then exit.

=head2 -q

Causes the command to be quiet.  Informational messages are suppressed.

=head2 -u "<username>"

Specifies a username for C<mvs login>.

=head2 -p "<password>"

Specifies a password for C<mvs login>.

=head2 -l "<language_code>"

The language code the wiki server uses to differentiate between language
versions.

=head2 -m "<your message>"

A commit message for C<mvs commit>.  Use this to explain the nature of your
changes.

=head2 -s "<your message>"

Same as C<-m>

=head2 --minor <yes|no|default>

Choose whether to mark change as a minor edit.  The default is to mark
changes as minor if the Mediawiki user profile is set to do so by
default.  Use this when committing a change with C<mvs commit> or
previewing with C<mvs preview>.

=head2 -M

Same as C<--minor yes>.

=head2 --watch <yes|no|keep|default>

Choose whether to add the edited page to your watchlist.  Specifying
C<keep> will maintain the current watched status.  The default is to
watch the page if it is already being watched, or if the Mediawiki
user profile is set to do so by default.  Use this when committing a
change with C<mvs commit> or previewing with C<mvs preview>.

=head2 -W

Same as C<--watch yes>.

=head2 -w "<wiki path>"

The path on the given C<host> to the Mediawiki script.  This defaults to
I<wiki/wiki.phtml> which is correct for a vanilla install of Mediawiki
1.4.x.

=head2 -v

Verbose.  If this is set C<mvs> will give you lots of extra information
about what it's doing.  The -q flag overrides this.

=head1 ENVIRONMENTAL VARIABLES

=head2 MVS_BROWSER

The browser you prefer to use for previewing changes.

=head2 HTTP_PROXY

A proxy server to use (if any), expressed as a standard URL, something like
this:

  export HTTP_PROXY=http://[username:password@]proxy.myorg.org:8080

=head1 CAVEATS

This is an early version of this program.  Future versions may have major
differences which will effect your ability to use them interchangeably with
this one.  In particular the initial "command" arguments may become
options and the handling of conflicts might change dramatically.

=head1 BUGS

Please submit bug reports to the CPAN bug tracker at
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-Mediawiki-Client>.

=head1 DISCUSSION

There is a discussion list.  You can subscribe or read the archives at:
L<http://www.geekhive.net/cgi-bin/mailman/listinfo/www-mediawiki-client-l>

=head1 SEE ALSO

=head2 Mediawiki

L<http://www.wikimedia.org|Mediawiki>

=head2 CVS

L<http://www.cvs.org|The CVS home page>

=head1 AUTHORS

=over

=item Mark Jaroski <mark@geekhive.net>

=item Bernhard Kaindl <bkaindl@ffii.org>

Improved error and usage messages.

=item Oleg Alexandrov <aoleg@math.ucla.edu>, Thomas Widmann <twid@bibulus.org>

Bug reports and feedback.

=item Adrian Irving-Beer <wisq@wisq.net>

Preview support, export support for multi-page update, more 'minor'
and 'watch' settings, and bug reports.

=back

=head1 COPYRIGHT

(C) Copyright 2004-2005, Mark Jaroski

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.