简体   繁体   English

如何强制目录与Subversion服务器保持完全同步

[英]How to force a directory to stay in exact sync with subversion server

I have a directory structure containing a bunch of config files for an application. 我有一个目录结构,其中包含一堆应用程序的配置文件。 The structure is maintained in Subversion, and then a few systems have that directory struture checked out. 该结构在Subversion中维护,然后一些系统将目录结构检出。 Developers make changes to the struture in the repository, and a script on the servers just runs an "svn update" periodically. 开发人员对存储库中的结构进行了更改,并且服务器上的脚本仅定期运行“ svn更新”。

However, sometimes we have people who will inadvertently remove a .svn directory under one of the directories, or stick a file in that doesn't belong. 但是,有时我们有些人会无意间删除其中一个目录下的.svn目录,或者将不属于该目录的文件粘贴到其中。 I do what I can to cut off the hands of the procedural unfaithful, but I'd still prefer for my update script to be able to gracefully (well, automatically) handle these changes. 我尽我所能切断不忠实的程序,但我仍然希望我的更新脚本能够优雅地(自动地)处理这些更改。

So, what I need is a way to delete files which are not in subversion, and a way to go ahead and stomp on a local directory which is in the way of something in the repository. 因此,我需要的是一种删除不在Subversion中的文件的方法,以及一种以存储库中某种方式继续处理本地目录的方法。 So, warnings like 所以,警告像

Fetching external item into '/path/to/a/dir'
svn: warning: '/path/to/a/dir' is not a working copy

and

Fetching external item into '/path/to/another/dir'
svn: warning: Failed to add directory '/path/to/another/dir': an unversioned directory of the same name already exists

should be automatically resolved. 应该自动解决。

I'm concerned that I'll have to either parse the svn status output in a script, or use the svn C API and write my own "cleanup" program to make this work (and yes, it has to work this way; rsync / tar+scp, and whatever else aren't options for a variety of reasons). 我担心我将不得不解析脚本中的svn状态输出,或者使用svn C API并编写自己的“清理”程序来完成此工作(是的,它必须以这种方式工作; rsync / tar + scp,由于种种原因,其他都不是选项)。 But if anyone has a solution (or partial solution) which takes care of the issue, I'd appreciate hearing about it. 但是,如果有人有解决该问题的解决方案(或部分解决方案),我很高兴听到此消息。 :) :)

How about 怎么样

rm -rf $project
svn checkout svn+ssh://server/usr/local/svn/repos/$project

I wrote a perl script to first run svn cleanup to handle any locks, and then parse the --xml output of svn status, removing anything which has a bad status (except for externals, which are a little more complicated) 我编写了一个perl脚本,首先运行svn cleanup来处理所有锁,然后解析svn status的--xml输出,删除状态不佳的任何内容(外部组件除外,该组件稍微复杂一些)

Then I found this: http://svn.apache.org/repos/asf/subversion/trunk/contrib/client-side/svn-clean Even though this doesn't do everything I want, I'll probably discard the bulk of my code and just enhance this a little. 然后我发现了这一点: http : //svn.apache.org/repos/asf/subversion/trunk/contrib/client-side/svn-clean即使这并不能满足我的所有需求,我还是会丢弃大部分我的代码,只是将其增强一点。 My XML parsing is not as pretty as it could be, and I'm sure this is somewhat faster than launching a system command (which matters on a very large repository and a command which is run every five minutes). 我的XML解析不尽如人意,我敢肯定,这比启动系统命令要快一些(这在很大的存储库中很重要,并且每五分钟运行一次命令)。

I ultimately found that script in the answer to this question - Automatically remove Subversion unversioned files - hidden among all the suggestions to use Tortoise SVN. 我最终在该问题的答案中找到了该脚本- 自动删除Subversion未版本化的文件 -隐藏在所有使用Tortoise SVN的建议中。

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

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