Examples of programs integrating with Vault and Fortress API. Also, information on integrating with NAnt, CruiseControl.Net and other third-party tools
Moderator: SourceGear
-
splatteredbits
- Posts: 18
- Joined: Fri Mar 06, 2009 12:27 pm
Post
by splatteredbits » Tue Aug 11, 2009 1:00 pm
How do I attach to the UserMessage event. This:
Code: Select all
// ... snip ...
ServerOperations.UserMessage += VaultMessagHandler
// ... snip ...
private void HandleUserMessage(object sender, string message)
{
// ... snip ...
}
gives me a compiler error: "Cannot access non-static event 'UserMessage' in static context." I can't find any sample code anywhere.
-
jeremy_sg
- Posts: 1821
- Joined: Thu Dec 18, 2003 11:39 am
- Location: Sourcegear
-
Contact:
Post
by jeremy_sg » Tue Aug 11, 2009 1:04 pm
You need to use:
Code: Select all
ServerOperations.GetInstance().UserMessage
-
splatteredbits
- Posts: 18
- Joined: Fri Mar 06, 2009 12:27 pm
Post
by splatteredbits » Tue Aug 11, 2009 2:35 pm
How do I get the API to behave like the GUI with respect to unchanged files? In the GUI, if a file has been modified, but unchanged, it is updated so that it no longer shows as updated and a new version is not added to the file's history. When I commit via the API, an unchanged file gets checked-in so that a new version is added to its history.
Here is my code:
Code: Select all
ServerOperations.ProcessCommandCommit(changes, UnchangedHandler.UndoCheckout, false, LocalCopyType.Replace, false);
I've also tried LocalCopyType.Leave but the same thing happens.
-
jeremy_sg
- Posts: 1821
- Joined: Thu Dec 18, 2003 11:39 am
- Location: Sourcegear
-
Contact:
Post
by jeremy_sg » Tue Aug 11, 2009 3:42 pm
The UnchangedHandler.UndoCheckout should trigger the behavior that you want. Can you post a log file showing the superfluous checkin?
-
splatteredbits
- Posts: 18
- Joined: Fri Mar 06, 2009 12:27 pm
Post
by splatteredbits » Tue Aug 11, 2009 4:29 pm
The file is Unchanged.txt. In my test, I read the contents of the file and then overwrite the file with those same contents, like this:
Code: Select all
var contents = File.ReadAllText(@"Unchanged.txt");
File.WriteAllText(@"Unchanged.txt", contents);
And when I call
Code: Select all
var changes = ServerOperations.ProcessCommandListChangeSet(new string[] { @"Unchanged.txt" });
ServerOperations.ProcessCommandCommit(changes, UnchangedHandler.UndoCheckout, false, LocalCopyType.Leave, false);
The file is still checked-out and a new version is created in Vault. If I diff the two versions, they are showing as no change.
-
Attachments
-
- Vault20090811152052.txt
- (1.5 MiB) Downloaded 2577 times
-
jeremy_sg
- Posts: 1821
- Joined: Thu Dec 18, 2003 11:39 am
- Location: Sourcegear
-
Contact:
Post
by jeremy_sg » Wed Aug 12, 2009 8:03 am
Because you wrote to the file, the timestamp has changed. Thus Vault thinks the file is Modified. If you want to check using the CRC of the contents instead of the timestamp, set the Use CRC Instead of Timestamp checkbox in the GUI client's Tools->Options->Local Files dialog.
-
splatteredbits
- Posts: 18
- Joined: Fri Mar 06, 2009 12:27 pm
Post
by splatteredbits » Wed Aug 12, 2009 10:53 am
If I update a file's timestamp, usually by modifying the file but not changing it, this is what happens:
* When I choose "Commit selected operations..." in the GUI, the file is "un-checked-out" and the Version number of the file stays the same (it stays at 50).
* When I run the CLI command `vault.exe commit -host vault -repository Repo Modified.txt` the file is checked-in and given a new version number (increases from 50 to 51).
* When I call ServerOperations.ProcessCommandCommit(changes, UnchangedHandler.UndoCheckout, false, LocalCopyType.Leave, false); the behavior is the same as the CLI: the file is checked-in and given a new version number (increases from 51 to 52).
The GUI does *not* use the CRC method, yet it still un-checks-out the file. I want that behavior in the CLI and API. What do I do to get it?
-
pierre-chew
- Posts: 3
- Joined: Tue Mar 23, 2010 3:06 pm
Post
by pierre-chew » Tue Mar 23, 2010 3:10 pm
I am having a similar problem. When I perform a rename of a file in Visual Studio 2008 or I add a file to the solution, it can take up to 20 minutes for the whole process to complete. When I have to perform a number of these types of operations, I now just take the solution offline, perform my adds and renames and then bring the solution back online. It still takes 20 minutes for the whole operation to complete but at least I can do everythign at once.
I have tried what was specified above but that did not seem to fix the problem. I am running version 5.0.2 of vault. Any suggestions?
Thanks,
Pierre
pchew@planelements.com