root / branches / v2_0_0_prep / dist-utils / scripts / svn-preparar_tag @ 30602
History | View | Annotate | Download (2.41 KB)
1 |
#!/usr/bin/python |
---|---|
2 |
|
3 |
from svn_utils import * |
4 |
import sys |
5 |
import os |
6 |
|
7 |
from os import path |
8 |
|
9 |
def usage(): |
10 |
print """ |
11 |
Prepare 'tmp_build' tag from source dir |
12 |
|
13 |
If enviroment var '%(env_name)s' isn't set |
14 |
it use like gvSIG svn root this URL: |
15 |
%(defalut_root)s |
16 |
the current is: |
17 |
%(cur_root)s |
18 |
|
19 |
usage: |
20 |
%(command)s source message |
21 |
|
22 |
- source: Source path of copy relative |
23 |
to root |
24 |
|
25 |
- message: Message to use in the operations |
26 |
|
27 |
examples: |
28 |
|
29 |
%(command)s branches/v10 pre_v1_1_1_Build_1017 |
30 |
|
31 |
%(command)s trunk pre_v1_2_Build_1203 |
32 |
|
33 |
""" % { |
34 |
"env_name":gvSIG_svn_root_env_name, |
35 |
"defalut_root":gvSIG_svn_default_root, |
36 |
"cur_root":get_gvSIG_SVN_root(), |
37 |
"command":sys.argv[0] |
38 |
} |
39 |
|
40 |
def checks(): |
41 |
if len(sys.argv) != 3: |
42 |
return False |
43 |
return True |
44 |
|
45 |
def run(): |
46 |
if not checks(): |
47 |
usage() |
48 |
exit(1) |
49 |
svnRoot = get_gvSIG_SVN_root() |
50 |
print "gvSIG svn root: %s" % svnRoot |
51 |
|
52 |
client = getSVNClient() |
53 |
|
54 |
logMsg = str(sys.argv[2]) |
55 |
src = sys.argv[1] |
56 |
srcURL = "/".join((svnRoot,src)) |
57 |
def logMsgCallback(): |
58 |
return True,str(logMsg) |
59 |
client.callback_get_log_message = logMsgCallback |
60 |
|
61 |
trgType = "tags" |
62 |
trgName = "tmp_build" |
63 |
trgNameStr = trgName |
64 |
trgURL = "/".join((svnRoot,trgType,trgName)) |
65 |
tagsForlderURL = "/".join((svnRoot,trgType)) |
66 |
|
67 |
print "Checks for an existing tags/temp_build..." |
68 |
entries = client.ls(tagsForlderURL) |
69 |
for entry in entries: |
70 |
if entry["name"] == trgURL: |
71 |
existsTrg = True |
72 |
break |
73 |
else: |
74 |
existsTrg = False |
75 |
|
76 |
|
77 |
if existsTrg: |
78 |
msgs = client.log(trgURL,strict_node_history=True,limit=5) |
79 |
print "tags/temp_build found!!! this is the last five logs:" |
80 |
print formatSvnLogForPrint(msgs) |
81 |
print "\n\n" |
82 |
yesNo = raw_input("Continue and remove this tag (y/n)?") |
83 |
if not yesNo.strip().lower().startswith("y"): |
84 |
print "** Aborted by user **" |
85 |
exit(1) |
86 |
|
87 |
print "Removing tags/temp_build ..." |
88 |
client.remove(trgURL) |
89 |
|
90 |
print "Creating tags/temp_build...." |
91 |
client.mkdir(trgURL,logMsg) |
92 |
|
93 |
|
94 |
print "Indentify proyects to copy...." |
95 |
entries = client.ls(srcURL) |
96 |
dirsToCopy = [entry["name"].split("/")[-1] for entry in entries] |
97 |
for adir in dirsToCopy: |
98 |
print " - %s" % adir |
99 |
|
100 |
|
101 |
print "\nStart make copy..." |
102 |
for adir in dirsToCopy: |
103 |
tmpSrcDir = "/".join((srcURL,adir)) |
104 |
tmpTrgDir = "/".join((trgURL,adir)) |
105 |
print "%s --> %s" % (tmpSrcDir,tmpTrgDir) |
106 |
client.copy(tmpSrcDir,tmpTrgDir) |
107 |
|
108 |
print "\nFinish... OK" |
109 |
exit(0) |
110 |
|
111 |
|
112 |
if __name__=="__main__": |
113 |
run() |