package com.perforce.svn.prescan; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.perforce.common.ConverterException; import com.perforce.common.node.Action; import com.perforce.config.CFG; import com.perforce.config.Config; import com.perforce.config.ConfigException; import com.perforce.svn.parser.Record; import com.perforce.svn.parser.RecordReader; import com.perforce.svn.prescan.UsageTree.UsageType; public class UsageParser { private Logger logger = LoggerFactory.getLogger(UsageParser.class); private UsageTree tree = new UsageTree("depot"); private int pathLength; private long emptyNodes; public UsageParser(String dumpFile) throws ConfigException { long endRev = (long) Config.get(CFG.P4_END); Progress progress = new Progress(endRev); pathLength = 0; emptyNodes = 0; logger.info("Scanning: " + dumpFile); // Open dump file reader and iterate over entries RecordReader recordReader = new RecordReader(dumpFile); for (Record record : recordReader) { switch (record.getType()) { case REVISION: progress.update(record.getSvnRevision()); break; case NODE: String toPath = record.findHeaderString("Node-path"); String fromPath = record.findHeaderString("Node-copyfrom-path"); if (toPath == null) { emptyNodes++; int rev = record.getSvnRevision(); int node = record.getNodeNumber(); logger.info("... empty node: " + rev + ":" + node); break; } if (toPath.length() > pathLength) { pathLength = toPath.length(); } UsageType type = getNodeType(record); Action action = Action.parse(record); tree.add(toPath, fromPath, type, action); break; default: break; } } } /** * Reads the node kind (file or directory) from the header field in the * Subversion dumpfile and returns the type. If a node kind is not found * then FILE is assumed. * * @param tree * @param record * @return * @throws ConverterException */ public static UsageType getNodeType(Record record) { UsageType nodeType = UsageType.UNKNOWN; String nodeKind = record.findHeaderString("Node-kind"); if (nodeKind == null) { nodeType = UsageType.FILE; } else if (nodeKind.equals("file")) { nodeType = UsageType.FILE; } else if (nodeKind.equals("dir")) { nodeType = UsageType.DIR; } return nodeType; } public UsageTree getTree() { return tree; } public int getPathLength() { return pathLength; } public long getEmptyNodes() { return emptyNodes; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 13876 | Paul Allen | Rename/move file(s) | ||
//guest/paul_allen/p4convert-maven/src/com/perforce/svn/prescan/UsageParser.java | |||||
#1 | 13873 | Paul Allen | Branching using p4convert-maven | ||
//guest/perforce_software/p4convert/src/com/perforce/svn/prescan/UsageParser.java | |||||
#6 | 13776 | Paul Allen |
CVS: Update to node Action detection. The RCS State is normally set to 'Exp' and 'dead', but this change allows more user defined states. - Move Action class to common.node package. - Modified test case061 to test custom states. |
||
#5 | 12890 | Paul Allen |
Extended start/stop change limits to CVS. - Moved start and stop configuration options out of SVN name space to the generic P4 space. - Abstracted shared range logic to ProcessChange #review-12880 |
||
#4 | 11273 | Paul Allen |
SVN: Add --tag=n option to search for labels in the SVN data. Example use: java -jar p4convert.jar --type=SVN --repo=svn.dump --tags=2 Sample output: ... A:1 tags/1.0.4/ ... D:2 tags/7.04.3/ Key: A - Automatic label S - Static label D - Deleted label B - Branch :n - number of changes on path |
||
#3 | 11270 | Paul Allen |
SVN: Detect deleted labels - Improvments to --info output - Tree depth reporting with --tree=n flag (n is depth >0) |
||
#2 | 11263 | Paul Allen | Refactor the enum Action outside of ChangeAction. | ||
#1 | 9807 | Paul Allen | Initial import of p4-convert (from change 894340) |