Labels: Bug report / feature request

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

Moderator: SourceGear

Post Reply
gmagana
Posts: 145
Joined: Wed Feb 18, 2004 10:51 am
Location: Santa Ana, CA, USA

Labels: Bug report / feature request

Post by gmagana » Mon May 24, 2004 3:29 pm

EDIT: Oops! I forgot to mention, this is on Vault version 2.0.3

I was finalizing some version changes and setting labels in Vault as appropriate when I made a mistake: I created a Vault label on files I had not yet checked in and meant to include those changes in the label. No big deal, I realized this in time and corrected my mistake. In the process though, I came up with these comments:

1) Deleting a label is hard (perhaps intentionally so?). You have to "show labels" and then you have to select the target label(s) and then the only way to delete the labels is by going to Label-->Delete on the menu. The right-click menu does not show the option, nor does hitting the "delete" key work. Since there is a confirmation screen anyway, it might be a good idea to let the user delete labels by hitting the delete key or via the right-click menu as well.

2) The deleted labels are still displayed after deleting them. If the user hits F5 to refresh the list of labels, the deleted labels are not displayed anymore. It might be a good idea to refresh the label list automatically after deleting one or more labels so the display is accurate.

3) This is the feature request: It may be a good idea to warn the user if there are any checked out files of a directory / file that is the target of a label operation. I would imagine that more often than not, the user wants to label a Vault directory "as is" and that may include files that have mistakenly not been checked in yet (as happened to me). It would have been helpful if a screen had popped up saying "Warning: One or more files in this label target are currently checked out!"

Let me know what you guys think about these issues.
gabriel magana-gonzalez

jclausius
Posts: 3706
Joined: Tue Dec 16, 2003 1:17 pm
Location: SourceGear
Contact:

Post by jclausius » Mon May 24, 2004 3:54 pm

Gabriel:

Great suggestions. I've logged them as enhancements / fixes.

Thanks for the feedback.
Jeff Clausius
SourceGear

dwayne_davis
Posts: 34
Joined: Mon Jan 26, 2004 5:12 pm

Label Promotion/Rename not working

Post by dwayne_davis » Tue May 25, 2004 12:20 pm

On a similar thread, using Vault 2.0.3.
  • Create a label on a folder (in my case, a root folder with both sub-folders and files contained).

    Select the folder, right-click and 'Show Labels'.

    Select the label, righ-click and select 'Promotion...'
    I'm seeing the Label Promotion window with a modal pop-up stating 'Object reference not set to an instance of an object.'
    The folder view in the label promotion window has a single folder titled 'Error retrieving structure'

    Also rather than Promotion, select 'Rename'. Enter a new name, a modal pop-up states: 'Server was unable to process request. --> Object reference not set to an instance of an object.'
Anybody else see this behavior? It seems to work fine if I label a file, but on the folders I see this. Also, when I apply the label to a folder, the sub-files show the label, but I cannot promote or delete them, either.

-DAD

dwayne_davis
Posts: 34
Joined: Mon Jan 26, 2004 5:12 pm

Label CLC feature request

Post by dwayne_davis » Tue May 25, 2004 12:25 pm

While we're on the subject ;)

How about command line features for renaming and deleting labels? I'd like to set up my build process to work in the following manner:
  • Create a temporary label (no problem, current CLC does this)

    Get by that label (again, no problem)

    If the build succeeds, rename the temporary label to the actual build label (this is new)

    If the build fails, delete the label (this is new)

jclausius
Posts: 3706
Joined: Tue Dec 16, 2003 1:17 pm
Location: SourceGear
Contact:

Post by jclausius » Tue May 25, 2004 12:27 pm

Dwayne:

What version of Vault (client and server) are you using?

Do you happen to have folder security enabled?

Is there anything in the server's sgvault.log file related to some sort of error for the label?
Jeff Clausius
SourceGear

jclausius
Posts: 3706
Joined: Tue Dec 16, 2003 1:17 pm
Location: SourceGear
Contact:

Post by jclausius » Tue May 25, 2004 12:28 pm

I've also logged your suggestions for the Command Line Client.

Thanks for the feedback.
Jeff Clausius
SourceGear

dwayne_davis
Posts: 34
Joined: Mon Jan 26, 2004 5:12 pm

Post by dwayne_davis » Tue May 25, 2004 12:43 pm

jclausius wrote:Dwayne:

What version of Vault (client and server) are you using?

Do you happen to have folder security enabled?

Is there anything in the server's sgvault.log file related to some sort of error for the label?
Sorry, should have been more clear.

