package org.jenkinsci.plugins.p4_client.changes; import hudson.model.User; import hudson.scm.ChangeLogSet; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import org.jenkinsci.plugins.p4_client.client.ConnectionFactory; import com.perforce.p4java.core.IJob; import com.perforce.p4java.core.file.IFileSpec; import com.perforce.p4java.impl.generic.core.Changelist; import com.perforce.p4java.impl.generic.core.file.FileSpec; import com.perforce.p4java.server.CmdSpec; import com.perforce.p4java.server.IOptionsServer; public class P4ChangeEntry extends ChangeLogSet.Entry { private Changelist changelist; private List<IFileSpec> files; private List<IFileSpec> shelvedFiles; private List<IJob> jobs; public P4ChangeEntry(P4ChangeSet parent) { super(); setParent(parent); } @Override public String getMsg() { return changelist.getDescription(); } @Override public User getAuthor() { String id = changelist.getUsername(); User user = User.get(id); return user; } @Override public Collection<String> getAffectedPaths() { List<String> files = new ArrayList<String>(); try { List<IFileSpec> list = changelist.getFiles(true); for (IFileSpec item : list) { files.add(item.getDepotPathString()); } } catch (Exception e) { e.printStackTrace(); } return files; } public void setChange(Changelist changelist) { try { int change = changelist.getId(); IOptionsServer iserver = ConnectionFactory.getConnection(); this.changelist = (Changelist) iserver.getChangelist(change); this.files = changelist.getFiles(true); this.shelvedFiles = loadShelvedFiles(iserver, change); this.jobs = changelist.getJobs(); } catch (Exception e) { e.printStackTrace(); } } private List<IFileSpec> loadShelvedFiles(IOptionsServer iserver, int id) throws Exception { String cmd = CmdSpec.DESCRIBE.name(); String[] args = new String[] { "-s", "-S", "" + id }; List<Map<String, Object>> resultMaps; resultMaps = iserver.execMapCmdList(cmd, args, null); List<IFileSpec> list = new ArrayList<IFileSpec>(); if (resultMaps != null) { if ((resultMaps.size() > 0) && (resultMaps.get(0) != null)) { Map<String, Object> map = resultMaps.get(0); if (map.containsKey("shelved")) { for (int i = 0; map.get("rev" + i) != null; i++) { FileSpec fSpec = new FileSpec(map, iserver, i); fSpec.setChangelistId(id); list.add(fSpec); } } } } return list; } public Changelist getChange() { return changelist; } public List<IFileSpec> getFiles() { return files; } public List<IFileSpec> getShelvedFiles() { return shelvedFiles; } public List<IJob> getJobs() { return jobs; } public String getJobStatus(IJob job) { Map<String, Object> map = job.getRawFields(); String status = (String) map.get("Status"); return status; } public String getJobSummary(IJob job) { String summary = job.getDescription(); if (summary.length() > 80) { summary = summary.substring(0, 80) + "..."; } return summary; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#6 | 9672 | Paul Allen | Refactor name from 'p4_client' to 'p4'. | ||
#5 | 9127 | Paul Allen |
Added Browser support for P4Web. - Includes fix for move/add and move/delete icons when browsing change lists. |
||
#4 | 9055 | Paul Allen |
Label support. Build at a label using the pram 'label'. This includes adding the label to the ChangeEntry, building the change reports and Browser links to Swarm. (TPI-102) |
||
#3 | 8940 | Paul Allen |
Major refactor for the ConnectionHelper class to simplify serialisation. Fixed remote Jenkins JNLP slave connection issue. ClientHelper now extends ConnectionHelper and takes on all methods that require a client workspace. P4StandardCredentials is sent to the remote node instead of Credentials ID due to an issue accessing the Credentials store over a remote connection. For simplicity Client ID (workspace name) is serialised instead of the Workspace object. |
||
#2 | 8916 | Paul Allen | Unit tests for ChangeLog feature and minor fix when listing files if the change is Submitted or Shelved. | ||
#1 | 8915 | Paul Allen |
Support for ChangeLog and RepoBrowser. - Added RepoBrowser for Swarm (porting the others should be easy) - ChangeLog XML file now only stores the changelist number all other information is fetched from Perforce |