How to set options via the API
Moderator: SourceGear
How to set options via the API
Hi,
How can I set options via the API. In particular, I'd like to make it so that checked in files aren't read-only in my local folder.
Thanks,
Tilman
How can I set options via the API. In particular, I'd like to make it so that checked in files aren't read-only in my local folder.
Thanks,
Tilman
I tried that, but I still got files which suddenly turned read-only.
Possibly related to that, it sometimes happens that files get checked out, but they are not checked back in. As far as I can tell this happens totally randomly. Maybe you could help with that, too? Here is the code
Possibly related to that, it sometimes happens that files get checked out, but they are not checked back in. As far as I can tell this happens totally randomly. Maybe you could help with that, too? Here is the code
Code: Select all
ChangeSetItemColl updateFileChangeSets = new ChangeSetItemColl();
VaultClientFolder root = m_VaultClient.Repository.Root;
VaultClientFolder configurationFolder = root.FindFolderRecursive(m_ConfigurationFolderName);
foreach (ITaskItem file in Files)
{
string vaultFileName = String.Format("{0}/{1}{2}", m_ConfigurationFolderName, file.GetMetadata("Filename"),
file.GetMetadata("Extension"));
if (configurationFolder.HasFile(file.GetMetadata("Filename") + file.GetMetadata("Extension")))
{
string localFolderName = String.Format("{0}{1}", file.GetMetadata("RootDir"),
file.GetMetadata("Directory"));
m_VaultClient.TreeCache.SetWorkingFolder(m_ConfigurationFolderName, localFolderName);
VaultClientFile vaultClientFile = root.FindFileRecursive(vaultFileName);
m_VaultClient.CheckOut(vaultClientFile, VaultCheckOutType.CheckOut, "Updated by build automation");
m_VaultClient.Refresh();
foreach (ChangeSetItem csi in m_VaultClient.InternalChangeSet_GetItems(false))
{
if (csi.DisplayName == file.GetMetadata("FullPath"))
{
updateFileChangeSets.Add(csi);
Log.LogMessage("Updating Vault file {0} with file {1}", csi.DisplayRepositoryPath, csi.DisplayName);
break;
}
}
}
else
{
updateFileChangeSets.Add(new ChangeSetItem_AddFile(VaultDateTime.Now, "Added by build automation", "",
file.GetMetadata("FullPath"), vaultFileName));
Log.LogMessage("Adding file {0} to Vault as {1}", file.GetMetadata("FullPath"), vaultFileName);
}
}
bool success = m_VaultClient.Commit(updateFileChangeSets);
I think that you need to do an explicit
to make sure that the internal change set is ready for you when you want to loop over it to get your changed file.
Code: Select all
m_VaultClient.CheckOut(vaultClientFile, VaultCheckOutType.CheckOut, "Updated by build automation");
m_VaultClient.Refresh();
m_VaultClient.UpdateKnownChanges_RefreshKnown(true)
That's it. A Needs Merge file can never be checked in. If the file is NM, your options are limited to
1. Get with MergeType.OverwriteWorkingCopy - delete what's on disk and try again.
2. Get with MergeType.AttemptAutomaticMerge - try to automerge the disk and the repository. If this fails (conflicting changes have been made on disk and in the repository), the file will remain Needs Merge.
Look at http://support.sourcegear.com/viewtopic.php?t=131 for more on Needs Merge
1. Get with MergeType.OverwriteWorkingCopy - delete what's on disk and try again.
2. Get with MergeType.AttemptAutomaticMerge - try to automerge the disk and the repository. If this fails (conflicting changes have been made on disk and in the repository), the file will remain Needs Merge.
Look at http://support.sourcegear.com/viewtopic.php?t=131 for more on Needs Merge
Now the thing is, that the files I want to check in are mostly dlls, also I somehow don't quite trust automatic merging. Is there no way of just setting the merge status to resolved. After all, when I resolve the merge status manually, all that happens is, the status changes from 'Needs merge' to 'Edited' (which is why I'm a bit puzzled about the 'Needs merge' status, anyway).
Two other ideas I'm toying with are. a) check out the file, the make changes to it (i.e. copy new file on top), then check back in. b) delete file every time and add again. Would either of those have better chances of success?
Two other ideas I'm toying with are. a) check out the file, the make changes to it (i.e. copy new file on top), then check back in. b) delete file every time and add again. Would either of those have better chances of success?
Thanks for that, but that still didn't do it.
Debugging showed that in my app the status is always 'Edited', never 'Needs merge'. Only in the GUI does it say 'Needs merge' sometimes.
The other thing is that it doesn't always say 'Needs merge' in the GUI. Often the check in fails and the status is 'Edited'
I just tried to manually commit a failed check in and got this error message:
Upload for item $/Red Gate/Referenced Dlls/TestProject/1.0.0/Release/TestProject.exe failed too many times, aborting transaction.
Please verify your network settings using the Options dialog under the Tools menu in the Vault GUI Client.
The specific error was "The server returned an unknown error header: VaultFileUpload.aspx encountered: FailFileInvalidCheckSum"
An exception was encountered during the transaction. Exception: The server returned an unknown error header: VaultFileUpload.aspx encountered: FailFileInvalidCheckSum at VaultClientOperationsLib.ClientInstance.UploadItem(ChangeSetItem item, String txID, Byte[]& streamBuffer, Int32& bytesWrittenThisFile, Boolean bIsImport)
at VaultClientOperationsLib.UploadThread.ProcessCommand(UploadThreadCommand command, UploadThreadCommandResult& outputResult)
However, I did that before and it worked.
Debugging showed that in my app the status is always 'Edited', never 'Needs merge'. Only in the GUI does it say 'Needs merge' sometimes.
The other thing is that it doesn't always say 'Needs merge' in the GUI. Often the check in fails and the status is 'Edited'
I just tried to manually commit a failed check in and got this error message:
Upload for item $/Red Gate/Referenced Dlls/TestProject/1.0.0/Release/TestProject.exe failed too many times, aborting transaction.
Please verify your network settings using the Options dialog under the Tools menu in the Vault GUI Client.
The specific error was "The server returned an unknown error header: VaultFileUpload.aspx encountered: FailFileInvalidCheckSum"
An exception was encountered during the transaction. Exception: The server returned an unknown error header: VaultFileUpload.aspx encountered: FailFileInvalidCheckSum at VaultClientOperationsLib.ClientInstance.UploadItem(ChangeSetItem item, String txID, Byte[]& streamBuffer, Int32& bytesWrittenThisFile, Boolean bIsImport)
at VaultClientOperationsLib.UploadThread.ProcessCommand(UploadThreadCommand command, UploadThreadCommandResult& outputResult)
However, I did that before and it worked.