#!/usr/bin/python from svn_utils import * import sys import os from os import path def usage(): print """ Prepare 'tmp_build' tag from source dir If enviroment var '%(env_name)s' isn't set it use like gvSIG svn root this URL: %(defalut_root)s the current is: %(cur_root)s usage: %(command)s source message - source: Source path of copy relative to root - message: Message to use in the operations examples: %(command)s branches/v10 pre_v1_1_1_Build_1017 %(command)s trunk pre_v1_2_Build_1203 """ % { "env_name":gvSIG_svn_root_env_name, "defalut_root":gvSIG_svn_default_root, "cur_root":get_gvSIG_SVN_root(), "command":sys.argv[0] } def checks(): if len(sys.argv) != 3: return False return True def run(): if not checks(): usage() exit(1) svnRoot = get_gvSIG_SVN_root() print "gvSIG svn root: %s" % svnRoot client = getSVNClient() logMsg = str(sys.argv[2]) src = sys.argv[1] srcURL = "/".join((svnRoot,src)) def logMsgCallback(): return True,str(logMsg) client.callback_get_log_message = logMsgCallback trgType = "tags" trgName = "tmp_build" trgNameStr = trgName trgURL = "/".join((svnRoot,trgType,trgName)) tagsForlderURL = "/".join((svnRoot,trgType)) print "Checks for an existing tags/temp_build... %s"%tagsForlderURL entries = client.ls(tagsForlderURL) for entry in entries: if entry["name"] == trgURL: existsTrg = True break else: existsTrg = False if existsTrg: msgs = client.log(trgURL,strict_node_history=True,limit=5) print "tags/temp_build found!!! this is the last five logs:" print formatSvnLogForPrint(msgs) print "\n\n" yesNo = raw_input("Continue and remove this tag (y/n)?") if not yesNo.strip().lower().startswith("y"): print "** Aborted by user **" exit(1) print "Removing tags/temp_build ..." client.remove(trgURL) print "Creating tags/temp_build...." print "------> %s" % trgURL print "======> %s" % logMsg client.callback_get_login = login client.mkdir(trgURL,logMsg) print "Indentify proyects to copy...." entries = client.ls(srcURL) dirsToCopy = [entry["name"].split("/")[-1] for entry in entries] for adir in dirsToCopy: print " - %s" % adir print "\nStart make copy..." for adir in dirsToCopy: tmpSrcDir = "/".join((srcURL,adir)) tmpTrgDir = "/".join((trgURL,adir)) print "%s --> %s" % (tmpSrcDir,tmpTrgDir) client.copy(tmpSrcDir,tmpTrgDir) print "\nFinish... OK" exit(0) if __name__=="__main__": run()