1 | """ Tag generation script. |
---|
2 | -------------------------- |
---|
3 | |
---|
4 | USAGE |
---|
5 | ----- |
---|
6 | |
---|
7 | python step1.py "<comment on version>" ## updates versionConfig.py and creates "step2.sh" |
---|
8 | Uses version specified in trunk |
---|
9 | bash step2.sh ## checks trunk into repository, creates tagged version |
---|
10 | """ |
---|
11 | |
---|
12 | from pkg_resources import parse_version |
---|
13 | import sys, os, glob, string, time |
---|
14 | if os.path.isfile( 'step2.sh' ): |
---|
15 | os.unlink( 'step2.sh' ) |
---|
16 | |
---|
17 | d1 = os.getcwd() |
---|
18 | print d1 |
---|
19 | sys.path.append('../trunk/dreqPy' ) |
---|
20 | ##os.chdir( '../trunk/dreqPy' ) |
---|
21 | ##print os.getcwd() |
---|
22 | ##time.sleep(1) |
---|
23 | import packageConfig |
---|
24 | ##import __init__ |
---|
25 | version = packageConfig.__version__ |
---|
26 | print 'version = ',version |
---|
27 | ##os.chdir( d1 ) |
---|
28 | |
---|
29 | svnBaseUrl = 'http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreq' |
---|
30 | |
---|
31 | ii = string.join( open( 'versionConfig.tmpl' ).readlines() ) |
---|
32 | tags = glob.glob( '../tags/*' ) |
---|
33 | |
---|
34 | ##f1 = lambda x: map( int, string.split(x, '.' ) ) |
---|
35 | def f1( vs ): |
---|
36 | if vs == 'latest': |
---|
37 | return (0,0) |
---|
38 | bits = string.split(vs, '.' ) |
---|
39 | estr = 'Version string should be "nn.nn" or "nn.[alpha|beta].nn": %s' % vs |
---|
40 | assert len(bits) in [2,3,4], estr |
---|
41 | if len( bits ) == 3: |
---|
42 | assert bits[1] in ['alpha','beta'], estr |
---|
43 | assert len(bits[0]) == 2 and len(bits[-1]) == 2, estr |
---|
44 | bits[0] = int( bits[0] ) |
---|
45 | bits[-1] = int( bits[-1] ) |
---|
46 | return bits |
---|
47 | |
---|
48 | def tcmp(t1,t2): |
---|
49 | if len(t1) != len(t2): |
---|
50 | if t1[0] == t2[0]: |
---|
51 | return cmp( len(t1), len(t2) ) |
---|
52 | else: |
---|
53 | return cmp( t1[0], t2[0] ) |
---|
54 | elif len(t1) == 2: |
---|
55 | if t1[0] == t2[0]: |
---|
56 | return cmp( t1[1], t2[1] ) |
---|
57 | else: |
---|
58 | return cmp( t1[0], t2[0] ) |
---|
59 | elif len(t1) == 3: |
---|
60 | if t1[0] == t2[0]: |
---|
61 | if t1[1] == t2[1]: |
---|
62 | return cmp( t1[2], t2[2] ) |
---|
63 | else: |
---|
64 | return cmp( t1[1], t2[1] ) |
---|
65 | else: |
---|
66 | return cmp( t1[0], t2[0] ) |
---|
67 | |
---|
68 | ##thistag, thiscomment = sys.argv[1:] |
---|
69 | thiscomment = sys.argv[1] |
---|
70 | thistag = version |
---|
71 | thistn = parse_version( version ) |
---|
72 | if len(tags) > 0: |
---|
73 | tn = map( parse_version, tags ) |
---|
74 | tn.sort() |
---|
75 | assert thistn > tn[-1], 'Requested tag not greater than last tag: %s' % str(tn[-1]) |
---|
76 | |
---|
77 | oo = open( '../trunk/dreqPy/versionConfig.py', 'w' ) |
---|
78 | for l in string.split( ii % (thistag, thiscomment), '\n' ): |
---|
79 | oo.write( '%s\n' % string.strip(l) ) |
---|
80 | oo.close() |
---|
81 | |
---|
82 | bashtmpl = """ |
---|
83 | tag=%(thistag)s |
---|
84 | comment='"%(thiscomment)s"' |
---|
85 | |
---|
86 | echo $tag, $comment |
---|
87 | cd ../trunk |
---|
88 | svn ci -m "Updated setup for tag %(thistag)s" |
---|
89 | svn copy %(svnBaseUrl)s/trunk %(svnBaseUrl)s/tags/%(thistag)s -m "%(thiscomment)s" |
---|
90 | |
---|
91 | ## cd %(svnBaseUrl)s/tags |
---|
92 | ## svn del latest |
---|
93 | ## svn ci -m "removed latest" |
---|
94 | #svn copy %(svnBaseUrl)s/tags/%(thistag)s %(svnBaseUrl)s/tags/latest |
---|
95 | """ |
---|
96 | |
---|
97 | oo = open( 'step2.sh', 'w' ) |
---|
98 | oo.write( bashtmpl % locals() ) |
---|
99 | oo.close() |
---|