Command line example?

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
Traveler
Posts: 16
Joined: Fri Feb 20, 2004 12:04 pm

Command line example?

Post by Traveler » Wed Feb 25, 2004 11:43 am

Hello,
I'd like to create a batch file to traverse a directory and add all the .cpp and .h files to Vault.
Could someone give me an example of the vault command line, specifically what the repositoryfolder and localpath params would look like?

TIA.

ericsink
Posts: 346
Joined: Mon Dec 15, 2003 1:52 pm
Location: SourceGear
Contact:

Re: Command line example?

Post by ericsink » Wed Feb 25, 2004 3:28 pm

Traveler wrote:Hello,
I'd like to create a batch file to traverse a directory and add all the .cpp and .h files to Vault.
Could someone give me an example of the vault command line, specifically what the repositoryfolder and localpath params would look like?

TIA.
I'm not sure the cmdline client is the way to do this. However:

Suppose you have a file at c:\foo.cpp and you want to add this file into the repository folder at $/src/stuff, the command is:

Code: Select all

vault.exe ADD $/src/stuff c:\foo.cpp
You may want to make your question more specific, because I'm not sure I answered it.
Eric Sink
Software Craftsman
SourceGear

Guest

Post by Guest » Thu Feb 26, 2004 1:53 pm

Thanks for the reply.
What I was looking for was what I finally figured out through trial and error:

Code: Select all

for %a in (*.cpp *.h *.rc *.mak) do vault.exe add -user Admin -password pwd -host xx.xxx.xxx.xxx -repository King %NewFolder %_CWD\%a
Where NewFolder is an environment var set by this batch file -- it decides if the current dir gets a folder in Vault; if so, it sets the NewFolder env var.

Code: Select all

vault.exe CreateFolder -user Admin -password pwd -host xx.xxx.xxx.xxx -repository King %NewFolder

vault.exe Commit -user Admin -password pwd -host xx.xxx.xxx.xxx -repository King %NewFolder
Unfortunately, the "for %a in ()" is brutally slow. Any suggestions on how to make that part of the operation more efficient?

TIA.

sterwill
Posts: 256
Joined: Thu Nov 06, 2003 10:01 am
Location: SourceGear

Post by sterwill » Thu Feb 26, 2004 2:58 pm

The "add" command can take more than one local item to add to a given repository folder. If it's possible to rewrite your script to do all files in a single folder at once, you can benefit from this syntax.

Vault 2.0's command-line client has a batch mode, which can read multiple commands from a file or stdin. Most of the startup time for the Vault client is constructing the web service classes (which is slow for reasons unknown to me) and logging into the service. Batch mode only has to startup and login once, and then can commit many transactions.

You may want to rewrite your program to construct a file which can then later be fed to Vault. The format of the file (call it "cmds.txt") would be something like this:

Code: Select all

add $/destination file1.txt
add $/destination file2.txt
add $/destination/sub file3.txt
commit
Invoke Vault like: vault.exe <...> batch cmds.txt
Shaw Terwilliger
SourceGear LLC
`echo sterwill5sourcegear6com | tr 56 @.`

Post Reply