package test;
import com.perforce.p4java.core.file.FileSpecBuilder;
import com.perforce.p4java.core.file.IFileSpec;
import com.perforce.p4java.option.client.ReconcileFilesOptions;
import com.perforce.p4java.server.IOptionsServer;
import java.util.List;
/**
* *
* Do Jenkins stuff. Goal is to isolate from p4 plugin code.
*
* @author jbrown
*/
public class Reconcile {
/**
* @param args the command line arguments
* p4javassl://host:port
* client
* user
*
*/
public static void main(String[] args) {
boolean goodSyntax = true;
if (args.length < 5) {
goodSyntax = false;
}
if (!goodSyntax) {
printSyntax();
System.exit(1);
}
Reconcile obj = new Reconcile();
try {
obj.doReconcile(args);
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
}
public static void printSyntax() {
System.out.println("test.Reconcile <p4java uri> <user> <password> <client> <filespec>");
System.out.println("The user must already be logged in if password is zero-length string.");
}
String uri;
String clientName;
String userName;
String passWord;
String fileSpec;
IOptionsServer server;
/* perform the sync
*
*/
private void doReconcile(String[] args) throws Exception {
this.uri = args[0];
this.userName = args[1];
this.passWord = args[2];
this.clientName = args[3];
this.fileSpec = args[4];
server = ConnectFactory.getServer(uri, userName, passWord, clientName);
List<IFileSpec> fileSpecs = FileSpecBuilder.makeFileSpecList(fileSpec);
ReconcileFilesOptions statusOpts = new ReconcileFilesOptions();
statusOpts.setUseWildcards(true);
statusOpts.setOutsideAdd(true);
statusOpts.setOutsideEdit(true);
statusOpts.setRemoved(true);
statusOpts.setNoUpdate(true);
System.out.println("Client: " + server.getCurrentClient().getName());
System.out.println(" Root: " + server.getCurrentClient().getRoot());
List<IFileSpec> specs = server.getCurrentClient().reconcileFiles(fileSpecs, statusOpts);
ConnectFactory.dumpSpecs("Reconcile results", specs);
}
}