[Phpmyadmin-git] [SCM] phpMyAdmin website branch, master, updated. bbee78c1104146f36d1145dcface82563391eb1b

Michal Čihař nijel at users.sourceforge.net
Thu Mar 11 16:06:09 CET 2010


The branch, master has been updated
       via  bbee78c1104146f36d1145dcface82563391eb1b (commit)
       via  83511e004f43bb10df5d070d10f155f81c301276 (commit)
      from  289aa8e4ec467ddc107ad550291ca00df17b9c63 (commit)


- Log -----------------------------------------------------------------
commit bbee78c1104146f36d1145dcface82563391eb1b
Author: Michal Čihař <mcihar at novell.com>
Date:   Thu Mar 11 16:05:56 2010 +0100

    Ignore git cache.

commit 83511e004f43bb10df5d070d10f155f81c301276
Author: Michal Čihař <mcihar at novell.com>
Date:   Thu Mar 11 16:05:20 2010 +0100

    Generate translation stats from Git.

-----------------------------------------------------------------------

Summary of changes:
 README           |    4 +-
 cache/.gitignore |    1 +
 helper/cache.py  |  119 +++++-------------------------------------------------
 render.py        |   29 +++++++------
 4 files changed, 29 insertions(+), 124 deletions(-)

diff --git a/README b/README
index 887bfee..12c4747 100644
--- a/README
+++ b/README
@@ -14,8 +14,8 @@ Genshi -  http://genshi.edgewall.org/
 (0.5.0 tested)
 python-feedparser - http://www.feedparser.org
 (4.1 tested)
-pysvn - http://pysvn.tigris.org/
-(1.6.1 tested)
+GitPython - http://gitorious.org/projects/git-python/
+(0.1.6 tested)
 
 
 Security announcements
diff --git a/cache/.gitignore b/cache/.gitignore
index 2232829..775d8a0 100644
--- a/cache/.gitignore
+++ b/cache/.gitignore
@@ -1 +1,2 @@
 *.dump
+git*
diff --git a/helper/cache.py b/helper/cache.py
index e59e341..28c288d 100644
--- a/helper/cache.py
+++ b/helper/cache.py
@@ -23,10 +23,10 @@ import cPickle
 import feedparser
 import os
 import time
-import pysvn
 import glob
 import traceback
 import urllib
+import git
 
 from xml.dom import minidom
 
@@ -35,8 +35,6 @@ import helper.date
 
 # How long is cache valid (in seconds)
 CACHE_TIME = 60 * 60
-# How long is svn cache valid (in seconds)
-SVN_CACHE_TIME = 60 * 60 * 24
 
 class NoCache(Exception):
     pass
@@ -181,108 +179,13 @@ class FeedCache(URLCache):
                 self.set(cache, result)
         return result
 
-class SimpleSVNCache(Cache):
-    def __init__(self, url, timeout = SVN_CACHE_TIME):
-        super(SimpleSVNCache, self).__init__(timeout)
-        self._svn = pysvn.Client()
-        self._url = url
-
-    def cat(self, name):
-        '''
-        Performs cached svn cat, returns string with file content.
-        '''
-        fullname = '%s/%s' % (self._url, name)
-        cachename = 'svn-log-%s' % fullname
-
-        try:
-            data = self.get(cachename)
-            return data
-        except NoCache:
-            data = self._svn.cat(fullname)
-            self.set(cachename, data)
-            return data
-
-    def log(self, name):
-        '''
-        Performs cached svn log, returs list of revisions as dict with
-        message, date, author and revision fields.
-
-        1. If cache is up to date, use cache.
-        2. If cache exists, use it as base, request only remaining logs.
-        3. Request missing logs.
-        4. Save log to cache and return it.
-        '''
-        fullname = '%s/%s' % (self._url, name)
-        cachename = 'svn-log-%s' % fullname
-
-        try:
-            list = self.get(cachename)
-            return list
-        except NoCache:
-            pass
-
-        try:
-            list = self.force_get(cachename)
-            base = list[0]['revision']
-        except NoCache:
-            list = []
-            base = 0
-
-        try:
-            base_rev = pysvn.Revision(pysvn.opt_revision_kind.number, base)
-            self.dbg('svn log -r %d %s' % (base, fullname))
-            svnlog = self._svn.log(fullname, revision_end = base_rev)
-            newlog = [{
-                'message': x['message'],
-                'revision': x['revision'].number,
-                'date': helper.date.fmtdate.fromtimestamp(x['date']),
-                'author': x['author'],
-                } for x in svnlog]
-            list.extend(newlog)
-            list.sort(key = lambda x: x['revision'], reverse = True)
-            self.set(cachename, list)
-        except pysvn.ClientError:
-            traceback.print_exc()
-        return list
-
-class SVNCache(SimpleSVNCache):
-    def __init__(self, url, timeout = SVN_CACHE_TIME):
-        super(SVNCache, self).__init__(timeout)
-        self._svn = pysvn.Client()
-        self._url = url
-        self._updated = False
-        self._wc = self.get_name('svn-%s' % self._url, '%s')
-
-    def ls(self):
-        '''
-        Performs cached svn ls, returs list of URLs.
-        '''
-        self.update_wc()
-        files = glob.glob(os.path.join(self._wc, '*'))
-        files.sort()
-        return [os.path.basename(x) for x in files]
-
-    def cat(self, name):
-        '''
-        Performs cached svn cat, returns string with file content.
-        '''
-        self.update_wc()
-        return open(os.path.join(self._wc, name), 'r').read()
-
-    def update_wc(self):
-        '''
-        Updates working copy of repository.
-        '''
-        if self._updated:
-            return
-        if not os.path.exists(self._wc):
-            self.dbg('svn co %s' % self._url)
-            self._svn.checkout(self._url, self._wc)
-            self._updated = True
-        elif not self.check_timeout(self._wc):
-            try:
-                self.dbg('svn up %s' % self._url)
-                self._svn.update(self._wc)
-            except pysvn.ClientError:
-                traceback.print_exc()
-            self._updated = True
+class GitCache(Cache):
+    def __init__(self, url):
+        self.dirname = self.get_name(url, '%s')
+        if not os.path.exists(self.dirname):
+            os.system('git clone %s %s' % (url, self.dirname))
+        else:
+            os.system('cd %s ; git pull' % self.dirname)
+        self.repo = git.Repo(self.dirname)
+        self.tree = self.repo.tree()
+        self.langtree = self.tree['lang']
diff --git a/render.py b/render.py
index de7fb1f..faf85cc 100755
--- a/render.py
+++ b/render.py
@@ -86,8 +86,7 @@ PROJECT_SUMMARY_RSS = 'https://sourceforge.net/export/rss2_projsummary.php?group
 DONATIONS_RSS = 'https://sourceforge.net/export/rss2_projdonors.php?group_id=%d&limit=20' % PROJECT_ID
 PROJECT_VCS_RSS = 'http://cia.vc/stats/project/phpmyadmin/.rss'
 PROJECT_DL = 'http://prdownloads.sourceforge.net/%s/%%s' % PROJECT_NAME
