package com.perforce.p4simulink.connection; /** * Perforce SCM Integration */ import com.perforce.p4java.PropertyDefs; import com.perforce.p4java.client.IClient; import com.perforce.p4java.impl.mapbased.rpc.RpcPropertyDefs; import com.perforce.p4java.server.IOptionsServer; import com.perforce.p4java.server.ServerFactory; import com.perforce.p4simulink.P4CMException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.Closeable; import java.io.IOException; import java.util.Properties; public class Connection implements Closeable { private static final Properties properties; private static final Logger log = LogManager.getLogger(Connection.class.getName()); IOptionsServer server; IClient client; /** * Initialise static properties for all Perforce connections */ static { properties = System.getProperties(); properties.put(PropertyDefs.PROG_NAME_KEY, "P4Simulink"); properties.put(PropertyDefs.PROG_VERSION_KEY, "2013.2"); // Set up socket pooling to use a single socket properties.put(RpcPropertyDefs.RPC_SOCKET_POOL_SIZE_NICK, "1"); // disable timeout for slow servers / large db lock times properties.put(RpcPropertyDefs.RPC_SOCKET_SO_TIMEOUT_NICK, "0"); } /** * Connect to the Perforce Server * * @param config Perforce connection config (e,g. P4PORT, P4USER, ...) * @throws com.perforce.p4simulink.P4CMException */ public void connect(Config config) throws P4CMException { try { if (server != null && server.isConnected()) { server.disconnect(); } server = ServerFactory.getOptionsServer(config.getAddress(), properties); server.connect(); server.setUserName(config.getUser()); client = server.getClient(config.getClient()); server.setCurrentClient(client); } catch (Exception e) { P4CMException ex = new P4CMException(e); log.error(ex); log.error(e.getMessage()); throw ex; } } /** * Disconnect from the Perforce Server, if we're connected. * * @throws com.perforce.p4simulink.P4CMException */ public void disconnect() throws P4CMException { try { if ((server != null) && server.isConnected()) { server.disconnect(); } } catch (Exception e) { P4CMException ex = new P4CMException(e); log.error(ex); throw ex; } } @Override public void close() throws IOException { try { disconnect(); } catch (P4CMException e) { throw new IOException(e); } } public boolean isReady() { if (server != null && server.isConnected()) { return true; } return false; } public IOptionsServer getServer() { return server; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#11 | 11645 | Paul Allen |
Refactoring and additional work on UI: Removed Connection class and went with global server/client objects. Implemented panes for connection, depot path and passwords. Passwords are only requested when required. Transferred from p4://perforce.perforce.com:1666@957149 |
||
#10 | 11644 | Paul Allen |
Paul's changes: Refactor getAddress and getAddressForConfig to getPort and getP4JavaURI. There were a few cases when the wrong value was written + getPort was not working. Password had a null password object (now initilised) P4PaswordPane needs some work - must talk to Perfoce to see if it needs a pass or is already logged in. There are still sync -f (this is very bad) Think I miss understood the checkout method after finding and reading the JavaDoc. You were right to start. Looks like a p4 edit. Would like to set a break point and find out when it is used. Elliot's changes: * Changed export() to use p4 'print' * Connect/login now looks for P4TICKETS env var * Config no longer stores P4PASSWD or P4TICKETS * Removed P4TICKET functionality (was only for P4Jenkins) * Ensured we're using a global IServer object * checkout() now uses editFiles() (opens all files for edit) * Changed all "sync -f" to plain "sync" * Removed final client update with force flag * Removed error dialogues regarding login issues * Investigated use of P4IGNORE - I'll need to write my own filter, no big deal Transferred from p4://perforce.perforce.com:1666@955247 |
||
#9 | 11643 | Paul Allen |
Unshelved from pending changelist '953729': Paul: Added: - getWorkspaceState() -- run a p4 status - getOpenedState() -- run p4 opened - getIgnoreState() -- run p4 add -n Modified: - add() -- seemed to call reopen? - P4FileState -- simple constructor for state Elliot: * global client and changelist object within the adapter * removed repeated client updates and changelist refreshes * removed 'reopen' in add * added calls to 'edit' where appropriate file states are found * made 'checkout' a pure sync, with no edits * commented a bunch of the @Override methods * added a call to haveList in getFileState so we can see versions of files in the project * changed the connection pane to look like p4v's * refactored a bit of the dialogue code, added calls to prompt for password (like p4v) * changed all log.trace() calls to log.debug() so the log file messiness can be controlled more easily Functionality that now works properly: * open project from source control, with properly-configured .p4config file * add new project to source control, with properly-configured .p4config file * add * edit * commit * revert * compare reversions (opens Simulink diff tool) Things to work on: * dialogues (particularily the password one, but the connection one is a bit dodge-y) * remove from project (possibly always making the Simulink project meta-data editable will fix this - it *almost* works) - the current issue is Simulink needs to edit the meta-data, but Perforce has made the files read-only, so Simulink throws up on itself Transferred from p4://perforce.perforce.com:1666@954622 |
||
#8 | 11642 | Paul Allen |
More fixes from discussion with Paul and after looking at other integrations work. Transferred from p4://perforce.perforce.com:1666@953553 |
||
#7 | 11641 | Paul Allen |
Fixes from chat with Paul. Transferred from p4://perforce.perforce.com:1666@953389 |
||
#6 | 11639 | Paul Allen |
Integrate code from the P4Jenkins plugin, add ability to authenticate with tickets or ticket file. Worked through some issues with getting current file state. Transferred from p4://perforce.perforce.com:1666@952289 |
||
#5 | 11637 | Paul Allen |
Fix up isLatest, uncheckout, add back code that searched for a .p4rc file within the sandbox directory first, then looks in ~/.p4simulink/ and finally ~/. Transferred from p4://perforce.perforce.com:1666@950121 |
||
#4 | 11636 | Paul Allen |
Updates to integrate with Simulink, merging into one directory. Added auto submits to add, remove, etc since this is what Simulink expects. Transferred from p4://perforce.perforce.com:1666@947024 |
||
#3 | 11635 | Paul Allen |
Updated gradle build to create a "fat jar", fixed some issues with the interfaces when it runs in Simulink itself. Added connection.configuration pane, switched the adapter to use a current changelist which gives a more svn-ish feel (which the Adapter is expecting). Added some more unit tests. General re-factoring. Transferred from p4://perforce.perforce.com:1666@946607 |
||
#2 | 11634 | Paul Allen |
Debugging actual adapter functionality and starting to integrate with Simulink. Transferred from p4://perforce.perforce.com:1666@938961 |
||
#1 | 11632 | Paul Allen |
Added commons-exec library, server startup/shutdown for unit tests, fixed a bunch of NPEs. Transferred from p4://perforce.perforce.com:1666@937331 |