有没有办法防止代码注释被标记为从版本控制获得的差异中的更改? (CVS/SVN)
有没有办法防止代码注释被标记为从版本控制获得的差异中的更改? (CVS/SVN) 我讨厌显示 100 个更改的差异,而实际上由于 CVS 信息(如日志或 id)的注释中的更新而只有少数更改。
Is there a way to prevent code comments to be marked as changes in the diffs obtained from version control? (CVS/SVN) I hate the differences showing 100's of changes when there are only a handful due to the update in the comments for CVS info like log or id.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您怎么能期望源代码控制系统存储文件的新版本,然后忽略它已存储新版本的事实呢?
How could you expect a source control system to store a new version of the file and then ignoring the fact it has stored a new version?
注释本身将被视为更改 - 但是,您可以在提交到主干之前通过某种代码美化器运行代码(根据您自己的规则删除注释或其他内容),然后主干之间的差异将仅显示代码更改,而不是比上面的评论还要多。
Comments themselves would be counted as changes - however you could run the code through a code beautifier of sorts (to remove comments or other things according to your own rules) before committing to trunk, and then the diff between trunks would only show code changes rather than the comments on top of it.
我不这么认为。因为 SVN 不/无法理解文件中的内容。它只是向您显示文件中的内容。
I dont think so. Because SVN doesn't/can't understand what is into a file. It just show you what is into the file.
我使用像 Beyond Compare 这样的 diff 程序,它可以忽略空格和注释更改,但仅限于进行 diff 时。但是,如果文件确实发生了更改,那么大多数 vcs 都会将其列在其更改列表中。在 SVN 中,您可以设计一个提交钩子,根据您的规则检测 chagne 是否“重要”。如果 chagne 不是,那么它可以拒绝提交。
I use a diff program like Beyond Compare that can ignore whitespace and comment changes, but only when doing diffs. However if the file actually changed, then most vcs would list that in their changelist. In SVN you could engineer a commit hook that detects if a chagne is "significant" according to your rules. It could then reject the commit if the chagne is not.
这可能归结为回答另一个问题:
源文件上的历史日志和文件 ID 等版本控制信息有用吗?
It might come down to answering another question:
Is it useful to have versioning information like history log and file ID on the source file?