package com.perforce.p4simulink; /** * Copyright (C) 2014 Perforce Software. All rights reserved. * * Please see LICENSE.txt in top-level folder of this distribution. */ import com.mathworks.cmlink.api.ApplicationInteractor; import com.mathworks.cmlink.api.ConfigurationManagementException; import com.mathworks.cmlink.api.version.r14a.CMRepository; import com.mathworks.cmlink.api.RepositorySupportedFeature; import com.perforce.p4simulink.connection.Config; import com.perforce.p4simulink.ui.P4ConnectionPane; import com.perforce.p4simulink.util.Logging; import javax.swing.JOptionPane; import java.awt.Frame; import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.EnumSet; public class P4Repository extends P4Interactor implements CMRepository { private final int OK = 0; private final int CANCEL = 1; private final int ERROR = 2; private final Collection<RepositorySupportedFeature> supportedFeatures; public P4Repository(ApplicationInteractor applicationInteractor) throws P4CMException { this(applicationInteractor, new Config()); } public P4Repository(ApplicationInteractor applicationInteractor, Config config) throws P4CMException { super(applicationInteractor, config); terminator = applicationInteractor.getTerminator(); supportedFeatures = EnumSet.of(RepositorySupportedFeature.REPOSITORY_BROWSER); } @Override public void convertFolderToSandbox(File folder) { log.debug("convertFolderToSandbox() - {}", folder.getAbsolutePath()); throw new UnsupportedOperationException(); } @Override public boolean isFeatureSupported(RepositorySupportedFeature feature) { boolean supported = supportedFeatures.contains(feature); log.debug("isFeatureSupported() - {} {}", feature, supported); return supported; } @Override public void retrieveSandboxFromRepository(String repositorySpecifier, File sandboxRoot) throws ConfigurationManagementException { log.debug( "retrieveSandboxFromRepository() {} {}", repositorySpecifier, sandboxRoot != null ? sandboxRoot.getAbsolutePath() : "" ); try { retrieveSandboxFromRepository(repositorySpecifier, sandboxRoot, null); } catch (ConfigurationManagementException e) { Logging.logException(log, e, true); } } public void retrieveSandboxFromRepository(String repositorySpecifier, File sandboxRoot, String tag) throws ConfigurationManagementException { log.debug( "retrieveSandboxFromRepository() {} {} {}", repositorySpecifier, sandboxRoot != null ? sandboxRoot.getAbsolutePath() : "", tag ); if (sandboxRoot == null || (sandboxRoot != null && !sandboxRoot.exists())) { log.error("Check-out directory missing: " + sandboxRoot.getAbsolutePath()); return; } try { // here we need to get an adapter and check out the files in the directory P4Adapter p4 = (P4Adapter) new P4AdapterFactory().getAdapterForThisSandboxDir(sandboxRoot); p4.setDepotPath(repositorySpecifier); config = p4.config; p4.connect(); if (!p4.login()) { showPasswordDialogue(""); p4.login(); } client = p4.getClient(); Collection<File> files = Collections.singletonList(sandboxRoot); p4.checkout(files); } catch (ConfigurationManagementException e) { Logging.logException(log, e, true); } } public String getVersion() { log.debug("getVersion()"); return "0.2.982869"; } public Collection<String> getTags(String repositoryPath) throws ConfigurationManagementException { log.debug("getTags() - {}", repositoryPath); Collection<String> tags = new ArrayList<>(); try { File repositoryFile = new File(repositoryPath); P4Adapter p4 = (P4Adapter) new P4AdapterFactory().getAdapterForThisSandboxDir(repositoryFile); tags = p4.getTags(repositoryFile); } catch (ConfigurationManagementException e) { Logging.logException(log, e, true); } return tags; } @Override public String browseForRepositoryPath(String currentlySelectedPath, Frame parentFrame) { log.debug("browseForRepositoryPath() - {}", currentlySelectedPath); P4ConnectionPane pane = new P4ConnectionPane(config); if (depotPath == null || depotPath.isEmpty()) { depotPath = currentlySelectedPath; } boolean showDialogue = true; int tries = 5; int result = OK; while (showDialogue && tries-- > 0) { int option = JOptionPane.showConfirmDialog( applicationInteractor.getParentFrame(), pane.getFields(), "Open Connection", JOptionPane.OK_CANCEL_OPTION ); if (option == JOptionPane.CANCEL_OPTION) { // user hit cancel result = CANCEL; break; } showDialogue = pane.getServer() == null || pane.getServer().isEmpty() || pane.getUsername() == null || pane.getUsername().isEmpty() || pane.getWorkspace() == null || pane.getWorkspace().isEmpty(); result = !showDialogue ? OK : ERROR; } if (result == OK) { // we're good, so update the config values and save config.setPort(pane.getServer()); config.setClient(pane.getWorkspace()); config.setUser(pane.getUsername()); try { config.save(); } catch (P4CMException e) { log.error("Couldn't save config: " + e.getLocalizedMessage()); } } return depotPath; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#22 | 13842 | Paul Allen |
New P4Adapter setup designed to avoid passing the URI. #review-13782 |
||
#21 | 12023 | Paul Allen | Copying using p4Simulink_dev->main | ||
#20 | 11672 | Paul Allen |
Tidy up formatting and imports. No functional change. |
||
#19 | 11664 | Paul Allen |
New build for Mathworks to look at. Transferred from p4://perforce.perforce.com:1666@991739 |
||
#18 | 11662 | Paul Allen |
Fix NPE in changelist selector, remove reference to "Simulink project" from error messages. Transferred from p4://perforce.perforce.com:1666@988672 |
||
#17 | 11661 | Paul Allen |
Finishing up unit tests. Transferred from p4://perforce.perforce.com:1666@985194 |
||
#16 | 11659 | Paul Allen |
Performance improvements, continued: improved performance of getFileState() by replacing the client haveList call with a direct server command. Also improved isLatest by removing fstat calls and replacing with simpler calls to diff and sync. Transferred from p4://perforce.perforce.com:1666@983506 |
||
#15 | 11655 | Paul Allen |
Updating for Scania demo. Transferred from p4://perforce.perforce.com:1666@977338 |
||
#14 | 11653 | Paul Allen |
Fixes for R2014b of MATLAB/Simulink, including: * No longer prompting for connection information in isDirSandboxForThisAdapter * Fixed up commit logic, so it no longer uses the current changelist * Added back logic to walk the directory tree to find a .p4config file, rather than needing one in the sandbox directory * Added new buttons for re-connecting to p4d, and editing .p4config * Investigated conflict issues - fixed some, better logic coming * Removed .p4ignore generation - wrong spot for it Transferred from p4://perforce.perforce.com:1666@976888 |
||
#13 | 11652 | Paul Allen |
Added boilerplate to code, fixed build issues (NPEs on plugin load), removed Mathworks classes from plugin jar, fixed delete vs missing issue on remove() call. Transferred from p4://perforce.perforce.com:1666@970498 |
||
#12 | 11651 | Paul Allen |
Finalizing alpha code changes - adding jar for release. Transferred from p4://perforce.perforce.com:1666@962486 |
||
#11 | 11648 | Paul Allen |
Final changes after demo with PM, including removal of depot path from the connection dialogue, and fixing of the p4 print issue. Transferred from p4://perforce.perforce.com:1666@958518 |
||
#10 | 11647 | Paul Allen |
New project creation fixes. Transferred from p4://perforce.perforce.com:1666@958305 |
||
#9 | 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 |
||
#8 | 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 |
||
#7 | 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 |
||
#6 | 11642 | Paul Allen |
More fixes from discussion with Paul and after looking at other integrations work. Transferred from p4://perforce.perforce.com:1666@953553 |
||
#5 | 11641 | Paul Allen |
Fixes from chat with Paul. Transferred from p4://perforce.perforce.com:1666@953389 |
||
#4 | 11640 | Paul Allen |
Fixes to project integrity checks within Simulink. Transferred from p4://perforce.perforce.com:1666@952945 |
||
#3 | 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 |
||
#2 | 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 |
||
#1 | 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 |