API Checked in Files - Label only if modified

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

Moderator: SourceGear

Post Reply
Jonese
Posts: 3
Joined: Tue Dec 13, 2005 6:18 am
Location: Bristol, UK

API Checked in Files - Label only if modified

Post by Jonese » Tue Dec 13, 2005 8:57 am

Hi, I'm using C#.Net 2003, Vault version 3.0.4 and API version 3.0.7

I've written some code to Check Files Out & In based on a folder in a repository. The problem I have is when I check the code back in and add a comment all the files whether or not they have been modified are being labeled and listed in the Folder history. This does not happen if I use the Windows Vault application as that only labels changed files. Is it possible to work out if a file has been changed in the API?

Code I'm using.

ChangeSetItemColl oSetItemColl = null;
foreach (ChangeSetItem oChangeSetItem in ClientInstance.InternalChangeSet_GetItem(false))
{
oChangeSetItem.Comment = "Checked in ";
oSetItemColl.Add(oChangeSetItem);
}
ClientInstance.Commit(oSetItemColl, false, false);

Everything else works fine :D

Thanks

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

Post by jeremy_sg » Tue Dec 13, 2005 2:09 pm

I'll address one thing first. I recommend changing the code to:

Code: Select all

ClientInstance.InternalChangeSet_SetComment("Checked in");
ClientInstance.Commit();
Does that convince the API to not check in unchanged files?

Jonese
Posts: 3
Joined: Tue Dec 13, 2005 6:18 am
Location: Bristol, UK

Post by Jonese » Wed Dec 14, 2005 4:43 am

Thanks for the reply by sadly it didn't work.

All I'm doing is:-

//Test Folder Contains 3 files (2 gif, 1 text)
ClientInst.CheckOut(ClientFolder, true, VaultLib.VaultCheckOutType.Exclusive, null);

ClientInst.Get(ClientFolder, true, true, MakeWritableType.MakeAllFilesWritable, SetFileTimeType.Current, MergeType.OverwriteWorkingCopy, null);

ClientInst.Refresh();


//Amend text file

ClientInst.InternalChangeSet_SetComment("Checked in 14Dec");
ClientInst.Commit();

Even though I have only amended one file it still checks in all the files and increments their version number.

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

Post by jeremy_sg » Wed Dec 14, 2005 8:18 am

Going back to your original code:

Code: Select all

foreach (ChangeSetItem oChangeSetItem in ClientInstance.InternalChangeSet_GetItem(false))
{
if (! (item is ChangeSetItem_Unmodified))
{
oChangeSetItem.Comment = "Checked in ";
oSetItemColl.Add(oChangeSetItem);
}
ClientInstance.Commit(oSetItemColl, false, false);

Jonese
Posts: 3
Joined: Tue Dec 13, 2005 6:18 am
Location: Bristol, UK

Post by Jonese » Wed Dec 14, 2005 9:00 am

Works a treat, thank you very much.

Just a quick note I think the code should have been

if (! (oChangeSetItem is ChangeSetItem_Unmodified))

rather than

if (! (item is ChangeSetItem_Unmodified))

:wink:

Post Reply