简体   繁体   English

如何编写批处理文件以进行svn提交和更新

[英]How to write a batch file for svn commit and update

so far I have used Tortoise SVN to commit and update folders under version control. 到目前为止,我已经使用Tortoise SVN在版本控制下提交和更新文件夹。 When I commit I check "all" in the GUI dialog so that deletions as well as additions are committed. 当我提交时,我在GUI对话框中选中“全部”,以便删除和添加。

Now I have more and more folders under version control and I would like to have a batch file for committing and updating all of them. 现在,我拥有越来越多的受版本控制的文件夹,并且我想拥有一个批处理文件来提交和更新所有这些文件夹。

So far I have experimented with the command line and found this: 到目前为止,我已经在命令行上进行了实验,发现了这一点:

svn add . --force
svn commit -m"Adding missing files"

This adds new files but does not reflect any deletions. 这将添加新文件,但不反映任何删除。

Could you please help me with the batch files? 您能帮我处理批处理文件吗? It would make my work a lot easier but I am really too unexperienced with SVN/batch files to do this on my own... 这会使我的工作变得容易得多,但是我对SVN /批处理文件实在是太没有经验了,无法独自执行此操作...

I use Win7x64 and Tortoise SVN 1.7.12 with the command line extension. 我在命令行扩展中使用Win7x64和Tortoise SVN 1.7.12。

Thank you! 谢谢!

I think I figured something out using gammay's and this input: 我想我用gammay和这个输入想出了一些东西:

cd "C:\Users\User\Desktop"
for /f "usebackq tokens=2*" %%i in (`svn status ^| findstr /r "^\?"`) do svn add "%%i %%j"
for /f "usebackq tokens=2*" %%i in (`svn status ^| findstr /r "^\!"`) do svn delete "%%i %%j"
svn commit -m "Commit via Batch"

And

cd "C:\Users\User\Desktop"
svn update

and repeatedly for different paths! 并反复寻找不同的路径!

Thank you :) 谢谢 :)

Firstly, which svn command line tools do you use? 首先,您使用哪些svn命令行工具? You can use CollabNet for 'svn' commands. 您可以将CollabNet用于“ svn”命令。

Secondly, to delete files, you need to checkout existing files from svn, then use svn delete and then svn commit. 其次,要删除文件,您需要从svn中检出现有文件,然后使用svn delete和svn commit。

Your question is not clear - if this doesn't answer your question, please provide a few more details. 您的问题尚不清楚-如果这不能回答您的问题,请提供更多详细信息。


Edited to answer asker's requirement (in comments below): OK. 编辑以回答提问者的要求(在下面的评论中):确定。 What you want is a script which will find the new files in the folder and add them to SVN automatically and find deleted files in folder and delete them from SVN too. 您想要的是一个脚本,该脚本将在文件夹中找到新文件并将其自动添加到SVN中,并在文件夹中找到已删除的文件并将它们也从SVN中删除。 I can tell you this is a dangerous as undesired files can get added/deleted. 我可以告诉您,这是很危险的,因为不需要的文件可以被添加/删除。

Still, if you want to go ahead with this script this is what the script can do: 不过,如果您想继续使用此脚本,可以执行以下操作:

  • Run svn status which displays missing (deleted) files and unknown (to be added) files 运行SVN状态,显示丢失(已删除)的文件和未知(要添加)的文件
 ! FileA [Missing - deleted] ? FileD [Unknown - to be added] 
  • Parse the output to find the ! 解析输出以找到! files and run svn delete on these files 文件并在这些文件上运行svn delete
 svn delete FileA 
  • Parse the output to find the ? 解析输出以找到? files and run svn add on these files 文件,然后在这些文件上运行svn add
 svn add FileD 
  • svn commit
    • This commits the above deleted & added files and also any modifications. 这将提交以上已删除和添加的文件以及所有修改。
    • If you do not want to commit modifications, commit individual added/deleted files 如果您不想提交修改,请提交单个添加/删除的文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM