package com.perforce.workshop.tjuricek.p4java_ext; import com.perforce.p4java.exception.P4JavaException; import com.perforce.p4java.server.IOptionsServer; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; /** * Exposes access to the "p4 add" command */ public interface P4Add extends P4ClientConnection, P4Errors { static P4Add create(P4ClientConnection conn) { return new DefaultP4Add(conn); } /** * Marks the paths for add against the changelist. * * @param changelist Pending changelist ID, should be on the active client * @param type Either "binary" or "text", or null to guess the file type * @param paths Paths to add, probably local file paths */ default void add(String changelist, String type, String... paths) { try { List<String> optList = new ArrayList<String>(); // -f will allow us to submit special characters, and have them // reformatted later by the server optList.add("-f"); Collections.addAll(optList, "-c", changelist); if (type != null) { Collections.addAll(optList, "-t", type); } Collections.addAll(optList, paths); String[] opts = optList.toArray(new String[0]); IOptionsServer optionsServer = getOptionsServer(); Map<String, Object>[] results = optionsServer.execMapCmd("add", opts, null); checkError(results); } catch (P4JavaException e) { throw new P4Exception(e); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 9086 | tjuricek |
0.1.0 Initial release of p4java_ext Mostly just contains enough of the P4 API to build the test data initializer. About 4 commands have minimal testing, so it works. Kind of. |
||
//guest/tjuricek/p4java_ext/src/main/java/com/perforce/p4java_ext/P4Add.java | |||||
#1 | 9085 | tjuricek | First import of the project, before package refactoring. |