Command Line for branching from a label

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

Moderator: SourceGear

Post Reply
BenV
Posts: 10
Joined: Sat Mar 29, 2008 10:43 am

Command Line for branching from a label

Post by BenV » Mon Jul 28, 2008 12:37 pm

Is there a command line to branch from a label? I am using Vault 3.5.1.

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: Command Line for branching from a label

Post by Beth » Mon Jul 28, 2008 1:58 pm

There isn't currently, but I can take a feature request for that if you would like.
Beth Kieler
SourceGear Technical Support

BenV
Posts: 10
Joined: Sat Mar 29, 2008 10:43 am

Re: Command Line for branching from a label

Post by BenV » Mon Jul 28, 2008 2:19 pm

Hi Beth,

That would be great if you can pass this on as a feature request.

Thank you,

Ben V.

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: Command Line for branching from a label

Post by lbauer » Wed Aug 06, 2008 3:15 pm

We'll get this logged as a feature request.
Linda Bauer
SourceGear
Technical Support Manager

LennyT
Posts: 8
Joined: Sun Nov 09, 2008 6:05 pm

Re: Command Line for branching from a label

Post by LennyT » Thu Apr 23, 2009 7:40 pm

Has this feature been added yet, and if not has it been scheduled for release, and is there a work around?.

Thanks
Marc Thompson

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: Command Line for branching from a label

Post by Beth » Fri Apr 24, 2009 3:25 pm

It's still in our list of requests. I can add another vote to it for you.

I think there might be a way to use the client API to do it if you want something scripted out.

F: 9212
Beth Kieler
SourceGear Technical Support

LennyT
Posts: 8
Joined: Sun Nov 09, 2008 6:05 pm

Re: Command Line for branching from a label

Post by LennyT » Sun Apr 26, 2009 4:51 pm

Im trying to do this from code anyway, so if you could provide me with an example I would appreciate it.

Thanks
Marc Thompson

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: Command Line for branching from a label

Post by Beth » Mon Apr 27, 2009 8:09 am

All API examples are listed in this section of the forum: Development Tips (API).
Beth Kieler
SourceGear Technical Support

LennyT
Posts: 8
Joined: Sun Nov 09, 2008 6:05 pm

Re: Command Line for branching from a label

Post by LennyT » Mon Apr 27, 2009 5:38 pm

I havent been able to find any client API function that would enable branching from a label or version, but maybe Im looking in the wrong place. In the VaultClientInterationLib there the only branching method I can find is:

VaultClientOperationsLib.ChangeSetItemColl ProcessCommandBranch

But this has the same parameters as the command line version.

Should I be looking somewhere else?.

Cheers
Marc Thompson

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

Re: Command Line for branching from a label

Post by jeremy_sg » Tue Apr 28, 2009 7:58 am

I added this command to ServerOperations. You will need to download the VaultClientAPI.zip and edit ServerOperations to add this new command.

Code: Select all

/// <summary>
        /// Branch an item from one location to another (based on a label).
        /// </summary>
        /// <param name="objectPath_From">The path to the object that will be branched.  This can be either a local path or a server path.</param>
        /// <param name="objectPath_To">The path to the new location for the branch.  This path should not exist in the repository.  The last segment of this path will be the new name of the branched folder.</param>
        [LocalOrRemotePath("objectPath_From"), LocalOrRemotePath("objectPath_To")]
        public static ChangeSetItemColl ProcessCommandBranchFromLabel(string objectPath_From, string objectPath_To, string label)
        {
            ChangeSetItemColl csic = new ChangeSetItemColl();

            VaultClientTreeObject treeobj = null;
            treeobj = RepositoryUtil.FindVaultTreeObjectAtReposOrLocalPath(objectPath_From);
            string tmpstr = RepositoryUtil.CleanUpPathAndReturnRepositoryPath(objectPath_To);
            if (tmpstr == null)
                throw new Exception("Could not determine path: " + objectPath_To);
            objectPath_To = tmpstr;
            if (treeobj is VaultClientFolder)
            {
                bool bSuccess = false;
                long labelID = 0;
                string[] discoveredPaths = null;
                long rootID = 0;
                VaultClientTreeObject labelStructure = null;
                try
                {
                    bSuccess = ServerOperations.client.ClientInstance.GetByLabel_GetStructure(treeobj.FullPath, label, ref labelID, "", out discoveredPaths, out labelStructure, out rootID);
                }
                catch (Exception e)
                {
                    if (labelStructure == null)
                    {
                        throw new Exception(string.Format("Could not find label \"{0}\" created at item \"{1}\".  {2}", label, treeobj.FullPath, e.Message));
                    }
                    else
                    {
                        throw;
                    }
                }
                if (bSuccess == false)
                    throw new Exception(string.Format("Could not find label \"{0}\" created at item \"{1}\".", label, treeobj.FullPath));

                // ok, this is a folder
                ChangeSetItem_CopyBranch csi = new ChangeSetItem_CopyBranch(
                    VaultDateTime.Now,
                    client.Comment,
                    String.Empty,
                    treeobj.FullPath,
                    objectPath_To,
                    labelStructure.ObjVerID);
                csic.Add(csi);
            }
            else
            {
                throw new UsageException(string.Format("{0} exists, but this command may not be used to branch individual files.", treeobj.FullPath));
            }

            return commitTransaction(csic);
        }
I tested it with this program:

Code: Select all

ServerOperations.SetLoginOptions("http://localhost", "username", "password", "repository", false);
            ServerOperations.Login();
            ServerOperations.client.AutoCommit = true;
            string newfolder = String.Format("$/branch{0}.{1}.{2}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            ServerOperations.ProcessCommandBranchFromLabel("$/branch", newfolder, "testlabel");
I'll check in the new command to Vault 5.0.
Subscribe to the Fortress/Vault blog

LennyT
Posts: 8
Joined: Sun Nov 09, 2008 6:05 pm

Re: Command Line for branching from a label

Post by LennyT » Tue Apr 28, 2009 5:43 pm

Thanks for that Jeremy, but unfortunately I cant build the code due to a dependency on MantisLib.dll that is not included in the download. Is the dependency available anywhere. I found one post suggesting it was in the fortress download, but I guess it has been removed.

Cheers
Marc Thompson

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

Re: Command Line for branching from a label

Post by jeremy_sg » Tue Apr 28, 2009 7:09 pm

It is included, the namespace is MantisLib, but the dll is DragnetLib.dll
Subscribe to the Fortress/Vault blog

Post Reply