其实这个问题很久以前就发现了,只是当时比较忙就忽略了。
今天做cvs迁移的时候又遇到了,在这里写下来,看看看有没有同僚遇到过告诉一下解决方法,同时我自己也写了一段java程序用来解决这个问题,希望大家看看代码有什么不妥的地方。
问题描述:
1、 现有的module已经同步到了cvs上。
2、本地项目team→Disconnect...→alsoDelete删除了与CVS的联系
3、然后还是刚才那个断开联系的项目,Team→share project 一路next 然后use exiting 找到仓库里原来的那个同名项目,点击finished,如下图
正常图片 不正常图片
问题一:有没有什么方法能解决,还是我操作有问题?
在网上搜了一下,没有找到类似问题解决方案,于是我就研究了一下CVS在本地的文件格式看看和正常的比较有什么不同,发现CVS目录下的Entries文件中有所不同列举我发现的两个不同之处
正常文件:
/log4j.properties/1.1/Tue Mar 12 06:51:53 2013
/format.xls/-1.1/Mon Aug 6 03:01:55 2012/-kb/
不正常文件:
/log4j.properties/1.1/Tue Mar 12 06:51:53 2013//T1.1
/format.xls/-1.1/Mon Aug 6 03:01:55 2012/-kb/T1.1
然后我就写了一个处理这个文件的java程序。
package alterfile;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class AlterFile {
private static int FILENUMS = 0;
public void method(File f) {
try {
File[] FList = f.listFiles();
for (int i = 0; i < FList.length; i++) {
if (FList[i].isDirectory() == true) {
method(FList[i]);
} else {
if (FList[i].getName().equals("Entries")) {
FILENUMS++;
System.out
.println("path:" + FList[i].getAbsolutePath());
altermethod(FList[i].getAbsolutePath());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void altermethod(String filepath) {
File file = new File(filepath);
List<String> content = new ArrayList<String>();
BufferedReader breader = null;
FileWriter fw = null;
String tempString = null;
try {
breader = new BufferedReader(new FileReader(file));
while ((tempString = breader.readLine()) != null) {
System.out.println("cont:" + tempString);
content.add(tempString);
}
fw = new FileWriter(filepath);
for (int i = 0; i < content.size(); i++) {
System.out.println("alte:" + subLineString(content.get(i)));
fw.write(subLineString(content.get(i)) + "\r\n");
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (breader != null) {
try {
breader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
private static String subLineString(String tempString) {
int endT = tempString.lastIndexOf("//T");
int endkb = tempString.lastIndexOf("kb");
if (endT > 0) {
tempString = tempString.substring(0, endT + 2);
} else if (endkb > 0) {
tempString = tempString.substring(0, endkb + 3);
}
return tempString;
}
public static void main(String[] args) {
File file = new File("D:/workspace");
AlterFile t = new AlterFile();
t.method(file);
System.out.println("FILENUMS:" + FILENUMS);
}
}