~ubuntu-branches/ubuntu/quantal/torchat/quantal

« back to all changes in this revision

Viewing changes to version.py

  • Committer: Bazaar Package Importer
  • Author(s): Ulises Vitulli
  • Date: 2011-04-16 23:35:04 UTC
  • Revision ID: james.westby@ubuntu.com-20110416233504-j4dulunjoc224vfp
Tags: upstream-0.9.9.534
ImportĀ upstreamĀ versionĀ 0.9.9.534

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
import version_cached
 
3
 
 
4
NAME = "TorChat"
 
5
VERSION_MAJOR = "0.9.9"
 
6
SVN_OFFSET = 0
 
7
 
 
8
EXPERIMENTAL = False
 
9
 
 
10
def getDirMaxSvn(dir):
 
11
    try:
 
12
        #read all revisions in all-wcprops
 
13
        lines = open(os.path.join(dir, ".svn/all-wcprops")).readlines()
 
14
        max = 0
 
15
        for line in lines:
 
16
            if "/svn/!svn/ver/" in line:
 
17
                ver = int(line.split("/")[4])
 
18
                if ver > max:
 
19
                    max = ver
 
20
        
 
21
        #dive into all subdirs recursively
 
22
        subdirs = os.listdir(dir)
 
23
        for subdir in subdirs:
 
24
            if os.path.isdir(subdir) and subdir not in [".", "..", ".svn"]:
 
25
                subdir_ver = getDirMaxSvn(os.path.join(dir, subdir))
 
26
                if subdir_ver > max:
 
27
                    max = subdir_ver
 
28
        return max
 
29
    except:
 
30
        return False
 
31
 
 
32
svn_current = getDirMaxSvn(".")
 
33
svn_cached = version_cached.SVN_REVISION
 
34
 
 
35
if not svn_current:
 
36
    svn = svn_cached
 
37
else:
 
38
    svn = svn_current
 
39
    if svn_cached != svn_current:
 
40
        f = open("version_cached.py", "w")
 
41
        f.write("# this file is generated by version.py\nSVN_REVISION = %i\n" % svn_current)
 
42
        f.close()
 
43
                    
 
44
VERSION = VERSION_MAJOR + "." + str(svn - SVN_OFFSET)
 
45
VERSION_ONLY = VERSION
 
46
if EXPERIMENTAL:
 
47
    VERSION += "-experimental"
 
48
VERSION_SVN = svn