Statistics
| Revision:

root / branches / v2_0_0_prep / dist-utils / scripts / svn-merge_workspace_with_tmp_build @ 30602

History | View | Annotate | Download (2.82 KB)

1
#!/usr/bin/python
2

    
3
from svn_utils import *
4
import pysvn
5

    
6
import sys
7
import os
8
from os import path
9

    
10
def usage():
11
  print """
12
Merge a gvSIG workspace with tmp_build tag
13

    
14
Current dir muts be the gvSIG workspace
15

    
16
If enviroment var '%s' isn't set
17
it use like gvSIG svn root this URL:
18
%s
19
the current is:
20
%s
21

    
22
usage:
23
  %s
24

    
25
""" % (gvSIG_svn_root_env_name,gvSIG_svn_default_root,get_gvSIG_SVN_root(),sys.argv[0])
26

    
27
def checks():
28
  if len(sys.argv) != 1:
29
    return False
30

    
31
  if not path.isdir("_fwAndami"):
32
    print "%s: _fwAndami theDir not found\n" % sys.argv[0]
33
    return False
34

    
35
  if not path.isfile("_fwAndami/andami.jar"):
36
    print "%s: _fwAndami theDir not found\n" % sys.argv[0]
37
    return False
38
  return True
39

    
40

    
41
def run():
42
  if not checks():
43
    usage()
44
    exit(1)
45
  svnRoot = get_gvSIG_SVN_root()
46
  print "gvSIG svn root: %s" % svnRoot
47
  print "Processing workspace %s....\n" % path.abspath(".")
48
  trgType = "tags"
49
  trgName = "tmp_build"
50
  trgNameStr= trgName
51

    
52
  processCount = 0
53
  errorList=list()
54
  listDir = os.listdir(".")
55
  listDir.sort()
56
  client = getSVNClient()
57
  for theDir in listDir:
58
    if not path.isdir(theDir):
59
      continue
60

    
61
    if theDir.startswith("."):
62
      print "Skip %s\n" % theDir
63
      continue
64

    
65
    print "--- %s ---" % theDir
66
    try:
67
       svnInfo = client.info(theDir)
68
    except Exception,ex:
69
      strErr = "Error: %s, %s" % (ex.__class__.__name__,str(ex))
70
      print strErr
71
      errorList.append((theDir,strErr))
72
      continue
73

    
74
    print " * Current url: %s" % svnInfo.url
75
    srcType,srcName = branchTypeAndName(svnRoot,svnInfo.url)
76

    
77
    if srcName == None:
78
      srcName=""
79

    
80
    try:
81
      trgURL = switchURL(svnRoot,svnInfo.url,trgType,trgName)
82
    except Exception,ex:
83
      strErr = "ERROR: %s\n" % ex
84
      print strErr
85
      errorList.append((theDir,strErr))
86
      continue
87

    
88
    srcRevisionToUse = getFirstCopyRevision(trgURL)
89

    
90
    print " * Source url: %s" % svnInfo.url
91
    print " * Source type and name : %s %s" % (srcType,srcName)
92
    print " * Version of source to use: %s " % (srcRevisionToUse)
93
    print " * Merge to: %s %s" % (trgType,trgNameStr)
94
    print " * Merget to URL: %s" % trgURL
95
    print " * Processing..."
96
    try:
97
      #client.switch(theDir,trgURL,True)
98
      client.merge(
99
            svnInfo.url,
100
            srcRevisionToUse,
101
            trgURL,
102
            pysvn.Revision( pysvn.opt_revision_kind.head ),
103
            theDir,
104
            recurse=True)
105
    except Exception,ex:
106
      strErr =  "SVN ERROR: %s, %s\n" % (ex.__class__.__name__,str(ex))
107
      print strErr
108
      errorList.append((theDir,strErr))
109
      continue
110

    
111
    processCount += 1
112
    print "*** OK ****\n"
113

    
114
  print "Finish... OK=%s Errors=%s" % (processCount,len(errorList))
115
  if len(errorList) > 0:
116
    print "Error in the projects:"
117
    for errorItem in errorList:
118
      print "\t* %s: %s" % errorItem
119
  exit(0)
120

    
121

    
122
if __name__=="__main__":
123
  run()