[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn and wscript

From: BRM <bm_witness_at_yahoo.com>
Date: Fri, 6 Nov 2009 07:20:26 -0800 (PST)

I integrated SVN into our build process using WSH/jscript, and the official CollabNet releases of SVN. (CollabNet adds registry entries for where SVN is installed, so it is helpful. I'd use the non-CollabNet version if the installer did that. Both are basically the same otherwise.)

I have found that is it most helpful to run the scripts from the command-line to figure out problems as you may get some details you won't get by just running it. I also tried to redirect all output into a log file so I could capture as much of any problem as possible. This will likely give you the actual problem you are encountering. It's not likely with your code below - it's likely the software is generating an error that you can't recover from in this manner.

Also you need to be aware that running SVN from the command-line does have some limitations last I was aware as it doesn't use the Windows Unicode APIs for accessing files. So path depths could be an issue.

HTH,

Ben

________________________________
From: Luke Mason <lmason_at_oasisasset.com.au>
To: users_at_subversion.tigris.org
Sent: Thu, November 5, 2009 11:32:31 PM
Subject: svn and wscript

  
Hi,
 
I’m trying to integrate subversion into our build process.
We have a ticketing system that we also use to list associated sql files to
that allows us to specify their apply order. We have a script that gets all
tickets for a build, all associated sql, in order. Their source may be
one of several places, and will include SVN.
 
SVN_REMOTE is our svn server, served over http.
SVN_LOCAL is where the working copy should be
(d:\build\svn_wc).
 
runCmd is used to execute the commandline, catching output
and shooting it through to the log. When this is run, I end up hanging.
The directory structure is created, including a .svn dir, but no files.
When I cancel the batch job, all the files are then created (but my batch is
dead, so no good to me). I have also tried it with cmd /c in front of the
command – didn’t appear to work. Runcmd however works quite
well for other commands.
 
Before anyone asks, yes, it has to be run in windows. No, I
don’t have time to learn python.
svn, version 1.6.3 (r38063) (so not very far behind)
 
To checkout the directory containing an sql file I need, I
run:
Function ProcessSVNFile(filename, svn_filepath)
                Debug("Function:
ProcessSVNFile")
                'remove
the remote prefix for the svn repos, replace it with the path to the local
working copy, then swap the slashes.
                Dim
local_path
                Dim
cmd
                Dim
return_code
                
                local_path
= replace(replace(svn_filepath, SVN_REMOTE, SVN_LOCAL), "/",
"\")
                cmd
="svn checkout --force --depth files --username xxxx --password xxxx
--non-interactive " & svn_filepath & " " &
local_path
                ‘debug("Command:
" & cmd)
                return_code
= runCmd(cmd, "Get SVN File Directory")
                if
return_code <> 0 then
                                Log
"Failure: Could not checkout " & filename, "Error Code:
" & return_code, LOG_FAIL
                else
                                Log
"Success: Checked out " & filename, "", LOG_NORMAL
                end
if
                
                Log
"Info: " & local_path, "", LOG_NORMAL
                if
not fso.FileExists(local_path & filename) then
                                Log
"Failure: File " & filename & " does not exist at "
& local_path, "", LOG_FAIL
                else
                                Log
"Success: File " & filename & " exists",
"", LOG_NORMAL
                end
if
                ProcessSVNFile
= local_path & filename
End Function
 
' generic function to run a command and log the standard
output.
' returns the exit code.
Function runCmd(cmd, msg)
                debug("Function:
runCmd: " & msg)
                Dim
objShell
                Dim
objExecObject
                Dim
strText
                Set
objShell = WScript.CreateObject("WScript.Shell")
                Set
objExecObject = objShell.Exec(cmd)
 
                '
wait for it to finish
                do
while objExecObject.Status = 0
                                WScript.Sleep
100
                loop
 
                LogSectionOpen
"runCmd"
                do
while not objExecObject.StdOut.AtEndOfStream
                                strText
= objExecObject.StdOut.ReadLine()
                                Log
strText, "", LOG_NORMAL
                loop
                LogSectionClose
"runCmd"
                runCmd
= objExecObject.ExitCode
                Set
objExecObject = Nothing
End Function
 
Regards,
 
Luke
"This email is intended for the named recipient only. The information contained in this message may be confidential, or commercially sensitive. If you are not the intended recipient you must not reproduce or distribute any part of this email, disclose its contents to any other party, or take any action in reliance on it, or in reference to it. If you have received this email in error, would you please contact the sender immediately and delete/destroy all copies of this message, both electronic and otherwise. It is the recipient's duty to virus scan and otherwise test the enclosed information before using the information or loading attached files onto any computer system. Oasis Asset Management Ltd does not warrant that the information contained in this e-mail is free from viruses, defects, errors, interception or interference. Any views expressed in this message are those of the individual sender, except where that sender specifically states them to be
 the views of Oasis Asset Management Ltd."

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2415118

To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-11-06 16:21:50 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.