如何从 SVN 中删除现有的更改列表 [英] how do I remove an existing changelist from SVN

查看:79
本文介绍了如何从 SVN 中删除现有的更改列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过执行...创建了一个更改列表

I created a changelist by doing...

$ svn changelist my_changes

...向其中添加文件,然后提交更改列表...

... added files to it, and then committed the changelist...

$ svn ci --changelist my_changes --keep-changelists

...所以现在,我保留"了我的更改列表,并且每次查看状态时都会显示它.

... so now, I have "kept" my changelist and it shows up every time I view status.

$ svn status
... modified/added/deleted files listed here...

--- Changelist 'my_changes':
... files that are a part of this changelist listed here...

我出于某种原因保留"了更改列表,但我不再需要它,所以我准备将其删除.如何从 SVN 中删除此更改列表?我知道如何从变更列表中删除文件,但不知道如何从变更列表中删除.

I "kept" the changelist for a reason, but I don't need it anymore so I'm ready to remove it. How do I remove this changelist from SVN? I know how to remove files from the changelist, but not the changelist itself.

推荐答案

从变更列表中删除所有关联的文件,它就会消失.

Remove all the associated files from a changelist and it'll disappear.

https://stackoverflow.com/a/15992735/253468

svn changelist --remove --recursive --cl my_changes .

手动方式

svn 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:找到changelist并取CL标题后的输出,直到下一个CL或svn status的输出结束
  • grep:从缓冲区中删除 CL 标题
  • awk:删除文件状态,只保留文件名(即第二列)
  • xargs: 把每一行作为 svn changelist
    的参数(如果文件名中有空格或特殊字符,可能需要调整)
  • svn status: output all the modified files
  • sed: find the changelist and take the output after the CL title until the next CL or the end of svn status's output
  • grep: remove the CL titles from the buffer
  • awk: remove the file statuses, keep only the filenames (i.e. the second column)
  • xargs: put each line as an argument to svn changelist
    (may need tweaks if you have spaces or special characters in the filenames)
~/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

这篇关于如何从 SVN 中删除现有的更改列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