svn 自动提交丢失的文件 [英] svn commit missing file automatically

查看:66
本文介绍了svn 自动提交丢失的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个可以递归自动提交丢失文件的批处理文件.批处理命令怎么写?请帮忙.

解决方案

以下批处理脚本应 SVN 删除并提交所有标记为丢失的文件(即在本地删除但未使用 SVN 删除):

@echo offsvn 状态 |findstr/R "^!">遗失清单for/F "tokens=2 delims=" %%A in (missing.list) do (svn 删除 %%A &&svn -q commit %%A --message "删除丢失的文件")

丢失的文件用svn status加上字符!表示,例如:

<前>!测试.txt

此脚本然后使用 findstr 过滤掉除丢失文件之外的任何修改.然后将此丢失文件列表写入文件 missing.list.

接下来,我们遍历这个文件,使用 tokens=2 delims= 从文件中的行中删除 !,让我们(希望)只剩下文档名称.获得文件名后,我们将其传递给 svn deletesvn commit.随意更改邮件内容.

请注意,我没有测试过这个脚本.特别是,我不知道如果您希望提交的文件之一在其路径中有空格会发生什么,或者如果您在途中遇到冲突会发生什么.将 svn deletesvn commit 替换为 echo svn deleteecho svn commit 可能会更好,以便在您将它放到您的存储库中之前,您可以看到该脚本将要执行的操作.

I want to write a batch file that can auto commit missing file recursively. how to write the batch command? please helps.

解决方案

The following batch script should SVN delete and commit all files marked as missing (i.e. deleted locally but not using SVN delete):

@echo off
svn status | findstr /R "^!" > missing.list
for /F "tokens=2 delims= " %%A in (missing.list) do (
    svn delete %%A && svn -q commit %%A --message "deleting missing files")

Missing files are shown by svn status with the character !, for example:

!      test.txt

This script then uses findstr to filter out any modifications other than missing files. This list of missing files is then written to a file, missing.list.

Next, we iterate through this file, using tokens=2 delims= to remove the ! from the lines in the file, leaving us with (hopefully) just the filename. Once we have the filename, we pass it to svn delete and then svn commit. Feel free to change the contents of the message.

Please note that I have not tested this script. In particular, I don't know what happens if one of the files you wish to commit has a space in its path, or what happens if you encounter a conflict part of the way through. It may be better to replace svn delete and svn commit with echo svn delete and echo svn commit, so that you can see what this script is about to do before you let it loose on your repository.

这篇关于svn 自动提交丢失的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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