package com.perforce.p4simulink.connection; import java.io.File; import com.mathworks.cmlink.api.FileState; import com.mathworks.cmlink.api.IntegerRevision; import com.mathworks.cmlink.api.LocalStatus; import com.mathworks.cmlink.api.Revision; import com.perforce.p4java.core.file.FileAction; import com.perforce.p4java.core.file.IExtendedFileSpec; import com.perforce.p4simulink.P4CMException; public class P4FileState implements FileState { private LocalStatus status = LocalStatus.UNKNOWN; private int haveRev; private boolean lock; private File file; public P4FileState(IExtendedFileSpec spec) throws P4CMException { if (spec == null) { status = LocalStatus.NOT_UNDER_CM; return; } String clientFile = spec.getClientPathString(); this.file = new File(clientFile); this.lock = spec.isLocked(); this.haveRev = spec.getHaveRev(); int headRev = spec.getHeadRev(); // check pending changes FileAction action = spec.getAction(); if (action == FileAction.ADD) { status = LocalStatus.ADDED; return; } if (action == FileAction.MOVE_ADD) { status = LocalStatus.ADDED; return; } if (action == FileAction.EDIT) { status = LocalStatus.MODIFIED; return; } if (action == FileAction.DELETE) { status = LocalStatus.DELETED; return; } if (action == FileAction.MOVE_DELETE) { status = LocalStatus.DELETED; return; } // have a file, but it is out of date if (haveRev > 0 && haveRev < headRev) { status = LocalStatus.CONFLICTED; return; } // don't have a file, but it is versioned if (haveRev <= 0) { status = LocalStatus.NOT_UNDER_CM; return; } // remainder status = LocalStatus.UNMODIFIED; return; } @Override public LocalStatus getLocalStatus() { return status; } @Override public Revision getRevision() { return new IntegerRevision(haveRev); } @Override public boolean hasLock() { return lock; } public File getFile() { return file; } public void setFile(File file) { this.file = file; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append(file + ": " + status.name()); return sb.toString(); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 11947 | Paul Allen | Added MOVE_ADD and MOVE_DELETE types to P4FileState to support rename. | ||
#3 | 11931 | Paul Allen |
Minor fix to FileState. MatLab asks about deleted files, so need to return NOT_UNDER_CM |
||
#2 | 11927 | Paul Allen |
Detect local edits (isModified) and add to pending change. Fix revert (uncheckout) if file is open in another change. |
||
#1 | 11899 | Paul Allen | Inprogress development - moved work to branch |