Vault Server 2.0.3. Client 2.0.3. Both were originally installed with 2.0.2; the problem existed there as well (noticed it last night). I noticed the newer 2.0.3, so I upgraded before posting the bug - hoping it was fixed.

I've attached the last portion of the log file - I noticed immediately there is a unique key constraint violation:

Code: Select all

----5/25/2004 11:07:52 AM    ddavis--se411755.engineeringsw.com(10.20.82.35)--SSL Disabled
	Violation of UNIQUE KEY constraint 'unique_tblfsobjectlabels_labelrepidobjid'. Cannot insert duplicate key in object 'tblfsobjectlabels'.
----5/25/2004 11:07:52 AM    ddavis--se411755.engineeringsw.com(10.20.82.35)--SSL Disabled
	AddLabel returned: FailDBInsert
----5/25/2004 11:07:52 AM    ddavis--se411755.engineeringsw.com(10.20.82.35)--SSL Disabled
	Logout
----5/25/2004 11:08:02 AM    ddavis--se411755.engineeringsw.com(10.20.82.35)--SSL Disabled
	Login
----5/25/2004 11:08:04 AM    ddavis--se411755.engineeringsw.com(10.20.82.35)--SSL Disabled
	Violation of UNIQUE KEY constraint 'unique_tblfsobjectlabels_labelrepidobjid'. Cannot insert duplicate key in object 'tblfsobjectlabels'.
----5/25/2004 11:08:04 AM    ddavis--se411755.engineeringsw.com(10.20.82.35)--SSL Disabled
	AddLabel returned: FailDBInsert
----5/25/2004 11:08:04 AM    ddavis--se411755.engineeringsw.com(10.20.82.35)--SSL Disabled
	Logout
----5/25/2004 11:13:39 AM    ddavis--se411755.engineeringsw.com(10.20.82.35)--SSL Disabled
	DeleteLabel returned: FailInvalidLabel
----5/25/2004 11:32:26 AM    ddavis--se411755.engineeringsw.com(10.20.82.35)--SSL Disabled
	Logout
I should note that I'm not trying to rename the label to a name already taken; it doesn't seem to matter what I choose for the name.
Attachments
sgvault.zip
Grrr. .log files not allowed... this is the log file.
(768 Bytes) Downloaded 800 times

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

Re: Label Promotion/Rename not working

Post by jeremy_sg » Tue May 25, 2004 1:04 pm

dwayne_davis wrote:On a similar thread, using Vault 2.0.3.

Select the label, righ-click and select 'Promotion...'
I'm seeing the Label Promotion window with a modal pop-up stating 'Object reference not set to an instance of an object.'
The folder view in the label promotion window has a single folder titled 'Error retrieving structure'
Dwayne,

I've figured this out while working with DarrenS on the Gold Support forum. The user who is doing the Show labels probably has no default rights, and 2.0.3 intorduced a bug where the inherited rights weren't being read properly. For now, you can work around this by giving the user default rights or by performing the operation as another user. This may or may not be related to your rename issue. Let me know if this solves that issue as well.

Guest

Re: Label Promotion/Rename not working

Post by Guest » Tue May 25, 2004 2:47 pm

jeremy_sg wrote:
dwayne_davis wrote:On a similar thread, using Vault 2.0.3.

Select the label, righ-click and select 'Promotion...'
I'm seeing the Label Promotion window with a modal pop-up stating 'Object reference not set to an instance of an object.'
The folder view in the label promotion window has a single folder titled 'Error retrieving structure'
Dwayne,

I've figured this out while working with DarrenS on the Gold Support forum. The user who is doing the Show labels probably has no default rights, and 2.0.3 intorduced a bug where the inherited rights weren't being read properly. For now, you can work around this by giving the user default rights or by performing the operation as another user. This may or may not be related to your rename issue. Let me know if this solves that issue as well.
Thanks Jeremy! That fixed it. I think it might still be a bug, because the users all seem to have full rights to that (and all) folders; I do have folder security set. When I go to the Users tab in the admin tool, none of the users show up with 'Default Rights' set. However, when I highlight a user and select security, view shows them with RCA rights on the folder. Changing the user's default rights seems to have fixed the problem; which implies that although they already had rights for the given folder they needed default rights for some reason.

-DAD

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

Post by jeremy_sg » Tue May 25, 2004 2:49 pm

You're right, it is a bug that we will address in a 2.0.4, when that is released.

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

Re: Label CLC feature request

Post by montek » Fri May 28, 2004 6:28 am

