Command Line - GETVERSION to working folder?

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

Moderator: SourceGear

montek
Posts: 107
Joined: Mon Jan 05, 2004 8:46 am

Post by montek » Tue Apr 13, 2004 4:43 am

montek wrote:What's not clear to me is how to effectively use DeleteLabel, which is expecting a labelID. I'm not entirely sure how to retrieve that.

I know exactly which file (full path) and which version (though display version again, but I can translate) and which label (text) that I want to remove (assuming it exists; I'll code around any failures). Any suggestions?
Any thoughts on this? I'm stuck here.

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

Post by sterwill » Tue Apr 13, 2004 1:58 pm

The only way I know of to get the label ID is to perform a label query on an object. The methods involved to get a list of labels applied to a given object are BeginLabelQuery, GetLabelQueryItems_Main, and EndLabelQuery.

You would call them like this pseudo-code. I've put some constants in where you would have retrieved some values for BeginLabelQuery. You'll want to change those bools if you want to query a folder.

Code: Select all

int numRowsInherited;
int numRowsRecursive;
string token = String.Empty;
VaultClientNetLib.ClientService.VaultLabelItemX[] items = null;
int foundID = -1;

ci.BeginLabelQuery("$/file.c", 1038, false, false, true, false, 1000, out numRowsInherited, out numRowsRecursive, out token);

if (token == null || token == String.Empty)
   return some error status;

ci.GetLabelQueryItems_Main(token, 0, numRowsInherited, out items);

if (items == null)
   return some error status;

foreach (VaultLabelItemX item in items)
{
    if (label.Label == "My Label String 1.0")
    {
        foundID = item.LabelID;
    }
}

ci.EndLabelQuery(token);
Shaw Terwilliger
SourceGear LLC
`echo sterwill5sourcegear6com | tr 56 @.`

montek
Posts: 107
Joined: Mon Jan 05, 2004 8:46 am

Post by montek » Wed Apr 14, 2004 5:25 am

Thanks! That works great. Now I have a new problem (and one I thought I'd already solved, but it doesn't seem to be working anymore).

I'm trying to write my own method to get a specific (display) version of a file. I have this code:

Code: Select all

public void getVersion(string path, long version) {
	VaultClientFile file = null;

	file = client.TreeCache.Repository.Root.FindFileRecursive(path);
	if (file != null) {
		file.Version = version;
		
		VaultClientFile[] files = new VaultClientFile[1]; // Because GetByDisplayVersion only takes an array.
		files[0] = file;
		
		client.GetByDisplayVersion(files, MakeWritableType.MakeAllFilesReadOnly, SetFileTimeType.CheckIn, MergeType.OverwriteWorkingCopy, null);
	} else 
		throw new Exception(string.Format("getVersion(): {0} does not exist", path));
}
The problem seems to be that regardless of my having set the .Version of the file, it doesn't actually GET that version. It seems to always get the latest version.

I tried a different route, wondering if that method was incorrect (though it's much more likely that I'm not doing something right) by using a regular Get after having set the file.ObjVerID correctly (I think I've got that right). I *think* it worked, but after asking my method to get v8 of a particular file, my normal Vault client still showed me as having v9 (the latest in the repository is v9), but it did mark the file as Old.

Thank you guys SO much for all your help.

montek
Posts: 107
Joined: Mon Jan 05, 2004 8:46 am

Post by montek » Wed Apr 14, 2004 5:34 am

Argh! I don't know what I was or wasn't doing that caused it to stop working, but now the above code seems to be working flawlessly.

montek
Posts: 107
Joined: Mon Jan 05, 2004 8:46 am

Post by montek » Thu May 13, 2004 6:31 am

OK, so it turns out that I'm having this problem again. Any thoughts on this? The code below works fine if the version I want is LATER than the current baseline; however, if it's earlier, it just seems to slip on through, without any errors, but doesn't actually *do* anything. Any ideas?
montek wrote:Thanks! That works great. Now I have a new problem (and one I thought I'd already solved, but it doesn't seem to be working anymore).

I'm trying to write my own method to get a specific (display) version of a file. I have this code:

Code: Select all

public void getVersion(string path, long version) {
	VaultClientFile file = null;

	file = client.TreeCache.Repository.Root.FindFileRecursive(path);
	if (file != null) {
		file.Version = version;
		
		VaultClientFile[] files = new VaultClientFile[1]; // Because GetByDisplayVersion only takes an array.
		files[0] = file;
		
		client.GetByDisplayVersion(files, MakeWritableType.MakeAllFilesReadOnly, SetFileTimeType.CheckIn, MergeType.OverwriteWorkingCopy, null);
	} else 
		throw new Exception(string.Format("getVersion(): {0} does not exist", path));
}
The problem seems to be that regardless of my having set the .Version of the file, it doesn't actually GET that version. It seems to always get the latest version.

I tried a different route, wondering if that method was incorrect (though it's much more likely that I'm not doing something right) by using a regular Get after having set the file.ObjVerID correctly (I think I've got that right). I *think* it worked, but after asking my method to get v8 of a particular file, my normal Vault client still showed me as having v9 (the latest in the repository is v9), but it did mark the file as Old.

Thank you guys SO much for all your help.

Post Reply