从 Subversion 迁移到 Mercurial - 如何调整工作流程和暂存/集成系统?

发布于 2024-09-10 13:13:07 字数 994 浏览 0 评论 0原文

我们对从 svn 到 hg 感到兴奋不已,随着开发工作流程或多或少地被淘汰,这里仍然是最困难的部分 - 登台和集成系统。

希望这个问题比您常见的“我如何从 xxx 迁移到 Mercurial”更进一步。请原谅冗长且可能写得不好的问题:)

我们是一家网上商店,做很多项目(主要是 PHP 和 Zend),所以我们有一个巨大的 svn 存储库,有大约 100 多个文件夹,每个文件夹代表一个带有自己标签的项目,当然是树枝和树干。在我们的集成和测试服务器上(QA 和客户查看工作结果和测试内容),一切几乎都是自动化的 - Apache 设置为自动挑选新项目,为每个项目/主干创建虚拟主机; mysql 迁移脚本也位于主干中,开发人员可以通过简单的 Web 界面应用它们。长话短说,我们现在的工作流程是这样的:

  1. 签出代码,工作,提交
  2. 通过 Web 界面在服务器上运行更新(这基本上是在特定项目的服务器上执行 svn up,如果需要的话还运行数据库迁移脚本)
  3. QA 更改 。

当我们有 2 个以上的开发人员处理相同的代码时,这种方法对于大型项目来说肯定不是最佳的 svn 中的分支只会引起更多麻烦,因此转向 Mercurial。这就是问题所在 - 如何为此类工作组织高效的登台/集成/测试服务器(如果您有许多项目,比如单个开发人员可以在 1 天内处理 3 个不同的项目)。

我们决定让“默认”分支本质上跟踪生产,然后在各个分支中进行所有更改。在这种情况下,我们如何自动化每个分支的暂存更新?如果早期对于一个项目,我们几乎总是在主干上工作,那么我们需要一个数据库、一个虚拟主机等。现在我们可能会讨论每个项目的 N 个数据库、N 个虚拟主机配置等。那么 CI 的东西呢(例如运行 phpDocumentor 和/或单元测试)?应该只在“默认”下完成吗?在树枝上?

我想知道其他团队如何解决这个问题,也许是我们没有使用或忽略的一些最佳实践?

附加说明:

可能值得一提的是,我们选择 Kiln 作为存储库托管服务(主要是因为我们无论如何都在使用 FogBugz)

We got all psyched about from from svn to hg and as the development workflow is more or less flushed out, here remains the most difficult part - staging and integration system.

Hopefully this question goes a bit further then your common 'how do I move from xxx to Mercurial'. Please forgive long and probably poorly written question :)

We are web shop that does a lot of projects(mainly PHP and Zend), so we have one huge svn repo, with like 100+ folders, each representing a project with it's own tags,branches and trunk of course. On our integration and testing server(where QA and clients look at work results and test stuff) everything is pretty much automated - Apache is set to pick up new projects automatically creating vhost for each project/trunk; mysql migration scripts right there in trunk too and developers can apply them through simple web-interface. Long story short our workflow is this now:

  1. Checkout code, do work, commit
  2. Run update on the server via web interface(this basically does svn up on server on a particular project and also run db-migration script if needed)
  3. QA changes on the server

This approach is certainly suboptimal for large projects when we have 2+ developers working on the same code. Branching in svn was only causing more headaches, well, hence moving to Mercurial. And here is where the question lies - how does one organize efficient staging/integration/testing server for this type of work(where you have many projects, say single developer could be working on 3 different projects in 1 day).

We decided to have 'default' branch tracking production essentially and then make all changes in individual branches. In this case though how can we automate staging updates for each branch? If earlier for one project we almost always were working on trunk, so we needed one DB, one vhost, etc. now we potentially talking about N-databases per project, N-vhost configs and etc. Then what about CI stuff(such as running phpDocumentor and/or unit tests)? Should it only be done on the 'default'? On branches?

I wonder how other teams solve this issue, perhaps some best practices that we're not using or overlooking?

Additional notes:

Probably worth mentioning that we've picked Kiln as a repo hosting service(mostly since we're using FogBugz anyway)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光是把杀猪刀 2024-09-17 13:13:07

这绝不是您最终选择的完整答案,但这里有一些可能会影响其中的工具:

  • 没有工作目录的存储库 - 如果您clone -Uhg update null 您将获得一个没有工作目录(只有 .hg)的存储库。它们在服务器上效果更好,因为它们占用的空间更少,而且没有人愿意编辑
  • changegroup 挂钩

