从更改列表中删除所有相关文件,它就会消失。
官方方式
见https://stackoverflow.com/a/15992735/253468
svn changelist --remove --recursive --cl my_changes .
手动方式
IEsvn changelist --remove file.name
D:\Programming>mkdir test
D:\Programming>cd test
D:\Programming\test>svnadmin create .
D:\Programming\test>svn co file:///D:\Programming\test co
Checked out revision 0.
D:\Programming\test>cd co
D:\Programming\test\co>echo "hello" > test.file
D:\Programming\test\co>svn add test.file
A test.file
D:\Programming\test\co>svn status
A test.file
D:\Programming\test\co>svn changelist mycl test.file
A [mycl] test.file
D:\Programming\test\co>svn status
--- Changelist 'mycl':
A test.file
D:\Programming\test\co>svn changelist --remove test.file
D [mycl] test.file
D:\Programming\test\co>svn status
A test.file
Bash 中的自动化
# Remove all files from a specific CL
# Usage: svn_remove_cl my_changes
function svn_remove_cl() {
svn status |\
sed -n "/--- Changelist '$1':/,/--- Changelist.*/p" |\
grep -v '^--- Changelist' |\
awk '{print $2}' |\
xargs svn changelist --remove
}
解释:
svn status
: 输出所有修改过的文件
sed
: 找到更改列表并在 CL 标题之后获取输出,直到下一个 CL 或svn status
输出的结尾
grep
:从缓冲区中删除 CL 标题
awk
:删除文件状态,只保留文件名(即第二列)
xargs
:将每一行作为参数svn changelist
(如果文件名中有空格或特殊字符,可能需要调整)
示例运行
~/tmp/wc$ svn status
A d
--- Changelist 'cl_a':
A a
A e
A f
--- Changelist 'cl_x':
A b
A c
~/tmp/wc$ svn_remove_cl cl_x
Path 'b' is no longer a member of a changelist.
Path 'c' is no longer a member of a changelist.
~/tmp/wc$ svn status
A b
A c
A d
--- Changelist 'cl_a':
A a
A e
A f