Command Line for branching from a label
Moderator: SourceGear
Command Line for branching from a label
Is there a command line to branch from a label? I am using Vault 3.5.1.
Re: Command Line for branching from a label
There isn't currently, but I can take a feature request for that if you would like.
Beth Kieler
SourceGear Technical Support
SourceGear Technical Support
Re: Command Line for branching from a label
Hi Beth,
That would be great if you can pass this on as a feature request.
Thank you,
Ben V.
That would be great if you can pass this on as a feature request.
Thank you,
Ben V.
Re: Command Line for branching from a label
We'll get this logged as a feature request.
Linda Bauer
SourceGear
Technical Support Manager
SourceGear
Technical Support Manager
Re: Command Line for branching from a label
Has this feature been added yet, and if not has it been scheduled for release, and is there a work around?.
Thanks
Marc Thompson
Thanks
Marc Thompson
Re: Command Line for branching from a label
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
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
SourceGear Technical Support
Re: Command Line for branching from a label
Im trying to do this from code anyway, so if you could provide me with an example I would appreciate it.
Thanks
Marc Thompson
Thanks
Marc Thompson
Re: Command Line for branching from a label
All API examples are listed in this section of the forum: Development Tips (API).
Beth Kieler
SourceGear Technical Support
SourceGear Technical Support
Re: Command Line for branching from a label
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
VaultClientOperationsLib.ChangeSetItemColl ProcessCommandBranch
But this has the same parameters as the command line version.
Should I be looking somewhere else?.
Cheers
Marc Thompson
Re: Command Line for branching from a label
I added this command to ServerOperations. You will need to download the VaultClientAPI.zip and edit ServerOperations to add this new command.
I tested it with this program:
I'll check in the new command to Vault 5.0.
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);
}
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");
Subscribe to the Fortress/Vault blog
Re: Command Line for branching from a label
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
Cheers
Marc Thompson
Re: Command Line for branching from a label
It is included, the namespace is MantisLib, but the dll is DragnetLib.dll
Subscribe to the Fortress/Vault blog