对于最后一个,每当一个或多个变更集时,changegroup 挂钩都会运行通过推或拉到达,您可以让它做一些有趣的事情,例如:

  • 根据到达的内容将变更集推送到另一个存储库
  • 更新接收存储库的工作目录

例如,可以仅使用上述工具来自动化类似的操作:

  1. 开发人员将五个变更集推送到central-repo/project1/main
  2. 最后一个变更集位于分支“my-experiment”上,因此csets会自动重新推送到可选创建的存储库central-repo/project1/my-experimentcentral-
  3. repo/project1/my-实验会自动执行 hg update Tip ,该提示肯定位于 my-expiriment 分支
  4. central-repo/project1/my-experiment 会自动在其工作目录中运行测试,如果它们pass 会执行一个“make dist”部署,这也可能会设置数据库和虚拟主机。

最重要的是,mercurial 书中的第 10 章介绍了这一点,就是不让用户等待该过程。您希望用户推送到包含可能没问题的代码的存储库,并自动处理完成 CI 和部署工作,如果通过,最终将成为可能没问题的存储库。

在我工作过的最大的 Mercurial 设置中(大约 20 名开发人员),我们的 CI 系统(Hudson)定期从每个可能还可以的存储库中提取,然后构建和测试,并分别处理每个分支。

底线:设置您想要的任何内容所需的所有工具可能已经存在,但将它们粘合在一起将是一次性的工作。

This is by no means the complete answer you'll eventually pick, but here are some tools that will likely factor into it:

  • repositories without working directories -- if you clone -U or hg update null you get a repository with no working directory (only the .hg). They're better on the server because they take up less room and no one is tempted to edit there
  • changegroup hooks

For that last one the changegroup hook runs whenever one or more changesets arrive via push or pull and you can have it do some interesting things such as:

  • push the changesets on to another repo depending on what has arrived
  • update the receiving repo's working directory

For example one could automate something like this using only the tools described above:

  1. developer pushes five changesets to central-repo/project1/main
  2. last changeset is on branch 'my-experiment' so csets are automatually re-pushed to optionally created repo central-repo/project1/my-experiment
  3. central-repo/project1/my-experiment automatically does hg update tip which is certain to be on the my-expiriment branch
  4. central-repo/project1/my-experiment automatically runs tests in its working dir and if they pass does a 'make dist' that deploys, which might set up database and vhost too

The biggie, and chapter 10 in the mercurial book covers this, is to not have the user waiting on that process. You want the user to push to a repo that contains possibly-okay-code and the automated processed do the CI and deploy work, which if it passes ends up being a likely-okay repo.

In the largest mercurial setup in which I've worked (20 or so developers) we got to the point where our CI system (Hudson) was pulling from the maybe-ok repos for each periodically then building and testing, and handling each branch separately.

Bottom line: all the tools you need to setup whatever you'd like probably already exist, but gluing them together will be one-off sort of work.

渔村楼浪 2024-09-17 13:13:07

您需要记住的是 DVCS(与 CVCS ) 引入了版本控制的另一个维度:
您不必再依赖分支(并从正确的分支获取暂存工作区)
现在,您可以通过 DVCS 获得发布工作流程(存储库之间的推/拉)

意味着您的临时环境现在是一个存储库(具有项目的完整历史记录),在某个分支签出:
许多开发人员可以将许多不同的分支推送到该临时存储库:协调过程可以在该存储库内、您选择的“主”分支中独立完成。
或者他们可以将临时分支拉到他们的存储库中并在推迟之前进行测试。

替代文本
来自 Joel 的 Mercurial 教程HgInit

开发人员不必提交给其他人看:DVCS 中的发布过程允许他/她首先拉取临时分支,在本地协调任何冲突,并且然后推送到临时存储库。

What you need to remember is that DVCS (vs. CVCS) introduces another dimension to versioning:
You don't have to rely anymore only on branching (and get a staging workspace from the right branch)
You now have with DVCS the publication workflow (push/pull between repo)

Meaning your staging environment is now a repo (with the full history of the project), checked out at a certain branch:
Many developers can push many different branches to that staging repo: the reconciliation process can be done in isolation within that repo, in a "main" branch of your choice.
Or they can pull that staging branch in their repo and test things out before pushing back.

alt text
From Joel's tutorial on Mercurial HgInit

A developer don't necessary have to commit for other to see: the publication process in a DVCS allows for him/her to pull the staging branch first, reconcile any conflict locally, and then push to the staging repo.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文