Mercurial - 分发克隆有什么意义?
Mercurial 关于页面显示:
“传统版本控制系统 比如 Subversion 就是典型的 客户端-服务器架构 中央服务器存储修订版本 一个项目的。相比之下,水银 是真正分布式的,给每个 开发者整个本地副本 发展历史。这样就可以了 独立于网络访问或 中央服务器。提交、分支 并且合并既快又便宜。”
因此,当每个开发人员从_(?)获得克隆时,每个开发人员都可以开始自己的项目工作。10 个月后来每个人都做了一些事情并以完全不同的方式更改了 RootViewController
现在,当 Dev A 更改 RootViewController 时,Dev B 想要继续基于该更改的工作有什么意义? B 每天都克隆整个东西吗?是否有某种超级合并操作可以将所有克隆合并成一个大的超级克隆,每个人都必须偶尔用他自己的克隆来替换它? ?
我确信 Mercurial 很酷而且很有用,但我就是不明白。
The Mercurial About page says:
"Traditional version control systems
such as Subversion are typical
client-server architectures with a
central server to store the revisions
of a project. In contrast, Mercurial
is truly distributed, giving each
developer a local copy of the entire
development history. This way it works
independent of network access or a
central server. Committing, branching
and merging are fast and cheap."
So when every developer gets a clone from _ (?), then every developer can start working on the project for his own. 10 months later everyone has done something and changed RootViewController in a whole different way.
Now, what's the point of cloning the whole thing? When Dev A changes RootViewController, then Dev B wants to continue work based on that change. Or not? But how will Dev B ever get that change? By cloning the whole thing every day? How about his own changes? Is there some kind of super merge operation that merges all clones into one big superclone which everyone would have to replace with his individual clone once in a while?
I am sure Mercurial is cool and useful. But I just don't get it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我发现这里的基础知识很好地介绍了 Mercurial。
此外,拥有一些中央存储库很方便,每个人都可以在其中推送更改并从中提取更改。
I found the basics here a good introduction to Mercurial.
Also, it is convenient to have some central repository where every one can push their changes and pull changes from.
一般来说,在像 Mercurial 这样的分布式版本控制系统中,您仍然拥有一个中央存储库。要么开发人员推送到中央存储库,要么由一个人维护中央存储库,从各个开发人员那里获取补丁(例如,Linux 使用这种方法)。
如果您不使用该开发模型,那么是的,通常您只需在其他开发人员完成有趣的补丁后就可以从他们那里获取。
Generally, in a distributed version control system like Mercurial, you'll still have a central repository. Either developers push into the central repo, or there is one person maintaining the central repo that pulls patches from individual developers (Linux uses this approach, for example).
If you don't use that development model, then yes, typically you'd just pull from other developers when they had completed an interesting patch.
在分布式版本控制系统(DVCS)(mercurial 和 git)中没有人是大师。 (即使“服务器”也是任意选择的主人,没有更多权利对其他人的工作进行操作)
每个开发人员都可以在不让其他人的工作变得无法使用的情况下搞砸自己的事情。你还记得上次有人做了坏事而没有人能工作吗?这在 DVCS 中是不可能的。
在 Subversion/CVS 中,您应该进行分支以避免这些问题,但合并很复杂,因此很少/不是每个任务都执行合并。
在 DVCS 中,不可能不进行分支,但合并很容易,并且应该在所有代码完成后完成(错误关闭、完成功能等)。您的开发人员可以拥有与打开的任务一样多的分支。
In distributed version control system (DVCS) (mercurial and git) no one is the master. (Even the "server" is an arbitrary chosen master with no more right to the work of others)
Every developer can do his mess without making others work unusable. Do you remember last time some one commit something bad and none could work? This is just impossible in DVCS.
In Subversion/CVS you should branch to avoid those problems, but merge are complicated so it's done rarely/not for every tasks.
In DVCS, it' impossible not to branch, but merge are easy and should be done after all code completion (bug closed, finished feature,...). Your developers can have as many branches as he has tasks open.
取自我对另一个问题的回答:
如果您在任何类型的组织(公司、项目团队等)中,您仍然需要一个中央存储库,因此您拥有代码的规范版本。很少有团队使用没有中央服务器的完全分布式工作流程,因为随着团队人数的增加,您的连接数会增加到 N2,而使用中央服务器时连接数仍保持为 N。
Taken from my answer to a different question:
If you're in any sort of organization (company, project team, etc.), you'll still want a central repository, so you have a canonical version of the code. Very few teams use a fully distributed workflow without a central server, because as you increase the number of people on your team, your connections increase to N2, whereas it stays N with a central server.
如果每个开发人员都克隆整个项目,然后仅在本地提交,那么是的,您将会遇到问题。我想说软盘源代码控制模型在这一点上可能稍微好一些,因为您没有在组合中引入其他工具。
问题是,这并不是您应该做的全部事情。
基本上工作流程是这样的。
每个开发人员都会克隆本地存储库,并开始破解代码。
在某些时候,其中一位开发人员已经完成了一些他想要与其他人共享的提交,以便开发人员将他/她的更改推送回中央存储库。现在,中央存储库具有该开发人员的更改,但其他开发人员都没有(还没有)。
在他们自己的闲暇时间(但不是太少,否则您将遇到合并问题,就像您在问题中指出的那样),他们然后可以将这些更改拉入他们自己的存储库中。
当他们这样做时,他们的存储库中就会有分支。
首先,他们拥有中央存储库中所有克隆时存在的最新变更集,然后他们有两个分支,一个分支(通常)沿着线性路径进行自己的更改,另一个分支包含他们从存储库中拉取的所有更改。
IE。他们最终得到这样的结果,(C) 是每个人克隆的通用变更集:
所以,现在他们可以选择。他们可以继续在自己的分支上工作,他们可以切换到继续在他们刚刚从中央存储库获得的分支上工作,或者他们可以合并这两个分支并充分利用两个世界。通常他们会选择选项 3:合并。
这导致了这一点:
如果他们现在将更改推送回中央存储库,那么他们自己的分支、合并变更集以及他们在合并后提交的任何内容都会被推送回中央存储库以供其他人拉取。
通过这种方式,您可以看到:
If every developers clone the whole project, and then only commits locally after that, then yes, you're going to run into problems. I'd say the floppy-disk source control model is probably slightly better at that point, because you don't introduce another tool into the mix.
The thing is, that's not all that you're supposed to do.
Basically the workflow goes like this.
Every developer clones the local repository, and starts hacking at the code.
At some point, one of the developers have done a few commits that (s)he wants to share with the others, so that developer pushes his/her changes back to the central repository. Now the central repository has that developer's changes, but none of the other developers have them (yet.)
At their own leisure (but not too seldom, or you're going to have merge problems, like you indicate in your question), they can then pull those changes down into their own repository.
When they do this, they have branches in their repository afterwards.
First they have the latest changeset that was present in the central repository when they all cloned it, then they have two branches, one with their own changes down a linear path (usually), and one with all the changes they pulled down from the repository.
ie. they end up with something like this, (C) is the common changeset everybody cloned:
So, now they can choose. They can continue working on their own branch, they can switch to continue working on the branch they just got from the central repository, or they can merge the two and get the best of two worlds. Typically they will choose option 3, merge.
Which leads to this:
If they now push their changes back to the central repository, their own branch, the merge changeset, and anything they committed after the merge, is then pushed back to the central repository for others to pull.
In this way you can see that:
其他人的答案都对,但我想具体回答你的问题
您现在拥有自己的私人存储库。这使得许多操作变得更快,因为它们是本地的,但也允许您进行私密的更改,直到您想要共享它们为止。
这样做的连锁反应是开发人员可以将“签入”与发布他们的作品分开。这意味着您不会有很长一段时间什么都没有签入,因为“它还没有准备好公开”。
当开发人员 A 乐意分享他的更改时,他可以:
克隆仅用于创建存储库的新副本。想想“svn co”。
您通常将更改集“拉”到存储库中,有点像“svn update”
当变更集被引入存储库(例如通过“拉取”)时,它们将存在于另一个分支上。据说存储库有多个“头”,它们是分支的开放端。通过合并这些头,他将获得一个包含两个分支的更改的单一版本。然后,开发人员 B 可以在此基础上继续工作。你会得到一个看起来像这样的图表。
合并之前:
合并之后:
这种合并可能听起来像是很多额外的工作,但是因为 Mercurial 使用有关开发人员何时拆分的信息,并且不只是“区分”两个头,所以它非常聪明。一般来说,合并冲突很少见。
也许 Dev A 做了更多工作,然后发布到中央存储库(注意:之前 Dev B 直接从他那里获得了 Dev A 的更改。也许 B 正在开发依赖于 A 代码的功能,并且需要代码的 beta 版本早期的)。您最终可能会得到这样的图表:
开发人员 B 在开发过程中拍摄了开发人员 A 的代码的几个快照,当开发人员 A 将其最终代码发布到中央存储库时,开发人员 B 能够提取额外的更改,并与他们,并将他的所有更改也推回到中央存储库。因为 Mercurial 知道 B 拥有 A 代码的快照,所以当它从中央存储库中提取时,它不会感到困惑。它只是说“哦,我已经得到了一些。”
因此,对我来说,DVCS 的两个杀手级功能是:
哇,虽然很长,但希望对您有所帮助。
Other people's answers are right, but I wanted to specifically answer your questions
You now have your own private repository. This makes a lot of operations faster because they're local, but also allows you to make changes that are private until you want to share them.
The knock on effect of this is that developers can separate 'checking-in' with publishing their work. This means that you don't get large periods of time when nothing is checked in, because "it's not ready to go public".
When Dev A is happy to share his changes, he can either:
Cloning is only done to create a new copy of a repository. Think "svn co".
You normally 'pull' change-sets into a repo, a bit like 'svn update'
When change-sets are brought into a repo (e.g. via 'pull') they will exist on another branch. The repository will be said to have multiple 'heads', which are the open ends of branches. By merging these heads he'll get a single version which contains the changes from both branches. Dev B can then continue working on top of that. You would get a graph that looked something like this.
Before merge:
After merge:
This merging might sound like a lot of extra work, but because Mercurial uses the information about when the developers split, and doesn't just 'diff' the two heads, it's pretty smart. In general, merge conflicts are rare.
Maybe Dev A does some more work, and then publishes to the central repo (Note: previously Dev B got Dev A's changes directly from him. Maybe B is working on a feature that relies on A's code, and needed a beta version of the code early). You could end up with a graph like this:
Dev B has taken a couple of snapshots of Dev A's code during development, and when Dev A published his final code to the central repository, Dev B was able to pull the extra changes, merge with them, and push all of his changes back to the central repo too. Because mercurial knew about the snapshots B had of A's code, it didn't get confused when it pulled from the central repo. It just said "Oh, I've already got some of this."
So, for me the two killer features of DVCS are:
Wow, that got long, but hope it helps.