Statistics
| Revision:

svn-gvsig-desktop / trunk / install / scripts / svnScripts / svn-preparar_tag @ 34464

History | View | Annotate | Download (2.58 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
def login(*args):
40
    return True, 'XXXXX', 'XXXXX', False
41

    
42
def checks():
43
  if len(sys.argv) != 3:
44
    return False
45
  return True
46

    
47
def run():
48
  if not checks():
49
    usage()
50
    exit(1)
51
  svnRoot = get_gvSIG_SVN_root()
52
  print "gvSIG svn root: %s" % svnRoot
53

    
54
  client = getSVNClient()
55
     
56
  logMsg = str(sys.argv[2])
57
  src = sys.argv[1]
58
  srcURL = "/".join((svnRoot,src))
59
  def logMsgCallback():
60
    return True,str(logMsg)
61
  client.callback_get_log_message = logMsgCallback
62

    
63
  trgType = "tags"
64
  trgName = "tmp_build"
65
  trgNameStr = trgName
66
  trgURL = "/".join((svnRoot,trgType,trgName))
67
  tagsForlderURL = "/".join((svnRoot,trgType))
68

    
69
  print "Checks for an existing tags/temp_build... %s"%tagsForlderURL
70
  entries = client.ls(tagsForlderURL)
71
  for entry in entries:
72
    if entry["name"] == trgURL:
73
      existsTrg = True
74
      break
75
  else:
76
    existsTrg = False
77

    
78

    
79
  if existsTrg:
80
    msgs = client.log(trgURL,strict_node_history=True,limit=5) 
81
    print "tags/temp_build found!!! this is the last five logs:"
82
    print formatSvnLogForPrint(msgs)
83
    print "\n\n"
84
    yesNo = raw_input("Continue and remove this tag (y/n)?")
85
    if not yesNo.strip().lower().startswith("y"):
86
      print "** Aborted by user **"
87
      exit(1)
88

    
89
    print "Removing tags/temp_build ..."
90
    client.remove(trgURL)
91
    
92
  print "Creating tags/temp_build...."
93
  print "------> %s" % trgURL
94
  print "======> %s" % logMsg
95

    
96
  client.callback_get_login = login
97

    
98
  client.mkdir(trgURL,logMsg)
99

    
100

    
101
  print "Indentify proyects to copy...."
102
  entries = client.ls(srcURL)
103
  dirsToCopy = [entry["name"].split("/")[-1] for entry in entries]
104
  for adir in dirsToCopy:
105
    print "  - %s" % adir
106

    
107

    
108
  print "\nStart make copy..."
109
  for adir in dirsToCopy:
110
    tmpSrcDir = "/".join((srcURL,adir))
111
    tmpTrgDir = "/".join((trgURL,adir))
112
    print "%s --> %s" % (tmpSrcDir,tmpTrgDir)
113
    client.copy(tmpSrcDir,tmpTrgDir)
114

    
115
  print "\nFinish... OK"
116
  exit(0)
117

    
118

    
119
if __name__=="__main__":
120
  run()