package com.perforce.common.journal; import java.util.ArrayList; import com.perforce.common.depot.DepotInterface; import com.perforce.common.label.LabelConvert; import com.perforce.common.label.TagConvert; import com.perforce.common.node.PathMapTranslator; import com.perforce.common.schema.JournalRecord; public class BuildLabel { public static ArrayList<String> toJournal(DepotInterface d, LabelConvert lbl) throws Exception { ArrayList<String> label = new ArrayList<String>(); StringBuffer sb = new StringBuffer(); // Build label view for (String view : lbl.getView()) { label.add(viewToJournal(lbl.getName(), view)); } // Build label domain spec JournalRecord dbLabel = new JournalRecord("pv", "db.domain", 5); dbLabel.addField("name", lbl.getName()); dbLabel.addField("type", 108); dbLabel.addField("extra", lbl.getAutomatic()); dbLabel.addField("mount", ""); dbLabel.addField("mount2", ""); dbLabel.addField("mount3", ""); dbLabel.addField("owner", lbl.getOwner()); dbLabel.addField("update", lbl.getDate()); dbLabel.addField("access", lbl.getDate()); dbLabel.addField("options", 0); dbLabel.addField("desc", lbl.getDesc()); dbLabel.addField("stream", ""); sb.append(dbLabel.toJournalString() + "\n"); label.add(sb.toString()); // Build label revisions for (TagConvert t : lbl.getTags()) { label.add(toJournal(lbl.getName(), t)); } return label; } private static String toJournal(String name, TagConvert tag) throws Exception { StringBuffer sb = new StringBuffer(); String p4path = PathMapTranslator.translate(tag.getPath()); JournalRecord dbTag = new JournalRecord("pv", "db.label", 0); dbTag.addField("name", name); dbTag.addField("file", p4path); dbTag.addField("rev", tag.getRevision()); sb.append(dbTag.toJournalString() + "\n"); return sb.toString(); } private static String viewToJournal(String name, String view) throws Exception { StringBuffer sb = new StringBuffer(); JournalRecord dbView = new JournalRecord("pv", "db.view", 0); dbView.addField("name", name); dbView.addField("seq", 0); dbView.addField("mapflag", 0); dbView.addField("vfile", ""); dbView.addField("dfile", view); sb.append(dbView.toJournalString() + "\n"); return sb.toString(); } private static String depotPath(DepotInterface d, String path) { return (d.getPath(path)); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 12446 | Paul Allen | Branching using p4convert-rusty | ||
//guest/perforce_software/p4convert/src/com/perforce/common/journal/BuildLabel.java | |||||
#5 | 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 |
||
#4 | 11071 | Paul Allen |
Path map translator for CVS and SVN paths. (undoc) To use create a path.map file with regex and group match. Only the first matching entry is used. The regex and group match are seperated by ', ' (or in regex terms ',\s+'). Lines starting with '#' are ignored. For example, 'trunk' is renamed to 'main', but other entries are left as-is. # path.map trunk/(.*), //import/main/{1} (.*), //import/{1} Note: if no file is found the default 'depot' and 'subPath' options are used to generate the map, preserving the original behaviour. CVS paths will always stat with the 'branch' name. 'main' for 1.1 and the symbol for other branches. # path.map main/projA/(.*), //import/projA/MAIN/{1} release_(.*)/projA/(.*), //import/projA/REL{1}/{2} (.*)/projA/(.*), //import/projA/TAG-{1}/{2} (.*), //import/unexpected/{1} Node: adding a catch all is a good idea. |
||
#3 | 11043 | Paul Allen |
SVN: Added View support for Automatic labels (Convert and Import mode) - Update view metadata in test case 118 |
||
#2 | 11018 | Paul Allen | SVN: Support automatic labels for IMPORT and CONVERT modes. | ||
#1 | 9807 | Paul Allen | Initial import of p4-convert (from change 894340) |