Simple CLC question

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

Moderator: SourceGear

Post Reply
stallent
Posts: 8
Joined: Mon Jun 21, 2004 11:23 am

Simple CLC question

Post by stallent » Thu Nov 17, 2005 10:55 am

Being primarily a GUI client user, I haven't had much need for the CLC other than a few basic commands used during our build. Now that I am getting our OS X based designers on board, I am using it much more since it is the only OS X option. I hope this is a simple question.

I am trying to use the LISTFOLDER command and it docs say it should list the contents of a folder. The default is recursive and it lists everything beneath it. Fine. But if I use the -norecursive option, instead of listing just the contents of the folder without recursion, it just returns the folder itself. Is there a way to just list the children of a folder without recursion?

I hope I am missing something easy! Thanks.

-stephen

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

Post by jclausius » Thu Nov 17, 2005 11:07 am

The LISTFOLDER command operates like you've described. Let me take a look at something.
Jeff Clausius
SourceGear

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

Post by jclausius » Thu Nov 17, 2005 11:20 am

If -norecursive is used, just the folder and any files in the folder are returned. No sub folders are listed in this query.

Does the directory you are listing have any files? Or does it just contain sub folder?
Jeff Clausius
SourceGear

Guest

Post by Guest » Thu Nov 17, 2005 1:32 pm

Ah. That would be the case. So now I modify my question! Is there any way to list the folders in addition to the files without the recursion? Without that, it makes it somewhat impossible to navigate a repository without grabbing the whole thing.

Thanks.

-stephen

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

Post by jclausius » Thu Nov 17, 2005 1:41 pm

I've logged a enhancement request for this change.

If you need results now, the only option is grabbing the latest Command Line Client source code - ClientAPI.zip, modify the method WriteFolder() so it lists both files / folders, and recompile a *new* command line client.

As a sample, you could write something like:

Code: Select all

void WriteFolder(VaultClientFolder vcfolder, bool recursive, int depth)
{
	WorkingFolder wf = _ci.GetWorkingFolder(vcfolder);

	_xml.Begin("folder");
	_xml.AddPair("name", vcfolder.FullPath);
	if (wf != null)
	{
		_xml.AddPair("workingfolder", wf.GetLocalFolderPath());
	}
	foreach (VaultClientFile file in vcfolder.Files)
	{
		_xml.Begin("file");
		_xml.AddPair("name", file.Name);
		_xml.AddPair("version", file.Version);
		_xml.AddPair("length", file.FileLength);
		_xml.AddPair("objectid", file.ID);
		_xml.AddPair("objectversionid", file.ObjVerID);

		string strCheckOuts = _ci.GetCheckOuts(file);
		if (
			(strCheckOuts != null)
			&& (strCheckOuts.Length > 0)
			)
		{
			_xml.AddPair("checkouts", strCheckOuts);
		}

		if (wf != null)
		{
			WorkingFolderFileStatus st = wf.GetStatus(file);
			if (st != WorkingFolderFileStatus.None)
			{
				_xml.AddPair("status", GetStatusString(st));
			}
		}

		_xml.End();
	}

	foreach (VaultClientFolder subfolder in vcfolder.Folders)
	{
		_xml.Begin("folder");
		_xml.AddPair("name", subfolder.Name);
		_xml.AddPair("version", subfolder.Version);
		_xml.AddPair("length", subfolder.FileLength);
		_xml.AddPair("objectid", subfolder.ID);
		_xml.AddPair("objectversionid", subfolder.ObjVerID);
		if (recursive == true)
		{
			WriteFolder(subfolder, recursive, depth+1);
		}
	}
	_xml.End();
}
HTH
Jeff Clausius
SourceGear

stallent
Posts: 8
Joined: Mon Jun 21, 2004 11:23 am

Post by stallent » Thu Nov 17, 2005 1:58 pm

Cool. That will be just fine. For now I am struggling to get the CLC to work under mono on OS X, but as soon as I get that rolling, I will make the source mod.

Thanks for your help.

-stephen

Guest

Post by Guest » Thu Nov 17, 2005 4:24 pm

Brilliant! Took your example and modified it a bit, compiled and moved over to OS X and it just flat out worked.

Mono is too cool. It is totally strange compiling code in VS that runs on my designer team's Macs.

Thank you guys very much.

-stephen

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

Post by jeremy_sg » Fri May 30, 2008 3:37 pm

ListFolder in the 4.1.2 command line client will list all folder contents if -norecursive has been specified.
Subscribe to the Fortress/Vault blog

Post Reply