在Windows下清理SVN关联文件
来源:互联网 发布:服务器攻击防御软件 编辑:程序博客网 时间:2024/04/29 19:59
第一次写博文。
前阵子笔记本的硬盘坏了,丢了很多的源代码。向公司反映此事,经批准搭设CVS服务器,一个便于追踪版本,一个以防类似以上的事故再次发生。但是实际搭设好CVS服务器后,发现有很多问题:
第一,虽然使用了基于图形界面的WINCVS,但是上手还是很难,界面也不友好;
第二,CVS无法实现强制版本。比如,XXX项目的版本提交到1.0.0.134 后,想统一所有文件的版本为2.0.0.0上继续开发,CVS无法实现。
第三,CVS无法删除文件。如果你提交文件到服务器上以后,想再删除,不可能!
所以,重新搭设了SVN服务器。据说是CVS的替代者,使用起来也很容易,界面友好,但还有很多外围的软件需要开发。比如SVN关联文件的清理:
1.制作背景:
从SVN服务器上check out 工程文件之后,工程文件会产生关联文件,这对于追踪版本是必不可少的。但是,有时当我们需要将工程文件发送给其他人,或者拷贝到其他电脑上等等,此时我们并不想将工程文件夹内的关联文件一并发送,需要将目录下的_svn(或者.svn)文件手动地逐一删除。制作此程序就是为了方便清理关联文件.
2.程序实现方法:
遍历工程文件下的所有文件和文件目录,如果是_svn(.svn)目录,则将该目录下的所有文件删除,并且删除_svn(.svn)目录;如果是其他目录,则通过递归,继续删除该目录下存在的_svn(.svn)目录及目录下的所有文件。
3.存在的问题:
基本功能已经实现,但是_svn(.svn)目录无法删除,这可能与TSVNCache.exe进程有关。
从SVN服务器上check out 工程文件之后,工程文件会产生关联文件,这对于追踪版本是必不可少的。但是,有时当我们需要将工程文件发送给其他人,或者拷贝到其他电脑上等等,此时我们并不想将工程文件夹内的关联文件一并发送,需要将目录下的_svn(或者.svn)文件手动地逐一删除。制作此程序就是为了方便清理关联文件.
2.程序实现方法:
遍历工程文件下的所有文件和文件目录,如果是_svn(.svn)目录,则将该目录下的所有文件删除,并且删除_svn(.svn)目录;如果是其他目录,则通过递归,继续删除该目录下存在的_svn(.svn)目录及目录下的所有文件。
3.存在的问题:
基本功能已经实现,但是_svn(.svn)目录无法删除,这可能与TSVNCache.exe进程有关。
int CSVNCLEANDlg::DeleteSVN(CString strPath)
...{
CString strFile;
strFile.Format( "%s/*.*" , strPath );
CFileFind finder;
BOOL bWorking = finder.FindFile(strFile);
while (bWorking)
...{
bWorking = finder.FindNextFile();
// skip . and .. files; otherwise, we'd
// recur infinitely!
if (finder.IsDots())
continue;
// if it's a directory, recursively search it
if (finder.IsDirectory())
...{
CString str = finder.GetFileName();
if ( str == "_svn" || str == ".svn" )
...{//SVN目录
CString strTemp;
strTemp.Format( "%s/%s" , strPath , str );
AllDelete( strTemp );
}
else
...{
CString strTemp;
strTemp.Format( "%s/%s" ,m_strFolder, str );
DeleteSVN( strTemp );
}
//pBox->InsertString( iIndex , str );
//iIndex++;
}
}
finder.Close();
return 0;
}
void CSVNCLEANDlg::AllDelete(CString strPath)
...{
CFileFind ff;
CString path = strPath;
if ( path.Right(1) != "/")
...{
path += "/";
}
path += "*.*";
BOOL res = ff.FindFile( path );
while (res)
...{
res = ff.FindNextFile();
if ( !ff.IsDots() && !ff.IsDirectory() )
...{
SetFileAttributes( ff.GetFilePath() , FILE_ATTRIBUTE_NORMAL );
if ( DeleteFile(ff.GetFilePath()) == 0 )
...{
TRACE("删除%s 失败 " , ff.GetFilePath() );
}
}
else if( ff.IsDots() )
...{
continue;
}
else if( ff.IsDirectory() )
...{
path = ff.GetFilePath();
AllDelete( path );
SetFileAttributes( ff.GetFilePath() , FILE_ATTRIBUTE_NORMAL );
if ( RemoveDirectory( path ) == 0 )
...{
TRACE("删除%s 失败 " , ff.GetFilePath() );
}
}
}
SetFileAttributes(strPath, FILE_ATTRIBUTE_NORMAL);
RemoveDirectory(strPath);
//DWORD nCode = GetLastError();
}
...{
CString strFile;
strFile.Format( "%s/*.*" , strPath );
CFileFind finder;
BOOL bWorking = finder.FindFile(strFile);
while (bWorking)
...{
bWorking = finder.FindNextFile();
// skip . and .. files; otherwise, we'd
// recur infinitely!
if (finder.IsDots())
continue;
// if it's a directory, recursively search it
if (finder.IsDirectory())
...{
CString str = finder.GetFileName();
if ( str == "_svn" || str == ".svn" )
...{//SVN目录
CString strTemp;
strTemp.Format( "%s/%s" , strPath , str );
AllDelete( strTemp );
}
else
...{
CString strTemp;
strTemp.Format( "%s/%s" ,m_strFolder, str );
DeleteSVN( strTemp );
}
//pBox->InsertString( iIndex , str );
//iIndex++;
}
}
finder.Close();
return 0;
}
void CSVNCLEANDlg::AllDelete(CString strPath)
...{
CFileFind ff;
CString path = strPath;
if ( path.Right(1) != "/")
...{
path += "/";
}
path += "*.*";
BOOL res = ff.FindFile( path );
while (res)
...{
res = ff.FindNextFile();
if ( !ff.IsDots() && !ff.IsDirectory() )
...{
SetFileAttributes( ff.GetFilePath() , FILE_ATTRIBUTE_NORMAL );
if ( DeleteFile(ff.GetFilePath()) == 0 )
...{
TRACE("删除%s 失败 " , ff.GetFilePath() );
}
}
else if( ff.IsDots() )
...{
continue;
}
else if( ff.IsDirectory() )
...{
path = ff.GetFilePath();
AllDelete( path );
SetFileAttributes( ff.GetFilePath() , FILE_ATTRIBUTE_NORMAL );
if ( RemoveDirectory( path ) == 0 )
...{
TRACE("删除%s 失败 " , ff.GetFilePath() );
}
}
}
SetFileAttributes(strPath, FILE_ATTRIBUTE_NORMAL);
RemoveDirectory(strPath);
//DWORD nCode = GetLastError();
}
- 在Windows下清理SVN关联文件
- windows svn右键清理.svn文件
- Windows下清理svn的批处理命令
- Windows XP下如何清理日志文件
- 浅谈Windows下SVN在Android Studio中的配置、基本使用及解除关联
- 清理svn文件
- SVN在Windows下安装
- SVN在Windows下安装
- SVN在Windows下安装
- windows下python ide关联.py文件
- Windows下清理磁盘
- 在windows下关联py文件到IDLE直接打开并可调试的方法
- 清理Mac中svn文件
- 取消SVN关联文件
- 在Linux及在Windows下删除文件夹中包含的.svn文件的方法
- Windows下批量删除.svn文件
- Windows下批量删除.svn文件
- Windows下svn重命名文件大小写
- 页面特殊字符 处理总结
- chm文件无法显示问题解决一法
- ASP.NET-ASP.NET 中如何防范SQL注入式攻击
- Rational ClearCase 权限要求的Tirgger
- 函数声明、函数指针、指针函数
- 在Windows下清理SVN关联文件
- Java中的super()
- net打包自动安装数据库! (转载)
- 关于atm错出钞票的感想
- Asp.Net细节性问题技巧精萃
- EasyJWeb1.0新特性抢先看-全
- 一生中,这八种朋友是必不可少的
- Tomcat 5 下文字乱码问题
- mysql 数据同步配置