dwayne_davis wrote:While we're on the subject ;)

How about command line features for renaming and deleting labels? I'd like to set up my build process to work in the following manner:
  • Create a temporary label (no problem, current CLC does this)

    Get by that label (again, no problem)

    If the build succeeds, rename the temporary label to the actual build label (this is new)

    If the build fails, delete the label (this is new)
I have accomplished much of this by using the Vault API. I have generic methods that apply & remove labels to files (individually, though, which may not be your approach). Let me know if you're interested in the code.

Guest

Re: Label CLC feature request

Post by Guest » Fri May 28, 2004 9:40 am

montek wrote:
dwayne_davis wrote:While we're on the subject ;)

How about command line features for renaming and deleting labels? I'd like to set up my build process to work in the following manner:
  • Create a temporary label (no problem, current CLC does this)

    Get by that label (again, no problem)

    If the build succeeds, rename the temporary label to the actual build label (this is new)

    If the build fails, delete the label (this is new)
I have accomplished much of this by using the Vault API. I have generic methods that apply & remove labels to files (individually, though, which may not be your approach). Let me know if you're interested in the code.
I'm very interested. I'm actually playing with the API now to accomplish this same thing. Can you zip and post the code here? Thanks in advance.

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

Re: Label CLC feature request

Post by montek » Fri May 28, 2004 10:03 am

Anonymous wrote:I'm very interested. I'm actually playing with the API now to accomplish this same thing. Can you zip and post the code here? Thanks in advance.
I'll just paste my "wrapper" class. Note that it's a work-in-progress (as I continue to learn more), but provides some raw-level functionality that I needed to use. You should be able to use the removeLabel and addLabel methods in some way.

Code: Select all

public class Vault {
		public ClientInstance client;

		public Vault() { }
		
		public Vault(string server, string username, string password, string repository) : this() {
			connect(server, username, password, repository);
		}
		
		/// <summary>
		/// Disconnects from Vault and sets client back to null.
		/// </summary>
		public void disconnect() {
			if (isConnected)
				client.Logout();
			client = null;
		}
		
		public bool isConnected {
			get {
				return (client != null && client.ConnectionStateType == ConnectionStateType.Connected);
			}
		}

		/// <summary>
		/// Connects (or reconnects) given the specified connection information.
		/// </summary>
		/// <param name="server"></param>
		/// <param name="username"></param>
		/// <param name="password"></param>
		/// <param name="repository"></param>
		public void connect(string server, string username, string password, string repository) {
			disconnect();
			client = new ClientInstance();
			
			if (server.StartsWith("http://") == false)
				server = "http://" + server;
			if (server.EndsWith("/VaultService") == false)
				server += "/VaultService";
			
			client.Init(VaultClientNetLib.VaultConnection.AccessLevelType.Client);
			client.Login(server, username, password);

			// Find and set repository (required because of Vault deficiency).
			VaultRepositoryInfo[] reps = null;
			//List all the repositories on the server.
			client.ListRepositories(ref reps);

			//Search for the one that we want.
			foreach (VaultRepositoryInfo r in reps) {
				if (String.Compare(r.RepName, repository, true) == 0) {
					//This will load up the client side cache files and refresh the repository structure.
					//See http://support.sourcegear.com/viewtopic.php?t=6 for more on client side cache files.
					client.SetActiveRepositoryID(r.RepID, client.Connection.Username, r.UniqueRepID, true, true);
					break;
				}
			}
			if (client.ActiveRepositoryID == -1)
				throw new Exception(string.Format("Repository {0} not found", repository));
		}

		public long getBaselineVersion(string path) {
			VaultClientFile file = null;
			
			file = client.TreeCache.Repository.Root.FindFileRecursive(path);

			if (file != null) {
				try {
					WorkingFolder working = client.GetWorkingFolder(file);
					return (working.GetDisplayVersion(file));
				} catch {
					return 0;
				}
			} else
				return (-1);
				//throw new Exception(string.Format("{0} does not exist", path));
		}

		public WorkingFolderFileStatus getBaselineStatus(string path) {
			VaultClientFile file = null;
			
			file = client.TreeCache.Repository.Root.FindFileRecursive(path);

			if (file != null) {
				try {
					WorkingFolder working = client.GetWorkingFolder(file);
					return (working.GetStatus(file));
				} catch {
					return WorkingFolderFileStatus.Missing;
				}
			} else
				//return (WorkingFolderFileStatus.Unknown);
				throw new Exception("File not found in Vault: " + path);
		}

