Select statement to return the last tran / vs id for folder

This forum is now locked, since Gold Support is no longer offered.

Moderator: SourceGear

Locked
christian
Posts: 202
Joined: Tue Sep 14, 2004 1:02 pm
Location: UK

Select statement to return the last tran / vs id for folder

Post by christian » Fri Feb 18, 2005 12:29 pm

Can you help me out here guys? I've written a little script that a developer runs whenever they want to update their machine with the latest in version control. This script then does a heap load of stuff taking the latest in vault and installing it on their machine.

At the moment this work is done regardless of whether what's in vault has changed since the last time the developer run the script so... I want to query a particular vault folder for its most recent tranid / versionid for that folder. I then compare this with the id the last time the script ran, if its different the script assumes something has changed and therefore does its full update on the developer's machine. Now, the next refinement to this query is to be a little more discriminating so that those tran's committed by the developer are excluded.

Can you give the appropriate select statement I need to execute that does the above?

Thanks in advance
Christian

christian
Posts: 202
Joined: Tue Sep 14, 2004 1:02 pm
Location: UK

Post by christian » Mon Feb 21, 2005 11:27 am

Any progress on this? Sorry to push but I'd really like to get this query working tonight if possible. Much longer and the script that does the update on a development machine is going to fall into disuse 'cause it takes way to long to do a full update when an incremental update of those bits that's changed would suffice.

Thanks
Christian

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Mon Feb 21, 2005 1:09 pm

I'd recommend looking at the vault command line client's history command. This is how the integration with Draco.Net works, and it does fine with detecting changes to the tree.

christian
Posts: 202
Joined: Tue Sep 14, 2004 1:02 pm
Location: UK

Post by christian » Mon Feb 21, 2005 1:17 pm

Cool. Just run the command and this looks like its returning just the info I need :-)

Can you tell me what the different values for "type" mean eg

<item txid="4574" date="25/01/2005 17:14:20" name="ecicDataAccess" type="10" version="8" user="SQLServer" />

Thanks
Christian

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Mon Feb 21, 2005 1:23 pm


christian
Posts: 202
Joined: Tue Sep 14, 2004 1:02 pm
Location: UK

Post by christian » Mon Feb 21, 2005 1:29 pm

Excellent. Thanks

christian
Posts: 202
Joined: Tue Sep 14, 2004 1:02 pm
Location: UK

Post by christian » Tue Feb 22, 2005 3:12 am

Hi Jeremy,
Been thinking about this query a bit more. I thought I was going to be excluding transactions that the developer had checked in to figure out whether his machine needs to be updated from vault. Then I thought, what happens if the developer checks in from another machine? The script would ignore this check-in and would assume that his current machine was all up to date (assuming nobody else has checked in).

So I don't think I can use this history command for what I'm trying to do. An alternative (I think) would be to do a diff against the working directory and what's in the repository. Ok, so I started looking at the DIFF command but I can't get things to work.

Here's the command line I tried:
vault.exe DIFF -user myuser -password mypassword -host myhost -repository ECICGenIns -compareto current "$/Mainline/Build/ecicDataAccess"

And I got this error:
<vault>
<error>
The Diff utility encountered an error during execution. Please verify the use o
f VAULTDIFF or the "diff" utility.
</error>
<exception>
System.Exception: The Diff utility encountered an error during execution. Pleas
e verify the use of VAULTDIFF or the "diff" utility.
at VaultCmdLineClient.VaultCmdLineClient.ProcessCommandDiff(String strArgDiff
Bin, String strArgDiffArgs, DiffAgainstType datDiffChoice, Boolean bRecursive, S
tring strLeft, String strLeftLbl, String strRight, String strRightLbl)
at VaultCmdLineClient.VaultCmdLineClient.ProcessCommand(Args curArg)
at VaultCmdLineClient.VaultCmdLineClient.Main(String[] args)
</exception>
<result success="no" />
</vault>

What am I doing wrong?
Thanks
Christian

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Tue Feb 22, 2005 9:45 am

Christian,

I'm confused. If all you want is to update the Vault working folders with the latest code, then you should be able to use the GET command with no destpath and specify the -merge automerge parameter. This will only download the necessary files, and will merge in with any local changes where it needs to. This is exactly equivalent to doing a get with automerge from the GUI client.

The DIFF command only works if you specify the VAULTDIFF environment variable. The variable should point to the location of the diff tool you want to invoke.

christian
Posts: 202
Joined: Tue Sep 14, 2004 1:02 pm
Location: UK

Post by christian » Tue Feb 22, 2005 11:21 am

jeremy_sg wrote: I'm confused. If all you want is to update the Vault working folders with the latest code, then you should be able to use the GET command with no destpath and specify the -merge automerge parameter. This will only download the necessary files, and will merge in with any local changes where it needs to. This is exactly equivalent to doing a get with automerge from the GUI client.
Unfortunately, it not that simple. For example, each sql database is maintained as a series of DDL scripts, one for each database object. When a developer wants to update his development machine its not just a case of doing a Get on those scripts. Get is the first thing that happens but after that another tool is executed that takes those scripts and synchs the developer database. Now I only want to execute this tool if something has changed in vault as it takes about 2-3 minutes to run. So you see why I want to query first?
jeremy_sg wrote: The DIFF command only works if you specify the VAULTDIFF environment variable. The variable should point to the location of the diff tool you want to invoke.
Ok, I already did that but it didn't take affect until a reboot. Now I've got it to run I'm disappointed as it just opens up the gui diff rather than give me an xml doc describing the difference. My script needs a report or status back from the command line that it can inspect programmatically, not a visual diff. Does Vault diff have a command line parameter to suppress the visual diff and hand back this xml or status code?

Thanks
Christian

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Tue Feb 22, 2005 11:38 am

You could use the filetime to determine if the get operation overwrote the file. Also, if you need to, I could show you how to get the Command line client to ouput verbose logging about what files are downloaded during the get operation.

christian
Posts: 202
Joined: Tue Sep 14, 2004 1:02 pm
Location: UK

Post by christian » Tue Feb 22, 2005 11:48 am

jeremy_sg wrote:You could use the filetime to determine if the get operation overwrote the file. Also, if you need to, I could show you how to get the Command line client to ouput verbose logging about what files are downloaded during the get operation.
Cool ideas. I particularly like the sound of the second one. I can then redirect the output to a text file, parse this to tell me whether something has changed? Please send me some instructions :-)

Christian

christian
Posts: 202
Joined: Tue Sep 14, 2004 1:02 pm
Location: UK

Post by christian » Tue Feb 22, 2005 3:15 pm

Jeremy,
Just found an undocumented command line switch for the GET command: -verbose

It looks as though this will tell me the files (if any) that are retrieved from Vault on a get. Looks to me I can parse this rather than having to parse a config file for gets. Is this the better way to go?

Thanks
Christian

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Tue Feb 22, 2005 3:35 pm

Christian,

I was just looking at the command line client to add that, but it looks like someone beat me to it. I think that Darren Sargent deserves the credit for that contribution. I added it as an option to the Get, GetLabel, GetVersion, and GetWildCard help text, so after 3.0.3, it will no longer be undocumented.

christian
Posts: 202
Joined: Tue Sep 14, 2004 1:02 pm
Location: UK

Post by christian » Wed Feb 23, 2005 1:42 am

Cool. Its an excellent feature :-)

Locked