Mercurial - 我可以做得更好吗?
我们已经使用 Mercurial 几个月了,它已经极大地改进了我们的部署流程。这是好的部分。
我们现有的系统正在运行,但如果您不小心或仓促,它仍然容易出错。这让我想知道是否有办法改进它,或者......也许我们完全偏离了轨道:)
我们的环境包括:
- 本地开发工作站(每个开发人员)
- 开发服务器(托管数据库和中央存储库
- )验收服务器(完成 QA)
- 临时服务器(我们暂存发布分支,然后自动复制到实时系统)
关于我们切换原因的一些背景知识:
我们所处的工作环境经常让我们从任务切换任务,留下许多悬而未决的任务。当我们回到 CVS 时,许多内容会变得陈旧并弄乱主分支。部署是一场噩梦,因为您必须围绕需要上线的线路和其他未使用 Beyond Compare 的线路进行工作。
Mercurial 的命名分支和轻松合并为我们解决了这个问题。所以不知道会发生什么,我们就设置了它。
首先,我们清理了我们的生产源,修剪了死文件等。
我们在登台时通过 FTP 进行了处理,并将其作为我们的新存储库作为“默认”,这是我们随时可以部署的稳定分支。
之后,我们对开发服务器进行了 hg 克隆
,并让每个开发人员从开发默认分支中进行了 hg 克隆
。
在我们进行 QA 的地方验收后,我们对开发服务器的默认分支进行了 hg 克隆
。
至此我们已经有了到处都有稳定的代码副本,大家都跃跃欲试了!
本地计算机推送到开发人员,从开发人员拉动接受,并且登台是完全隔离的,如果提供了路径,则可以从任何地方拉取。
现在,这背后的想法是,我们系统上的默认分支将始终是实时服务器上代码的副本,前提是我们记得在启动新分支之前拉取。当开始一项新功能时,我们会:
hg pull -b default #synch up
hg update default
hg branch {newFeature} #newFeature completely isolated from other changes.
*work on {newFeature}
哦不!一个错误!这与我目前正在做的事情无关,我们称之为{bugFix111}。这似乎需要一个独立于我的功能的新分支;返回到更新后的默认值。这会将 newFeature 和 bugFix111 相互隔离,并且每个都可以独立运行,因为它们基于默认值。
hg update default
hg pull -u
hg branch {bugFix111}
一旦工作完成,如{bugFix111}
hg push -F {bugFix111} #send our fix to the main central repo on dev.
转到验收:
hg pull -b {bugFix111} #pull the fix from the central repo (dev).
hg merge {bugFix111} #merge the code in the default QA branch.
hg commit -m "Merging {bugFix111} into default"
*QA sign off on the fix
我们必须分支验收 - 默认情况下进行 QA 并发布,我们在签名时合并内容离开。
hg update release
hg merge {bugFix111} #fix is now ready to go live
hg commit -m "Merging {bugFix111} into release"
关于登台:
hg pull -b release {PATH TO ACCEPTANCE REPO}
hg merge release
hg commit -m "Merging {bugFix111} into staging default"
hg tag release{date}
*robocopy to live
*run task that pull from staging to dev so that they synch up again.
这对我们很有用,并节省了一些部署时间,因为只需机器人复制稳定版本分支就很容易。
问题
我们注意到的是:
在发布时第二次合并时很容易搞砸合并,这似乎违背了流程。我们可以在 QA 签署后打破它。
也可以让 QA 来测试我们的发布分支,但这似乎是重复的资源,目标只是隔离功能并能够一次发送一个。
我们可以通过合并版本来完全摧毁它,例如,当您默认接受时,hg合并版本会完全覆盖它。
如果我们在开始新分支之前忘记拉取,我们就会在错误的基础上工作。
几乎没有其他奇怪的地方,但这些是最大的障碍。
我意识到这是一篇很长的文章,但希望答案能帮助像我这样的其他 Mercurial 新手在他们的公司建立一个像样的工作流程。
We've been using Mercurial for a couple of months now and it's improved our deployment process A LOT already. This is the good part.
The system we have in place is working but it's still error prone if you're not careful or rushing. This leave me wondering if there's ways we could improve it or... maybe we're completely off the track :)
Our environment consist of:
- Local development workstation (each developer)
- Development server (hosting the DB & the central repository)
- An acceptance server (Where QA is done)
- A staging server (Where we stage the release branch, we then robocopy to the live systems)
A little background on the reason why we switched:
We are in a work environment that often have us switching from task to task, leaving many pending tasks. Many would become stale and clutter up the main branch when we were back on CVS. Deployment was a nightmare as you had to work around lines that needed to go live and others that didn't using Beyond Compare.
Mercurial with named branches and easy merging solves this for us. So not knowing what to expect we set it up.
First we cleaned cleaned up our production source, pruning dead files, etc.
We FTP'd that on staging and made this our new repository as "default", this was to be our stable branch ready to be deployed at all time.
Afterward, we did an hg clone
to the development server and had each developer hg clone
from the development default branch.
On acceptance where we do QA we did an hg clone
of the development server's default branch.
At this point we have a stable copy of the code everywhere, everyone is eager to start!
local machine are pushing to dev, acceptance pulls from dev and staging is completely isolated and can pull from wherever if the path is provided.
Now the idea behind this was that the default branch on our system would always be a copy of the code on the live server, provided that we remembered to pull before starting a new branch. When starting a new feature we would:
hg pull -b default #synch up
hg update default
hg branch {newFeature} #newFeature completely isolated from other changes.
*work on {newFeature}
Oh no! A bug! this is unrelated to what I am currently working on lets call it {bugFix111}. This appear to call for a new branch independant of my feature; go back to updated default. This will isolate newFeature and bugFix111 from each other and each can go live independently as they are based on default.
hg update default
hg pull -u
hg branch {bugFix111}
Once work is completed on say {bugFix111}
hg push -F {bugFix111} #send our fix to the main central repo on dev.
Go to acceptance:
hg pull -b {bugFix111} #pull the fix from the central repo (dev).
hg merge {bugFix111} #merge the code in the default QA branch.
hg commit -m "Merging {bugFix111} into default"
*QA sign off on the fix
We have to branch off acceptance - default were QA take place and release where we merge the stuff as it get signed off.
hg update release
hg merge {bugFix111} #fix is now ready to go live
hg commit -m "Merging {bugFix111} into release"
On staging:
hg pull -b release {PATH TO ACCEPTANCE REPO}
hg merge release
hg commit -m "Merging {bugFix111} into staging default"
hg tag release{date}
*robocopy to live
*run task that pull from staging to dev so that they synch up again.
This has been working for us and save up some deployment time as it's a breeze to just robocopy the stable release branch.
Issues
What we have noticed is:
It's easy to goof up a merge when merging the second time on release, this seem against the flow. We can break it after the QA sign off.
Could get QA to test our release branch as well but it seems like duplicating resource, the goal is just to have features isolated and being able to send them one at a time.
We can completely blow it up by merging release over something wrong, e.g. hg merge release when you are on the default on acceptance completely overwrites it.
If we forget to pull before starting a new branch we are working off the wrong base.
Few other oddities but those are the biggest hurdles.
I realize this is a long post, but hopefully the answers will help other Mercurial newbies like me trying to set up a decent workflow at their company.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不从 QA 部门拉动登台呢?然后合并作业已经完成并验证,即如果提交有一些手动合并,您也将在暂存时导入它。否则,您必须像现在一样在暂存时复制合并。
Why not pull on staging from the QA branch? Then the merge job has already been done and validated, i.e if the commit has some manual merge you will import it on staging also. Otherwise you have to replicate the merge on staging as you are doing it now.