如何为每个已提交此文件的提交更新未修改文件中的修订号?
我的 SVN 项目中有一个 revision.txt 文件。
基本上,我希望当我使用提交后工作副本将具有的修订号调用 svn ci 时,该文件会自动更新。
例如:
- revision.txt 包含“10”
- 我对我的工作副本(其他文件,而不是 revision.txt)进行了一些更改
- svn ci
- 启动钩子脚本
- 阅读下一个版本号
- 更新 revision.txt
- 提交更改(还有 revision.txt)
- 现在revision.txt已经提交,修订号为11
我尝试使用钩子脚本但没有成功。我无法在提交之前检索下一个修订号并更新事务。
然后尝试使用“auto-props”,但它们仅适用于修改后的文件。 更好的解决方案是仅使用钩子脚本,而不使用检查修订和更新的包装器脚本。
有可能吗?欢迎举例
I have a revision.txt file in my SVN project.
Basically I want that this file is updated automatically when I call svn ci with the revision number the working copy will have after the commit.
For example:
- revision.txt contains "10"
- I make some change to my working copy (other files, not revision.txt)
- svn ci
- launch hook script
- read next revision number
- update revision.txt
- commit changes (also revision.txt)
- now revision.txt is already committed with revision number 11
I've tried without success with an hook script. I cannot retrieve the next revision number and update the transactione before committing.
Then try with "auto-props", but they are working only with modified files.
The preferable solution is using only hook script and not using a wrapper script which check the revision and update.
Is possible ? Examples are welcome
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于竞争条件,您无法在提交之前猜测下一个修订号 - 您无法保证,直到事后,其他人没有在您之前进入。在 svn commit hook 中更改文件也是一种极其糟糕的形式 - 工作副本全部过时且混乱,因为它们只从服务器得到“它工作了”或“它失败了”,从来没有“它工作了,但是通过该文件现在具有这些内容的方式......”
您需要这个做什么?也许还有另一种方法可以实现您想要实现的目标。
您可以使用“svn 在需要之前自动生成 revision.txt 文件info”,并将“修订:”行过滤到文件中。
You can't guess the next revision number before commit due to race conditions - you can't guarantee, until after the fact, that someone else hasn't got in ahead of you. It's also extremely bad form to change files in a svn commit hook - working copies get all out of date and messy, as they only get a "it worked" or "it failed" from the server, never a "it worked, but by the way that file now has these contents ..."
What do you need this for? Perhaps there's another way to get what you're trying to achieve.
You could auto-generate the revision.txt file just before it's needed by using "svn info", and filtering the "Revision: " line into the file.
正如您已经提到的,基于 svn:keywords 只能更改已修改的文件。但我认为您需要的是一个处理此类信息的构建系统(可能是构建服务器/持续集成服务器)。
As you already mentioned based on svn:keywords it's only possible to change modified files. But i think what you need is a build system which handles such kind of information (may be a build server / continous integration server).
关键字替换最接近你想要的,但这也不起作用,因为它给你的是文件的最后修改,而不是项目的最后修改。来自关于此问题的颠覆常见问题解答:
Keyword substitution comes closest to what you want, but that doesn't really work either because it gives you the last modification of the file, not of the project. From the subversion FAQ on this issue: