給Asp.Net項目應用SVN版本控制時,需要把SVN元數據文件夾由.svn改名為_svn,該了SVN客戶端的設置之后,原有工程不會自動轉換.如果工程特別大,而且文件夾嵌套特別多那么,可以考慮用下面的python進行轉換:
1
#Author : Vulcan Alva.yi@gmail.com
2
import os
3
import sys
4
from os.path import join
5
'''
6
A script for svn meta directory convert from .svn to _svn
7
'''
8
def 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
24
if __name__ == "__main__":
25
convert()

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25
