自动删除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))
它似乎做得很好。
这篇关于自动删除Subversion未版本控制的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文