Question

In a web-app I'm writing, the user is supposed to enter the path in the Perforce repository for the node they're entering. The application is supposed to validate that the entered directory exists in the repo.

I've got the P4Package (p4.jar) lib, and I'm configuring it correctly enough that it works for almost everything, EXCEPT this directory validation. I'm creating a DirEntry (from the p4.jar) using a configured Env and a path, but when I call DirEntry.sync(), it issues an incorrect command. Where I want it to issue the command:

p4 [config info] dirs directory_argument <-- using the dirs command to validate a dir

Instead, it issues:

p4 [config info] dirs directory_argument%1 <-- note extraneous %1

Which always fails, since none of the directories have a %1 at the end of them.

Any help? Is there a different way to check that a directory exists using this package?

Was it helpful?

Solution 3

So, the code I was using did have a bug requiring me to make a change and check the code into my repository.

However, since then, Perforce has come up with their own Java wrapper for the P4 client which works much better. I'd give that one a shot.

OTHER TIPS

Sounds like the sync command has a bug in relation to dir entries and the command. My suggestion would be to just roll the command yourself, using the perforce command line as that has to be set up anyway in order to use the java library.

Process p = Runtime.getRuntime().exec("p4 dirs " + directory_argument);
BufferedReader stdOut = new BufferedReader(new InputReader(p.InputStream()));
//Read the output of the command and process appropriately after this

I would try another library, P4Java, instead:

http://tek42.com/p4java

P4Java is much newer and I've found works much better than the P4Package. It is used in the Hudson project and I've seen it in the Fisheye source, though, I'm not sure if they are using it or not.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top