package com.perforce.common.label; import java.util.Date; import java.util.List; import com.perforce.common.client.P4Factory; import com.perforce.common.depot.DepotImport; import com.perforce.cvs.RevisionEntry; import com.perforce.p4java.core.ILabel; import com.perforce.p4java.core.ILabelMapping; import com.perforce.p4java.core.ViewMap; import com.perforce.p4java.core.file.FileSpecBuilder; import com.perforce.p4java.core.file.IFileSpec; import com.perforce.p4java.exception.P4JavaException; import com.perforce.p4java.impl.generic.core.Label; import com.perforce.p4java.option.server.TagFilesOptions; import com.perforce.p4java.server.IOptionsServer; public class LabelImport implements LabelInterface { private DepotImport depot; private ILabel ilabel; private IOptionsServer iserver; private String name; private String owner; private Date date; public LabelImport(String label, RevisionEntry entry, DepotImport depot) throws Exception { this.depot = depot; this.name = label; this.owner = entry.getAuthor(); this.date = entry.getDate(); iserver = depot.getIServer(); ilabel = iserver.getLabel(name); if (ilabel == null) { Label l = new Label(); l.setName(name); l.setOwnerName(depot.getUser()); ViewMap<ILabelMapping> viewMap = new ViewMap<ILabelMapping>(); Label.LabelMapping lMap = new Label.LabelMapping(); lMap.setLeft("//" + depot.getName() + "/..."); viewMap.addEntry(lMap); l.setViewMapping(viewMap); iserver.createLabel(l); ilabel = iserver.getLabel(name); } ilabel.setOwnerName(owner); ilabel.setLastAccess(date); ilabel.setLastUpdate(date); ilabel.setDescription(getDesc()); } @Override public String getName() { return name; } @Override public String getOwner() { return owner; } @Override public Long getDate() { return date.getTime() / 1000; } @Override public String getDesc() { StringBuffer sb = new StringBuffer(); sb.append("Created by "); sb.append(owner); sb.append(".\n"); return sb.toString(); } @Override public List<TagConvert> getTags() { // not required return null; } @Override public void add(TagConvert tag) throws Exception { StringBuffer fileStr = new StringBuffer(); fileStr.append("//" + depot.getName() + "/"); fileStr.append(tag.getPath()); fileStr.append("#" + tag.getRevision()); List<IFileSpec> fileSpecs; fileSpecs = FileSpecBuilder.makeFileSpecList(fileStr.toString()); TagFilesOptions tagOpts = new TagFilesOptions(); List<IFileSpec> tagSpec = iserver.tagFiles(fileSpecs, name, tagOpts); P4Factory.validateFileSpecs(tagSpec); } public String toString() { StringBuffer sb = new StringBuffer(); sb.append(name + " by: " + owner + "\n"); String fileStr = "//...@" + name; List<IFileSpec> fileSpecs; fileSpecs = FileSpecBuilder.makeFileSpecList(fileStr); List<IFileSpec> tags; try { tags = iserver.getDepotFiles(fileSpecs, null); for (IFileSpec rev : tags) { sb.append("... " + rev + "\n"); } } catch (P4JavaException e) { sb.append("... error\n"); } return sb.toString(); } @Override public void submit() throws Exception { ilabel.setOwnerName(owner); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#12 | 13920 | Paul Allen | copy part 2 (no errors) | ||
#11 | 11979 | Paul Allen | CVS: Fix label view when tagging files in later changes. | ||
#10 | 11836 | Paul Allen |
CVS: Fix path translation for labels. Allows the use of a path map or com.p4convert.p4.subPath definition when CVS labels are enabled. - includes test case057 |
||
#9 | 11760 | Paul Allen |
Use default label description and append label type. Previously I used the change description, which is ok for Automatic labels, but Static labels may include more than one change. Includes: - Fix parsing of RCS descriptions (support descriptions without new line) - Update to test cases. |
||
#8 | 11294 | Paul Allen |
SVN: Improved label support for Subversion tag of another tag, when one or both get converted to a Perforce label. TODO: add aditional unit tests. |
||
#7 | 11043 | Paul Allen |
SVN: Added View support for Automatic labels (Convert and Import mode) - Update view metadata in test case 118 |
||
#6 | 11042 | Paul Allen |
SVN: Test case 118 for labels_basic - minor fix to ignore 'label in sync' p4java message |
||
#5 | 11041 | Paul Allen | SVN: Fixes to support changelist numbering and AUTOMATIC labels in Import mode (front door). | ||
#4 | 11018 | Paul Allen | SVN: Support automatic labels for IMPORT and CONVERT modes. | ||
#3 | 10839 | Paul Allen |
Update Import Test framework (CVS/SVN) to support labels. CVS test case 030 update and code cleanup. |
||
#2 | 10730 | Paul Allen |
CVS: Fix for Labels in Import mode. Unable to label a revision in a pending change, so store all tag entries and add them to label after the change is submitted. Includes basic test case 030 |
||
#1 | 9807 | Paul Allen | Initial import of p4-convert (from change 894340) |