001: /*
002: * ====================================================================
003: * Copyright (c) 2004-2008 TMate Software Ltd. All rights reserved.
004: *
005: * This software is licensed as described in the file COPYING, which
006: * you should have received as part of this distribution. The terms
007: * are also available at http://svnkit.com/license.html
008: * If newer versions of this license are posted there, you may use a
009: * newer version instead, at your option.
010: * ====================================================================
011: */
012: package org.tmatesoft.svn.core.internal.io.fs;
013:
014: import org.tmatesoft.svn.core.SVNErrorCode;
015: import org.tmatesoft.svn.core.SVNErrorMessage;
016: import org.tmatesoft.svn.core.SVNException;
017: import org.tmatesoft.svn.core.SVNLogEntryPath;
018: import org.tmatesoft.svn.core.internal.wc.SVNErrorManager;
019:
020: /**
021: * @version 1.1.1
022: * @author TMate Software Ltd.
023: */
024: public class FSPathChange extends SVNLogEntryPath {
025: private static final String FLAG_TRUE = "true";
026: private static final String FLAG_FALSE = "false";
027:
028: private String myPath;
029: private FSID myRevNodeId;
030: private FSPathChangeKind myChangeKind;
031: boolean isTextModified;
032: boolean arePropertiesModified;
033:
034: public FSPathChange(String path, FSID id, FSPathChangeKind kind,
035: boolean textModified, boolean propsModified,
036: String copyfromPath, long copyfromRevision) {
037: super (path, FSPathChangeKind.getType(kind), copyfromPath,
038: copyfromRevision);
039: myPath = path;
040: myRevNodeId = id;
041: myChangeKind = kind;
042: isTextModified = textModified;
043: arePropertiesModified = propsModified;
044: }
045:
046: public String getPath() {
047: return myPath;
048: }
049:
050: public boolean arePropertiesModified() {
051: return arePropertiesModified;
052: }
053:
054: public void setPropertiesModified(boolean propertiesModified) {
055: arePropertiesModified = propertiesModified;
056: }
057:
058: public boolean isTextModified() {
059: return isTextModified;
060: }
061:
062: public void setTextModified(boolean textModified) {
063: isTextModified = textModified;
064: }
065:
066: public FSPathChangeKind getChangeKind() {
067: return myChangeKind;
068: }
069:
070: public void setChangeKind(FSPathChangeKind changeKind) {
071: myChangeKind = changeKind;
072: super .setChangeType(FSPathChangeKind.getType(changeKind));
073: }
074:
075: public FSID getRevNodeId() {
076: return myRevNodeId;
077: }
078:
079: public void setRevNodeId(FSID revNodeId) {
080: myRevNodeId = revNodeId;
081: }
082:
083: public void setCopyRevision(long revision) {
084: super .setCopyRevision(revision);
085: }
086:
087: public void setCopyPath(String path) {
088: super .setCopyPath(path);
089: }
090:
091: public static FSPathChange fromString(String changeLine,
092: String copyfromLine) throws SVNException {
093: int delimiterInd = changeLine.indexOf(' ');
094:
095: //String[] piecesOfChangeLine = changeLine.split(" ", 5);
096: if (delimiterInd == -1) {
097: SVNErrorMessage err = SVNErrorMessage.create(
098: SVNErrorCode.FS_CORRUPT,
099: "Invalid changes line in rev-file");
100: SVNErrorManager.error(err);
101: }
102:
103: String id = changeLine.substring(0, delimiterInd);
104: FSID nodeRevID = FSID.fromString(id);
105:
106: changeLine = changeLine.substring(delimiterInd + 1);
107: delimiterInd = changeLine.indexOf(' ');
108: if (delimiterInd == -1) {
109: SVNErrorMessage err = SVNErrorMessage.create(
110: SVNErrorCode.FS_CORRUPT,
111: "Invalid changes line in rev-file");
112: SVNErrorManager.error(err);
113: }
114: String changesKindStr = changeLine.substring(0, delimiterInd);
115:
116: FSPathChangeKind changesKind = FSPathChangeKind
117: .fromString(changesKindStr);
118: if (changesKind == null) {
119: SVNErrorMessage err = SVNErrorMessage.create(
120: SVNErrorCode.FS_CORRUPT,
121: "Invalid change kind in rev file");
122: SVNErrorManager.error(err);
123: }
124:
125: changeLine = changeLine.substring(delimiterInd + 1);
126: delimiterInd = changeLine.indexOf(' ');
127: if (delimiterInd == -1) {
128: SVNErrorMessage err = SVNErrorMessage.create(
129: SVNErrorCode.FS_CORRUPT,
130: "Invalid changes line in rev-file");
131: SVNErrorManager.error(err);
132: }
133: String textModeStr = changeLine.substring(0, delimiterInd);
134:
135: boolean textModeBool = false;
136: if (FSPathChange.FLAG_TRUE.equals(textModeStr)) {
137: textModeBool = true;
138: } else if (FSPathChange.FLAG_FALSE.equals(textModeStr)) {
139: textModeBool = false;
140: } else {
141: SVNErrorMessage err = SVNErrorMessage.create(
142: SVNErrorCode.FS_CORRUPT,
143: "Invalid text-mod flag in rev-file");
144: SVNErrorManager.error(err);
145: }
146:
147: changeLine = changeLine.substring(delimiterInd + 1);
148: delimiterInd = changeLine.indexOf(' ');
149: if (delimiterInd == -1) {
150: SVNErrorMessage err = SVNErrorMessage.create(
151: SVNErrorCode.FS_CORRUPT,
152: "Invalid changes line in rev-file");
153: SVNErrorManager.error(err);
154: }
155: String propModeStr = changeLine.substring(0, delimiterInd);
156:
157: boolean propModeBool = false;
158: if (FSPathChange.FLAG_TRUE.equals(propModeStr)) {
159: propModeBool = true;
160: } else if (FSPathChange.FLAG_FALSE.equals(propModeStr)) {
161: propModeBool = false;
162: } else {
163: SVNErrorMessage err = SVNErrorMessage.create(
164: SVNErrorCode.FS_CORRUPT,
165: "Invalid prop-mod flag in rev-file");
166: SVNErrorManager.error(err);
167: }
168:
169: String pathStr = changeLine.substring(delimiterInd + 1);
170:
171: String copyfromPath = null;
172: long copyfromRevision = FSRepository.SVN_INVALID_REVNUM;
173:
174: if (copyfromLine != null && copyfromLine.length() != 0) {
175: delimiterInd = copyfromLine.indexOf(' ');
176:
177: if (delimiterInd == -1) {
178: SVNErrorMessage err = SVNErrorMessage.create(
179: SVNErrorCode.FS_CORRUPT,
180: "Invalid changes line in rev-file");
181: SVNErrorManager.error(err);
182: }
183:
184: copyfromRevision = Long.parseLong(copyfromLine.substring(0,
185: delimiterInd));
186: copyfromPath = copyfromLine.substring(delimiterInd + 1);
187: }
188:
189: return new FSPathChange(pathStr, nodeRevID, changesKind,
190: textModeBool, propModeBool, copyfromPath,
191: copyfromRevision);
192: }
193:
194: }
|