-PROJECT_SVN = 'https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyAdmin/'
-TRANSLATIONS_SVN = '%slang/' % PROJECT_SVN
+PROJECT_GIT = 'git://phpmyadmin.git.sourceforge.net/gitroot/phpmyadmin/phpmyadmin'
 PLANET_RSS = 'http://planet.phpmyadmin.net/rss20.xml'
 RSS_CZ = 'http://phpmyadmin.cz/rss.xml'
 RSS_RU = 'http://php-myadmin.ru/rss/news.xml'
@@ -125,7 +124,7 @@ def copytree(src, dst):
     names = os.listdir(src)
     errors = []
     for name in names:
-        if name == '.svn' or name.find('.swp') != -1 or name[0] == '_':
+        if name == '.git' or name == '.svn' or name.find('.swp') != -1 or name[0] == '_':
             continue
         srcname = os.path.join(src, name)
         dstname = os.path.join(dst, name)
@@ -196,8 +195,7 @@ class SFGenerator:
         self.feeds = helper.cache.FeedCache()
         self.xmls = helper.cache.XMLCache()
         self.urls = helper.cache.URLCache()
-        self.svn = helper.cache.SVNCache(TRANSLATIONS_SVN)
-        self.simplesvn = helper.cache.SimpleSVNCache(PROJECT_SVN)
+        self.git = helper.cache.GitCache(PROJECT_GIT)
 
     def get_outname(self, page):
         '''
@@ -867,6 +865,8 @@ class SFGenerator:
         for root, dirs, files in os.walk(TEMPLATES):
             if '.svn' in dirs:
                 dirs.remove('.svn')  # don't visit .svn directories
+            if '.git' in dirs:
+                dirs.remove('.git')  # don't visit .git directories
             files.sort()
             dir = root[len(TEMPLATES):].strip('/')
             if len(dir) > 0:
@@ -911,9 +911,10 @@ class SFGenerator:
         '''
         helper.log.dbg('Processing translation stats...')
         self.data['translations'] = []
-        list = self.svn.ls()
-        translators = XML(self.simplesvn.cat('translators.html'))
-        english = self.svn.cat('english-utf-8.inc.php')
+        list = self.git.langtree.keys()
+        list.sort()
+        translators = XML(self.git.tree['translators.html'].data)
+        english = self.git.langtree['english-utf-8.inc.php'].data
         allmessages = len(re.compile('\n\$str').findall(english))
         for name in list:
             if name[-14:] != '-utf-8.inc.php':
@@ -931,18 +932,18 @@ class SFGenerator:
             translator = self.fmt_translator(translator)
             short = data.langnames.MAP[lang]
             helper.log.dbg(' - %s [%s]' % (lang, short))
-            svnlog = self.svn.log(name)
+            gitlog = self.git.repo.log(path = 'lang/english-utf-8.inc.php')
             langs = '%s|%s|%s' % (lang, short, baselang)
             regexp = re.compile(LANG_REGEXP % (langs, langs), re.IGNORECASE)
             found = None
             if lang == 'english':
-                found = svnlog[0]
+                found = gitlog[0]
             else:
-                for x in svnlog:
-                    if regexp.findall(x['message']) != []:
+                for x in gitlog:
+                    if regexp.findall(x.message) != []:
                         found = x
                         break
-            content = self.svn.cat(name)
+            content = self.git.langtree[name].data
             missing = len(re.compile('\n\$str.*to translate').findall(content))
             translated = allmessages - missing
             percent = 100.0 * translated / allmessages
@@ -953,7 +954,7 @@ class SFGenerator:
             else:
                 css =''
             try:
-                dt = found['date']
+                dt = datetime.datetime(*found.committed_date[:6])
             except TypeError:
                 dt = ''
             self.data['translations'].append({


hooks/post-receive
-- 
phpMyAdmin website




More information about the Git mailing list