自动删除 Subversion 未版本控制的文件 [英] Automatically remove Subversion unversioned files
本文介绍了自动删除 Subversion 未版本控制的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道递归删除工作副本中不受版本控制的所有文件的方法吗?(我需要这个来在我的自动构建 VMware 中获得更可靠的结果.)
Does anybody know a way to recursively remove all files in a working copy that are not under version control? (I need this to get more reliable results in my automatic build VMware.)
推荐答案
Subversion 1.9.0 引入了一个选项来执行此操作:
Subversion 1.9.0 introduced an option to do this:
svn cleanup --remove-unversioned
在此之前,我使用这个 python 脚本来做到这一点:
Before that, I use this python script to do that:
import os
import re
def removeall(path):
if not os.path.isdir(path):
os.remove(path)
return
files=os.listdir(path)
for x in files:
fullpath=os.path.join(path, x)
if os.path.isfile(fullpath):
os.remove(fullpath)
elif os.path.isdir(fullpath):
removeall(fullpath)
os.rmdir(path)
unversionedRex = re.compile('^ ?[?ID] *[1-9 ]*[a-zA-Z]* +(.*)')
for l in os.popen('svn status --no-ignore -v').readlines():
match = unversionedRex.match(l)
if match: removeall(match.group(1))
它似乎很好地完成了这项工作.
It seems to do the job pretty well.
这篇关于自动删除 Subversion 未版本控制的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文