Note: I no longer use mw and it appears to be broken—perhaps Media Wiki has changed its API. I’m now using the Mediawikir plugin with SublimeText 3.

The MediaWiki experience can be as frustrating to a hacker as it is for a newbie. Editing on the Web page is annoying and the syntax is atrocious. For myself, I prefer using Markdown syntax, a good text editor, pandoc , and a distributed version control system (VCS). (That’s how I wrote my book.)

I, and others, crave a similar tool-set for editing MediaWikis. I tried MOUNT.WIKIPEDIAFS once, but looking at a versioned wiki as a simple file-system didn’t do the trick, and the project is now unmaintained. The mvs Mediawiki client comes with Ubuntu, but I could never get it to work. wikish is OK but doesn’t do all that I would like.

At the beginning of 2011 I started making commits to Ian Weller’s mw , “VCS-like nonsense for MediaWiki websites”. He provides a great foundation and the basic pull , diff , commit and status commands. Since it’s written in Python, I could actually grok it, extend pull so it can pull new updates and warn of conflicts, and provide simple merge functionality.

mw is initiated by associating it with a MediaWiki server, in this case the English Wikipedia.

> mw init
> mw login  # if you need/want to
Username: Reagle
Password: *********
Login with token
Login successful! (yay)

I can then pull the latest revision of my user page, which shows the last saved comment and contributor.

> mw pull 'User:Reagle'
pulling:        "User:Reagle" : "Fixed a typo" by "User555"

The status shows that everything is “clean” and in sync. In this case we use the -A/–all options so we seen even the unmodified (‘clean’) pages.

> mw status --all
C User:Reagle!

I add the text “foo” to my local copy, which can be seen in the diff.

> echo -e "\nfoo\n" >> User\ 
> mw diff User\:Reagle
--- a/ (revision 411778675)
+++ b/ (working copy)
 -3,3 +3,5 
 I keep a link to a {{oldid|User:Reagle/Failed_predictions|239601703|deleted copy of "Failed Predictions"}} here for a class I teach.
 I also have a page for a [[User:Reagle/Berkman_Reading_Group|Wikipedia-related reading group]] in Cambridge.

The status shows it has been modified.

> mw status

And the modification is sent back to the wiki with a commit .

> mw commit -m 'added a foo'

status shows the local copy is now “clean” again.

> mw st --all
C User:Reagle!

Now, imagine I replace “foo” with “bar” in my local copy and at the same time someone replace “foo” with “BAZ” on the wiki. An attempt to pull the wiki copy is skipped because there are locally uncommitted modifications.

> mw pull
skipping:       User:Reagle -- uncommitted modifications 

Trying to commit my changes (and overwrite the wiki change) results in a warning.

> mw ci
Edit summary: save my local changes and overwrite remove
warning: edit conflict detected on "" (412089112 -> 412202828) -- skipping!

Sorting out the conflicts can then be done using the merge command – once you define your preferred merge tool in the config file. (Basically, the command runs your merge tool on the local and remote copies, then recommits the result.)