ajc
ajc

Reputation: 1735

How to get the list of folders from a branch in perforce?

I'm using perforce api to read the list of folders in a branch in java.

I reached to a point which tells me to get Branch spec.

http://www.perforce.com/perforce/doc.current/manuals/p4java-javadoc/com/perforce/p4java/server/IServer.html#getBranchSpec(java.lang.String)


Used the following code to implement getDirectories() method.

String serverUri = "p4java://<server-address>:1666?userName=username&password=password";
IServer server = ServerFactory.getServer(serverUri, null);
server.connect();

List<IFileSpec> inputList = FileSpecBuilder.makeFileSpecList("//domain/code/branches/");
System.out.println("HelloPerforce.main() >> passed list >> " + inputList );

List<IFileSpec> outputList =  server.getDirectories(inputList , false, false, false);
System.out.println("HelloPerforce.main()  >> directory list >> " + outputList );

Output: The outputList is null.

Expected output: List of folder names inside //domain/code/branches directory.

Can someone please point me what am I missing here?

Upvotes: 4

Views: 559

Answers (1)

Samwise
Samwise

Reputation: 71562

What you want is getDirectories(). A branch spec is a mapping between two branches (which are usually but not necessarily top-level depot paths). Usually if you're talking about a single "branch" what you're talking about is a depot path, e.g. "//depot/main", rather than a branch spec. To get the list of folders under the "main" branch you'd ask for the list of directories matching "//depot/main/*".

Upvotes: 3

Related Questions