Subversion - 处理代码生成 [英] Subversion - dealing with code generation

查看:22
本文介绍了Subversion - 处理代码生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个要与 Subversion 一起使用的 Web 应用程序框架.我们之前已经尝试了几次来设置它,但是我们应用程序的代码生成部分导致了问题.

We have a web application framework that we want to use with Subversion. We've tried a couple of times before to set it up, but the code generation part of our application is causing problems.

问题在于,一个开发人员生成的代码可能位于比另一个开发人员新的文件中,但新文件的内容可能更旧,因为作为代码生成基础的代码和 xml 文件具有已由开发人员 nr2 更新.

The problem is that the generated code from one developer can be in a newer file than from another developer, but the content of the newer file can be older, because the code and xml files that are the basis for the code generation has been update by developer nr2.

我们看过的一个解决方案是排除代码生成的文件,但是我们经常会得到新生成的文件,它们会自动添加到存储库中,除非我们记得要排除它,而且我们必须手动签入最新生成的文件.你怎么知道你是否有最新生成的文件?

One solution we've looked at is to exclude the code generated files, but we often get new files that are generated, and they are automatically added to the repository unless we remember to exclude it, and we have to manually check in the latest generated files. And how do you know if you have the latest generated file?

有关如何在 Subversion 中解决此问题的任何建议?

Any suggestion on how to solve this in Subversion?

推荐答案

决定某些东西是否应该在 Subversion 中的最好方法是记住它是一个版本控制系统.如果您不需要记住它是如何随时间变化的,则不需要在 svn 中. 使用 svn:ignore 将文件排除在此类考虑之外.

The best way to decide to whether something should be in Subversion is to remember that it's a version control system. If you don't need to remember how it changed over time, it doesn't need to be in svn. Use svn:ignore to exclude files from such consideration.

这里就是这种情况:您不关心生成的文件如何随时间变化,只关心用于生成它们的原始代码.这意味着它们应该被排除在 Subversion 之外.您可以使用 pre-commit hook 来执行此操作——例如,强制所有代码生成的文件都不应提交.我最喜欢这种策略的一句话:版本化食谱,而不是蛋糕."

That's the case here: you don't care how the generated files changed over time, only the original code used to produce them. That means they should be excluded from Subversion. You can do this with a pre-commit hook -- enforcing, for example, that all code-generated files shouldn't ever be committed. I have a favorite phrase for this tactic: "Version the recipe, not the cake."

你怎么知道你是否有最新生成的文件?

And how do you know if you have the latest generated file?

正是;你没有,因为生成的文件依赖于用于创建它们的源.您的下一步是确保您的构建过程在给定初始源代码的情况下自动生成这些文件,但如果您还不知道如何执行此操作,这可能是一个单独的 StackOverflow 问题.

Exactly; you don't, because the generated files were dependent on the source used to create them. Your next step is to make sure that your build process automatically generates these files given the initial source code, but that's probably a separate StackOverflow question if you don't know how to do that already.

这篇关于Subversion - 处理代码生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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