DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:gource_analysis

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tips:gource_analysis [2010-05-17 17:57] – correct the code for "delete" 193.9.13.136tips:gource_analysis [2010-05-20 15:53] (current) – some versions of gource need RGB hex colour to be in upper case 193.9.13.135
Line 1: Line 1:
-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. +====== Visualize Changes in Gource ====== 
 + 
 +I am fond of the wonderful videos made with [[http://code.google.com/p/gource/|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. 
  
  
Line 18: Line 20:
  
 """ """
 +import glob
 import os.path import os.path
 import getopt import getopt
Line 24: Line 26:
 import re import re
  
 +WHITE = "11FFAA"
 +GREEN = "00F000"
 +vector = (1,10,100)
 +start_page_name = "start"
  
 +def RGBToHTMLColor(rgb_tuple):
 +    """ convert an (R, G, B) tuple to #RRGGBB """
 +    hexcolor = '#%02X%02X%02X' % rgb_tuple
 +    # that's it! '%02x' means zero-padded, 2-digit hex values
 +    return hexcolor
 +
 +def HTMLColorToRGB(colorstring):
 +    """ convert #RRGGBB to an (R, G, B) tuple """
 +    colorstring = colorstring.strip()
 +    if colorstring[0] == '#': colorstring = colorstring[1:]
 +    if len(colorstring) != 6:
 +        raise ValueError, "input #%s is not in #RRGGBB format" % colorstring
 +    r, g, b = colorstring[:2], colorstring[2:4], colorstring[4:]
 +    r, g, b = [int(n, 16) for n in (r, g, b)]
 +    return (r, g, b)
 +
 +def colormodify(colorstring):
 +    rgb_tuple = HTMLColorToRGB(colorstring)
 +    r, g, b = (rgb_tuple[0]+vector[0]) % 255,(rgb_tuple[1]+vector[1]) % 255,(rgb_tuple[2]+vector[2]) % 255
 +    return RGBToHTMLColor((r, g, b))
 +
 +def listdirectory(path,color):
 +    l = glob.glob(path+"/*")
 +    for i in l:
 +        if os.path.isdir(i):
 +                listdirectory(i,colormodify(color))
 +        else:
 +                readfile(i,color)
  
 def listdirectory2(path): def listdirectory2(path):
Line 30: Line 64:
        read them and output them in gource's log syntax        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 root, dirs, files in os.walk(path):
         for i in files:         for i in files:
             if  (re.search('\.changes$', i)):             if  (re.search('\.changes$', i)):
                 fichier = os.path.join(root, i)                 fichier = os.path.join(root, i)
-                myfile = open(fichier, 'r'+                readfile(fichier,GREEN) 
-                for line in myfile.readlines(): + 
-                    mots = line.split('\t'+def readfile(fichier,color): 
-                    if len(mots)>=6: +    """read the file and output for each line of this 
-                        resultat = mots[0] + "|" +       file a log line for Gource 
-                        if mots[4] == '': +    """ 
-                            mots[4]  = 'Anonymous' + 
-                        resultat += mots[4] + "|" +    myfile = open(fichier, 'r'
-                        resultat += translate(mots[2]) + "|" +    for line in myfile.readlines(): 
-                        resultat += mots[3].replace(':', '/'+        mots = line.split('\t'
-                        if mots[3].rfind(start_page_name) == len(mots[3])-len(start_page_name): +        if len(mots)>=6: 
-     resultat += "|"WHITE +            resultat = mots[0] + "|" 
-                        else: +            if mots[4] == '': 
-                            resultat += "|"GREEN +                mots[4]  = 'Anonymous' 
-                        print resultat +            resultat += mots[4] + "|" 
-                    else: +            resultat += translate(mots[2]) + "|" 
-                        resultat = mots[0] + "|Anonymous|" +            resultat += mots[3].replace(':', '/'
-                        resultat += translate(mots[2]+ "|" +            if mots[3].rfind(start_page_name) == len(mots[3])-len(start_page_name): 
-                        resultat += fichier +                resultat += "|"color 
-                        resultat += "|FFFFFF" +            else: 
-                        print resultat +                resultat += "|"colormodify(color
-                myfile.close()+            print resultat 
 +    myfile.close() 
  
 def translate(mot): def translate(mot):
Line 89: Line 122:
             sys.exit()             sys.exit()
         elif opt in ("-d","--dokuwiki"):         elif opt in ("-d","--dokuwiki"):
-            print listdirectory2(arg)+            print listdirectory(arg,WHITE)
  
  
Line 108: Line 141:
 if __name__ == "__main__": if __name__ == "__main__":
     main(sys.argv[1:])     main(sys.argv[1:])
 +
 +</code>
 +launch the script inside your dokuwiki directory :  
 +<code bash>  
 +python gourcedoku.py -d ~/Sites/MyDokuwiki/ | sort > dokusort.log
 </code> </code>
 then you can use Gource to watch logs : then you can use Gource to watch logs :
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