DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:gource_analysis

This is an old revision of the document!


I am fond of the wonderful videos made with Gource. This tool makes a representation of changes made on a version control system like git or SVN. Then I remember that DokuWiki is also a version control system like any other … Just have a look in the folder tree to find the directory dokuwiki/data/meta in which the files *. changes contain exactly the information needed.

More information on this blog (french version) or a translate version on this blog.

I wrote a small python script to generate logs from .changes files that can be used by Gource :

gourcedoku.py
#!/bin/python
 
"""
This program parse logs of a dokuwiki
and tranform them for gource (a log viewer)
http://code.google.com/p/gource/
 
developped by WolverineX02
site : http://wolverinex02.blogspot.com
 
"""
 
import os.path
import getopt
import sys
import re
 
 
 
def listdirectory2(path):
    """list all the files like *.changes, 
       read them and output them in gource's log syntax
    """
    WHITE = "FFFFFF"
    GREEN = "00F000"
    start_page_name = "start"
    for root, dirs, files in os.walk(path):
        for i in files:
            if  (re.search('\.changes$', i)):
                fichier = os.path.join(root, i)
                myfile = open(fichier, 'r')
                for line in myfile.readlines():
                    mots = line.split('\t')
                    if len(mots)>=6:
                        resultat = mots[0] + "|"
                        if mots[4] == '':
                            mots[4]  = 'Anonymous'
                        resultat += mots[4] + "|"
                        resultat += translate(mots[2]) + "|"
                        resultat += mots[3].replace(':', '/')
                        if mots[3].rfind(start_page_name) == len(mots[3])-len(start_page_name):
			    resultat += "|" + WHITE
                        else:
                            resultat += "|" + GREEN
                        print resultat
                    else:
                        resultat = mots[0] + "|Anonymous|"
                        resultat += translate(mots[2]) + "|"
                        resultat += fichier
                        resultat += "|FFFFFF"
                        print resultat
                myfile.close()
 
def translate(mot):
    """translate the dokuwiki vocabulary to the gource one
       C (also cc and sc from discussion plugin) ->A
       E (also ec from discussion plugin) -> M
       D (also dc and hc from discssion plugin) -> D
       other -> M 
    """
    if mot.upper == "C" or mot == 'cc' or mot == 'sc':
        return "A"
    elif mot.upper == "E" or mot == 'ec':
        return "M"
    elif mot.upper == "D" or mot == 'dc' or mot == 'hc':
        return "D"
    else:
        return "M"
 
def main(argv):
    """principal function
    """
    try:
        opts, args = getopt.getopt(argv, "hd:", ["help", "dokuwiki="])
    except getopt.GetoptError:
        usage()
        sys.exit(2)
    for opt, arg in opts:
        if opt in ("-h","--help"):
            usage()
            sys.exit()
        elif opt in ("-d","--dokuwiki"):
            print listdirectory2(arg)
 
 
def usage():
    """this function will display how to use this script
    """
    print "This script will output change logs of a dokuwiki"
    print "in a friendly way for gource"
    print "how to use it :"
    print "python gourcedoku.py -d ~/Sites/MyDokuwiki/ | sort > dokusort.log"
    print "and then :"
    print "gource --log-format custom dokusort.log --stop-position 1.0 \ "
    print "--stop-on-idle --file-idle-time 10000000"
    print "---"
    print "-h : help "
    print "-d : meta directory of your dokuwiki"
 
if __name__ == "__main__":
    main(sys.argv[1:])

then you can use Gource to watch logs :

gource --log-format custom dokusort.log --stop-position 1.0 --stop-on-idle --file-idle-time 10000000
tips/gource_analysis.1274111867.txt.gz · Last modified: 2010-05-17 17:57 by 193.9.13.136

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki