Topic on Project:Support desk

[RESOLVED for Git] Wiki revisions history --> SVN/Git/Hg repository?

9
194.44.30.245 (talkcontribs)

Is it possible to export MediaWiki history into Subversion (Git, Hg, whatever) so later all newer MediaWiki-based wiki revisions could be updated (pulled) into that copy? I would expect that copy to be read-only without committing and pushing back to the wiki, that does not really matter. But is it possible? Thanks!

Florianschmidtwelzow (talkcontribs)

You mean the MediaWiki files, yes? Then yes, you can clone MW from git: https://www.mediawiki.org/wiki/Download_from_Git

and pull the newest files again, if changed. BUT: This is the master, which isn't for production use, so i would say, that's better to download the latest stable snapshoot of MediaWiki. It's possible to checkout REL branches, but what you do when the branch changes (maybe from REL1_23 to REL1_24)?

Another possible solution is to checkout the branch to a temporary location (e.g. /var/wiki/template) and copy the files to your production (e.g. /var/www/wiki) after a new version.

195.234.75.155 (talkcontribs)

Thanks for the answer, but sorry I seem to have asked a confusing question. Let me try to explain the subject better. I would like to checkout not the source code of MediaWiki, but the "source" of a wiki content.

For example, if my local wiki has two articles, let's say Foo and Bar, and just two edits at these two, then something like the following steps would be great (I prefer Mercurial, but the idea would be clear for SVN and Git):

  • hg clone %MY_LOCAL_WIKI_CONTENT_URL% - to make a local dump of the wiki
  • hg up 1 - to update to the very first edit in the wiki, so my local dump working copy snapshot at this revision could have just file, let's say, articles/Foo
  • hg up 2 - to update the working copy so a newer edit could appear at the working copy, articles/Bar
  • ... some time passes ... and then hg pull / hg up to sync with the latest wiki changes

So, it's more about the wiki content dump to be able to navigate through revisions and particular content snapshots (it may be one of possible usages), not the wiki engine source code.

Florianschmidtwelzow (talkcontribs)

Ok, then my first thought was right :D But: MediaWiki saves the articles and revisions not in files, the content is saved in a database, e.g. MySQL. So you need to export the database first. Alternative you can export the articles as XML and import them (with revisions if selected) in a new wiki (see Special:Export and Special:Import or using commandline). For further information to that, see: https://www.mediawiki.org/wiki/Manual:Importing_XML_dumps

With git/svn or something else it would be simply impossible i think :)

195.234.75.155 (talkcontribs)

Thanks! That matches what I want much closer. I've just played with the export feature and it looks very similar, yes, but very limited and not that configurable. However, it looks like the incremental changes could be exported only by writing a custom PHP script (MediaWiki stores revision diffs only, right?). If I could write such an extension, I guess I would write an SVN storage driver (or whatever it's called) so it could emulate a storage file system just querying the MediaWiki database, I think or something like that. Thank you again!

MarkAHershberger (talkcontribs)

MediaWiki stores the entire revision of a page in the revision table.

Still, I've seen git frontends for MediaWiki before so I went looking. I came across Leviation which isn't the thing I remember, but maybe it will help you.

195.234.75.155 (talkcontribs)
>> MediaWiki stores the entire revision of a page in the revision table.

Oops, I was not aware of this. I believed that it stores diffs only, and probably snapshots every N revisions to accelerate the history diffs computing.

I've just took a little look at the Levitation project page at GitHub. Not sure how it works yet, and the project seems to be no longer maintained. However this stills makes some interest to me. Thank you!

194.44.30.5 (talkcontribs)

Hi. If you're interested in a particular working solution, please see my comment below. Thanks!

194.44.30.5 (talkcontribs)

I managed to do exactly what I want. To be honest, I thought that mirroring a wiki into a Git repository is the most advanced thing I could ever want for such a scenario, but this following method even allows to push wiki changes back to the wiki. It's all built around a Git built-in concept of remote helpers that can be treated as a sort of bridges between heterogenous systems. Nevertheless, I don't know how to fetch talk pages and categories, but I hope it won't be an issue in the future. So I came across this page and noticed a very similar thing. Here is the manual describing this remote helper also saying that it's a Git built-in. True, this extension is a part of the Git source code repository at Github. Since I couldn't manage to make it work under Cygwin, I had to install a virtual machine with Linux Mint (just a tiny personal preference) where all of necessary operations might be easier. And yes, this here are the commands that work for me:

$ sudo apt-get install libmediawiki-api-perl
$ sudo apt-get install libdatetime-format-iso8601-perl
$ sudo apt-get install git
$ sudo apt-get install git-mediawiki
$ git clone mediawiki::http://localhost:8080/wiki
$ cd wiki

The current known to me, after a short test, issues are:

  1. I have no idea how to fetch categories and the talk pages (didn't check templates, though)
  2. If you just commit, your local changes are signed with your Git identity information, but once you push back to the wiki, the changes are recorded by anonymous user. This seems to work well if you configure the MediaWiki remote helper.
  3. Didn't check what happens if you push changes to protected pages.
  4. Files seem to be not cloned/pulled as well, unfortunately.

I hope to find how to deal with those issues, but I'm not sure :)

Reply to "[RESOLVED for Git] Wiki revisions history --> SVN/Git/Hg repository?"