		/// <summary>
		/// Retrives a file from the Vault and overwrites the working file (baseline) with the version specified.
		/// </summary>
		/// <param name="path">A fully qualified Vault path (starting with $)</param>
		/// <param name="version"></param>
		public void getVersion(string path, long version) {
			VaultClientFile file = null;

			file = new VaultClientFile(client.TreeCache.Repository.Root.FindFileRecursive(path));
			if (file != null) {
				file.ObjVerID = 0; // You must do this for GetByDisplayVersion to work properly and not corrupt the treeCache.
				file.Version = version;
				
				VaultClientFile[] files = new VaultClientFile[1]; // Because GetByDisplayVersion only takes arrays.
				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));
		}

		/// <summary>
		/// Adds specified label.
		/// </summary>
		/// <param name="path"></param>
		/// <param name="version"></param>
		/// <param name="label"></param>
		/// <param name="comment"></param>
		public void addLabel(string path, long version, string label, string comment) {
			//TODO: Cleanup code
			VaultClientNetLib.ClientService.VaultLabelResult labelResult = null;
			int labelReturn = client.AddLabel(path, getObjVerID(path, version), label, comment, ref labelResult);
			
			switch(labelReturn) {
				case VaultStatusCode.Success:
					break;

				case VaultStatusCode.FailDuplicateLabel:
					if(String.Compare(labelResult.ExistingRootPath, path, true) == 0) {
						//throw new Exception(string.Format("{0} already has label {1} applied.", path, label));
						removeLabel(path, label);
						addLabel(path, version, label, comment);
						break;
					} else
						throw new Exception(string.Format("{0} has inherited the label {1} already.", path, label));
				default:
					throw new Exception("Label error: " + VaultConnection.GetSoapExceptionMessage(labelReturn));
			}
		}

		/// <summary>
		/// Remove specified label.  If label not found, returns false.
		/// </summary>
		/// <param name="path"></param>
		/// <param name="label"></param>
		/// <returns></returns>
		public bool removeLabel(string path, string label) {
			const int ROW_LIMIT = 1000; // Maximum number of label rows to retrieve.
			int numRowsInherited; 
			int numRowsRecursive; 
			string token;
			
			client.BeginLabelQuery(path, getTreeObjectID(path), false, false, true, false, ROW_LIMIT, out numRowsInherited, out numRowsRecursive, out token); 

			if (token == null || token == String.Empty) 
				throw new Exception("Token is null or empty.");

			VaultLabelItemX[] items; 
			
			client.GetLabelQueryItems_Main(token, 0, numRowsInherited, out items);
			
			if (items == null)
				return false;

			// Find the labelID for the specified label applied to the specified file.
			long labelID = -1;
			foreach (VaultLabelItemX item in items) { 
				if (item.Label == label)
					labelID = item.LabelID; 
			} 
			client.EndLabelQuery(token); 

			if (labelID == -1)
				System.Windows.Forms.MessageBox.Show("Could not find label "" + label + "" on file "" + path + "", so I couldn't delete it; sorry.");
			else
				client.DeleteLabel(path, labelID);
				
			return true;
		}

		/// <summary>
		/// Returns a Vault Tree Object ID (sometimes referred to as objectID, treeObjID, nObjID) for a specified file/folder.
		/// </summary>
		/// <param name="path">Full Vault path to file or folder.</param>
		/// <returns></returns>
		private long getTreeObjectID(string path) {
			VaultClientTreeObject treeObject;
			
			if((treeObject = client.TreeCache.Repository.Root.FindTreeObjectRecursive(path)) == null)
				throw new Exception("Object does not exist in Vault: " + path);

			return (treeObject.ID);
		}

		/// <summary>
		/// Gets the objVerID for specified path and display version.
		/// </summary>
		/// <param name="path"></param>
		/// <param name="version"></param>
		/// <returns></returns>
		private long getObjVerID(string path, long version) {
			VaultObjectVersionInfo[] ovis = null;
			client.Connection.GetObjectVersionList(getTreeObjectID(path), ref ovis, false);

			if ((ovis != null) && (ovis.Length > 0)) {
				// Find the version number specified for this tree object
				foreach(VaultObjectVersionInfo ovi in ovis) {
					if(version == ovi.Version)
						return (ovi.ObjVerID);
				}
			}

			throw new Exception(string.Format(""{0}" does not exist at version {1}", path, version));
		}

		

		public string getWorkingFolder(string path) {
			return (client.TreeCache.GetWorkingFolder(path));
		}
	}

Post Reply