给Asp.Net项目应用SVN版本控制时,需要把SVN元数据文件夹由.svn改名为_svn,该了SVN客户端的设置之后,原有工程不会自动转换.如果工程特别大,而且文件夹嵌套特别多那么,可以考虑用下面的python进行转换:
1#Author : Vulcan Alva.yi@gmail.com
2import os
3import sys
4from os.path import join
5'''
6A script for svn meta directory convert from .svn to _svn
7'''
8def convert ():
9 os.chdir("d:\\workbench\\csx_webframe") #change to your own work directory which need convert
10 for root, dirnames, files in os.walk("."):
11 print "Current Directory:" + root
12 if "_svn" in dirnames:
13 print "Don't need convert for this directory."
14 break
15 #dirnames.remove("_svn")
16 #continue
17 if ".svn" in dirnames: #don't go to this directory
18 dirnames.remove(".svn")
19 newname = join(root, '_svn')
20 oldname = join(root, '.svn')
21 print "Change meta dir to :" + newname
22 os.rename(oldname, newname)
23
24if __name__ == "__main__":
25 convert()