从 svn 迁移时我应该如何组织 Mercurial 存储库
我们将项目以以下方式存储在 subversion
中:
- 主干(主要开发在此处)
- 分支
- 稳定(软件的生产版本)
- 内部(旧的内部版本的软件保留在这里,只有很少的新代码在这里提交)
我应该如何组织我的 Mercurial 存储库来托管它?我创建了三个存储库,一个用于主干,一个用于每个分支作为中央服务器,但由于 Mercurial 有分支,所以我可能做错了。至少感觉不对,但是当我尝试将单个变更集从开发本地存储库推送到稳定的本地存储库时,它推送了我所有的新变更集。那不是我想要的。
EDIT1
我在 trunk 中有修订版 623,在 stable 中有修订版 620。我只想将变更集 623 推送到稳定版本。我尝试了 hg push -r623 ../stable
,但 hg
告诉我,已推送 4 个变更集。
We have our project stored in subversion
in following way:
- trunk (main development goes here)
- branches
- stable (production version of software)
- internal (old, internal version of software is kept here and only very rarely new code is commited here)
How should I organize my mercurial
repostories to host it? I have created three repositories, one for trunk and one for each branch as central servers, but since mercurial has branches, than maybe I am doing it wrong. At least it feels wrong, but when I tried to push single changeset from development local repo to stable local repo it pushed all my new changesets. That's not what I wanted.
EDIT1
I had revision 623 in trunk and 620 in stable. I wanted to push only changeset 623 to stable. I tried hg push -r623 ../stable
, but hg
informed me, that 4 changesets were pushed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,让我们一次解决这个问题。
请注意,对于布局和组织,有很多方法可以做到这一点,唯一真正决定的人是您。
不过,我的建议是,根据您在评论中概述的工作流程,使用一个存储库作为默认存储库和稳定存储库,对这两个存储库使用命名分支。
至于旧代码,我会将其保存在一个单独的存储库中,如果需要的话,只需合并主代码中您需要的任何内容即可。
因此,我将如何组织它:
专注于主存储库,这将为您提供以下能力:
最后一个问题是,您如何合并时挑选变更集。
好吧,你不能。合并会合并您选择的变更集及其所有祖先。这就是 Mercurial 中合并的作用。
有两种方法可以缓解这种情况:
移植扩展允许您从一个分支中取出一个或多个变更集,并将它们复制(移植)到另一个分支上。变更集将被标记为已移植,因此将来的合并不会因此而出错。然而,问题在于,除了您添加到提交消息中的任何内容之外,图形日志中没有可见的行来表明您所做的事情。
另一种方法,即在其他地方提交变更集,最好通过示例来描述。
假设您有以下两个分支:
现在,您希望在默认情况下将变更集 7 提交到变更集 6 之上,然后仅将该变更集(而不是 2-5)“合并”到稳定分支上,正如我所说,合并不会这样做。
相反,您可以做的是找到以前的共同祖先,在本例中
1
,在该变更集之上提交新变更集,实际上获取此存储库日志:然后您可以将第 7 个变更集合并到稳定版本中和默认值:
这是 TortoiseHg 如何显示最后一个存储库,我只是移动了标签:
Ok, let's tackle this one question at a time.
Note that for layout and organization, there's many ways to do this, and the only person to really decide is you.
My advice, however, with the workflow you've outlined in your comment, is to use one repository for default and stable, using named branches for the two.
As for the old code, I would keep that in a separate repository, and just merge in whatever you need from the primary one, if you need to do that.
As such, here's how I would organize it:
Focusing on the primary repository, this gives you the following abilities:
The last question is, how can you cherry-pick changesets when merging.
Well, you can't. Merging merges the changeset you picked + all its ancestors. That's how merging does in Mercurial.
There's two ways to mitigate this:
The transplant extension allows you to take one or more changesets out of one branch, and copy them (transplant them) onto another branch. The changesets will be tagged as transplanted, so future merges will not trip over this. The problem, however, is that other than whatever you add to the commit messages, there's no visible lines in the graphical log to indicate this is what you did.
The other approach, to commit the changeset elsewhere, is probably best described with an example.
Let's assume you have the following two branches:
Now, you want to commit changeset 7 on top of changeset 6 in default, and then "merge" only that changeset, and not 2-5, onto the stable branch, and as I said, merge won't do that.
What you can do instead is find the previous common ancestor,
1
in this case, commit the new changeset on top of that changeset, in effect getting this repository log:Then you can merge the 7th changeset onto stable and default:
Here's how TortoiseHg shows that last repository, I just moved the labels: