package com.perforce.common.depot; import java.io.File; import java.util.Date; import com.perforce.common.journal.BuildCounter; import com.perforce.common.journal.BuildDepot; import com.perforce.common.journal.JournalWriter; import com.perforce.common.node.PathMapTranslator; import com.perforce.config.CFG; import com.perforce.config.Config; import com.perforce.config.ConfigException; public class DepotConvert implements DepotInterface { private String name; private String depotSub; private long defaultDate; private JournalWriter journal; public DepotConvert(String name) throws Exception { this.name = name; // Depot name = parent's name of tree if ((Boolean) Config.get(CFG.TEST) == false) { Date date = new Date(); defaultDate = date.getTime() / 1000; } else { defaultDate = 0; } depotSub = (String) Config.get(CFG.P4_DEPOT_SUB); if (!depotSub.endsWith("/")) { depotSub = new String(depotSub + "/"); } if (!depotSub.startsWith("/")) { depotSub = new String("/" + depotSub); } // Create Depot root directory String p4root = (String) Config.get(CFG.P4_ROOT); if (!p4root.endsWith("/")) { p4root = new String(p4root + "/"); } File directory = new File(p4root); directory.mkdirs(); // Create journal String jnlPath = p4root + Config.get(CFG.P4_JNL_PREFIX) + Config.get(CFG.P4_JNL_INDEX); journal = new JournalWriter(jnlPath); // Add unicode counter if required if ((Boolean) Config.get(CFG.P4_UNICODE)) { journal.write(BuildCounter.toJournal("unicode", "1")); } // Create depot and write to journal journal.write(BuildDepot.toJournal(this)); journal.flush(); } @Override public String getClient() { try { return (String) Config.get(CFG.P4_CLIENT); } catch (ConfigException e) { return "p4-client"; } } @Override public long getDefaultDate() { return defaultDate; } @Override public String getUser() { try { return (String) Config.get(CFG.P4_USER); } catch (ConfigException e) { return "p4-user"; } } @Override public String getName() { return name; } @Override public String getPath(String scmPath) { String p4Path = PathMapTranslator.translate(scmPath); return p4Path; } @Override public String getRoot() throws ConfigException { String depotPath = (String) Config.get(CFG.P4_ROOT); if (!depotPath.endsWith("/") && !depotPath.endsWith("\\")) { depotPath = new String(depotPath + "/"); Config.set(CFG.P4_ROOT, depotPath); } return depotPath; } public JournalWriter getJournal() { return journal; } @Override public String getDefaultClientRoot() { try { return (String) Config.get(CFG.P4_CLIENT_ROOT); } catch (ConfigException e) { return "/ws"; } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 13876 | Paul Allen | Rename/move file(s) | ||
//guest/paul_allen/p4convert-maven/src/com/perforce/common/depot/DepotConvert.java | |||||
#1 | 13873 | Paul Allen | Branching using p4convert-maven | ||
//guest/perforce_software/p4convert/src/com/perforce/common/depot/DepotConvert.java | |||||
#3 | 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. |
||
#2 | 11005 | Paul Allen |
Changed default user/client to 'p4-user' and 'p4-client'. Test cases still use the original 'svn-user' and 'svn-client' to avoid updating all the test results. |
||
#1 | 9807 | Paul Allen | Initial import of p4-convert (from change 894340) |