/* * */ package test; import com.perforce.p4java.core.file.FileSpecBuilder; import com.perforce.p4java.core.file.IFileSpec; import com.perforce.p4java.option.client.SyncOptions; import com.perforce.p4java.server.IOptionsServer; import java.util.Arrays; import java.util.List; /** * * @author jbrown */ public class Sync { /** * @param args the command line arguments * p4javassl://host:port * client * user * password * path * */ public static void main(String[] args) { boolean goodSyntax = true; if (args.length < 5) { goodSyntax = false; } if (!goodSyntax) { printSyntax(); System.exit(1); } Sync obj = new Sync(); try { obj.doSync(args); } catch (Exception ex) { ex.printStackTrace(System.out); } } public static void printSyntax() { System.out.println("test.Sync <p4java uri> <user> <password> <client> <filespec ...>"); System.out.println("The user must already be logged in if password is zero-length string."); System.out.println(" optional: -Dhave=false before test.StreamingSync"); System.out.println(" optional: -Dcharset=<charset> before test.StreamingSync"); } String uri; String clientName; String userName; String passWord; String[] fileSpec; IOptionsServer server; /* perform the sync * */ private void doSync(String[] args) throws Exception { this.uri = args[0]; this.userName = args[1]; this.passWord = args[2]; this.clientName = args[3]; this.fileSpec = Arrays.copyOfRange(args, 4, args.length); // args[4]; System.out.println("Java version: " + System.getProperty("java.version")); server = ConnectFactory.getServer(uri, userName, passWord, clientName); System.out.println("Default JVM Charset: " + server.getCharsetName()); String charset = System.getProperty("charset"); if (charset != null) { System.out.println("Setting charset to " + charset); server.setCharsetName(charset); System.out.println("server.getCharsetName() is now: " + server.getCharsetName()); } List<IFileSpec> fileSpecs = FileSpecBuilder.makeFileSpecList(fileSpec); System.out.println("Syncing "); for (IFileSpec fileSpec1 : fileSpecs) { System.out.println(" " + fileSpec1.getOriginalPathString()); } SyncOptions syncOpts = new SyncOptions(); Boolean ob = Boolean.valueOf(System.getProperty("have", "true")); System.out.println("Populate have list: " + ob); syncOpts.setServerBypass(!ob); List<IFileSpec> specs = server.getCurrentClient().sync(fileSpecs, syncOpts); ConnectFactory.dumpSpecs("Sync results", specs); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 28709 | Joel Brown |
Allow setting character encoding (charset) with syncs with the Java System Property -Dcharset=<value> |
||
#4 | 27671 | Joel Brown | Revise to use serverBypass | ||
#3 | 27670 | Joel Brown |
Add to Sync and Streaming Sync the ability to not populate the have table java -Dhave=false -cp JenkinsOps.jar .... |
||
#2 | 26536 | Joel Brown | Add additional logging | ||
#1 | 25636 | Joel Brown | Simple P4Java methods to sync and reconcile. |