package com.perforce.cvs; import java.util.ArrayList; import java.util.Date; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.perforce.config.CFG; import com.perforce.config.Config; import com.perforce.config.ConfigException; import com.perforce.cvs.parser.rcstypes.RcsObjectDelta; import com.perforce.cvs.parser.rcstypes.RcsObjectNum; import com.perforce.svn.change.RevisionImport; public class RevisionEntry implements Comparable<RevisionEntry> { private Logger logger = LoggerFactory.getLogger(RevisionEntry.class); private RcsObjectNum id; private boolean lazy = true; private String path; private int nodeID; private long cvsChange; private Date date; private String commitId; private String author; private String comment; private String state; private String fromPath; private List<String> labels = new ArrayList<String>(); public RevisionEntry(RcsObjectDelta revision) { this.id = revision.getID(); this.date = revision.getDate(); this.commitId = revision.getCommitId().intern(); this.author = revision.getAuthor().intern(); this.comment = revision.getLog().intern(); this.state = revision.getState().intern(); } @Override public boolean equals(Object obj) { if (!(obj instanceof RevisionEntry)) return false; RevisionEntry entry = (RevisionEntry) obj; // only test for commit ID if used if (getCommitId() != null && entry.getCommitId() != null) { if (getCommitId().contentEquals(entry.getCommitId())) return true; else return false; } // otherwise, check author if (!getAuthor().contentEquals(entry.getAuthor())) { return false; } // and comment if (!getComment().contentEquals(entry.getComment())) { return false; } // and date is within range return within(entry); } @Override public int compareTo(RevisionEntry obj) { final int EQUAL = 0; final int NEWER = 1; final int OLDER = -1; // compare newer or older by date long gap = obj.getDate().getTime() - getDate().getTime(); if (gap == 0) return EQUAL; else if (gap > 0) return OLDER; else return NEWER; } public RcsObjectNum getId() { return id; } public String getPath() { return path; } public String getCommitId() { return commitId; } public void clearCommitId() { commitId = null; } public String getAuthor() { return author; } public void setAuthor(String user) { author = user; } public String getComment() { return comment; } public void setComment(String log) { comment = log; } public Date getDate() { return date; } /** * Add milli seconds to date */ public void addDate(long t) { long d = date.getTime() + t; date = new Date(d); } public int getNodeID() { return nodeID; } public void setNodeID(int nodeID) { this.nodeID = nodeID; } public long getCvsChange() { return cvsChange; } public void setCvsChange(long cvsChange) { this.cvsChange = cvsChange; } public String getState() { return state; } public void setState(String s) { state = s; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append(getId()); sb.append(" "); sb.append(getDate().getTime()); sb.append(" "); sb.append(getPath()); sb.append(" "); sb.append(getCommitId()); sb.append(" "); sb.append(getAuthor()); return sb.toString(); } public void setPath(String revPath) { path = revPath.intern(); } public String getFromPath() { return fromPath; } public void setFromPath(String fromPath) { this.fromPath = fromPath.intern(); } public String getTmpFile() { if(lazy) { return null; } String tmp; try { tmp = (String) Config.get(CFG.CVS_TMPDIR); } catch (ConfigException e) { tmp = "tmp"; } String subPath = path.substring(path.indexOf("/")); String myTmpFile = tmp + subPath + "/" + id.toString(); myTmpFile = RevisionImport.unFormatPath(myTmpFile); return myTmpFile; } public void setLazy(boolean set) { this.lazy = set; } public void addLabel(String label) { if (logger.isDebugEnabled()) { logger.debug("Label tag: " + label + " - " + getId()); } getLabels().add(label.intern()); } public List<String> getLabels() { return labels; } public boolean within(RevisionEntry entry) { long window; try { window = (long) Config.get(CFG.CVS_WINDOW); } catch (ConfigException e) { window = 20000L; } long gap = getDate().getTime() - entry.getDate().getTime(); if (Math.abs(gap) > window) { return false; } return true; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#18 | 13920 | Paul Allen | copy part 2 (no errors) | ||
#17 | 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. |
||
#16 | 12405 | Paul Allen |
CVS: Save change list data to a JSON formatted file 'changes.json'. (Work-In-Progress) - need to add load option and resume flags |
||
#15 | 12325 | Paul Allen | CVS: Fix for RCS @b@ expand binary detection. | ||
#14 | 12235 | Paul Allen |
CVS: Username map Now supports the --users flag for CVS returning a list of usernames. The map file can then be used to remap usernames during the import. - Includes test case062 |
||
#13 | 12195 | Paul Allen |
CVS - Use the RCS 'expand' field to detect BINARY files. If set this will take precedence over the type map. - Added test case061 |
||
#12 | 11064 | Paul Allen |
CVS: added detection and support for +x revisions - extended testcase 040 to test for exec bits |
||
#11 | 10997 | Paul Allen |
CVS: use a dynamic time window when processing pseudo branches. - Prevent branches getting ahead of the source. - Used parent equals method in RevisionEntry to fix for drop method in RevisionSorter. |
||
#10 | 10978 | Paul Allen |
CVS redesign of RCS Revision Navigation. - Disabled reverse RCS tag lookup for the moment. |
||
#9 | 10944 | Paul Allen |
CVS change-list processing. Create a delayed list for pseudo branches to prevent them falling into the wrong change. - updated test cases 006 007 047 |
||
#8 | 10923 | Paul Allen | Even more null protection. | ||
#7 | 10921 | Paul Allen | String.intern() null protection. | ||
#6 | 10920 | Paul Allen |
CVS intern Strings to help reduce memory. (Use Java 7 or greater) |
||
#5 | 10912 | Paul Allen |
Back out changelist 10911 - Tmp file look to be in error |
||
#4 | 10911 | Paul Allen |
CVS memory optimisation - Calculate tmp file (has some risk, but saves lots of memory) - String.intern() must use with java 7 or later. |
||
#3 | 10839 | Paul Allen |
Update Import Test framework (CVS/SVN) to support labels. CVS test case 030 update and code cleanup. |
||
#2 | 10728 | Paul Allen |
CVS: new Label feature. Scans the RCS tree counting revisions on a branch. If the branch only has one revision it gets downgraded to a Label. Support added for Import and Convert mode. Activate using: com.p4convert.cvs.labels=true or in java Config.set(CFG.CVS_LABELS, true); (manual testing only -- automated tests will follow this change) |
||
#1 | 9807 | Paul Allen | Initial import of p4-convert (from change 894340) |