hg clone 相当于 hg (init→pull)
在工作中,我使用 7 个人共享的 svn 存储库。
为了避免因提交而困扰我的错误并破坏每个人的构建,并避免在 svn
中分支,我在 svn 的一部分中创建了一个
我当前正在处理的目录。hg
存储库
我在工作时对 hg 执行本地提交,并且由于我在虚拟机上完成了所有设置,所以我什至将我的 hg 存储库推送到私有集中位置。
最近我迁移到了 Mac OS X lion,这破坏了我的虚拟机,所以我不得不重新设置它。因此,我从我的 svn trunk 中查看了该项目,现在想要取回我正在处理的目录中的 hg 更改集。
我有两个选择:
$ hg clone
$ hg init && hg pull
这等效吗?
At work I am using a svn
repository shared among 7 people.
To avoid plaguing my mistakes with commits and breaking the builds for everyone and to avoid branching in svn
, I have a created a hg
repository in a part of the svn
directory I am currently working on.
I perform local commits on hg as I work and since I have this all setup on a virtual machine, I am even pushing my hg
repository to a private centralized location.
Recently I migrated to Mac OS X lion
which broke my virtual machine, so I had to set it up again. So I checked out the project from my svn trunk
and now want to get back hg change sets in the directory I was working on.
I have two options:
$ hg clone <remote repo>
$ hg init && hg pull <remote repo>
Is this equivalent?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
唯一的区别是,如果您运行 hg init && hg pull,那么您还必须:
hg update default
以签出工作副本push
和的默认路径>pull
hg clone
在一个命令中完成所有这一切。The only difference is that if you run
hg init && hg pull <remote>
, then you must also:hg update default
to checkout a working copypush
andpull
hg clone
does all this in one command.嗯,是的,也不是。
我知道您的问题表明您正在使用远程存储库作为源,但问题的标题有点宽泛,所以我正在回答更广泛的问题。
看似明显的最终结果是相同的。尽管两个存储库内的文件不是二进制相同的(注意,我不是在谈论您跟踪的文件,我是在谈论 Mercurial 用于跟踪这些文件的“数据库”)、历史记录、变更集等都是一样的。
所以在这方面,是的,这两个人似乎做了同样的事情。
然而,他们以不同的方式做到这一点。
如果你这样做:
那么就没有真正的区别。
但是,如果您执行以下操作:
(请注意,此克隆/拉取来自磁盘上已有的另一个存储库)
那么可能有所不同。如果可能的话,本地克隆将使用存储库的硬链接。换句话说,您并不是为存储库中的所有文件创建一个新的不同副本,而是在磁盘上为它们创建新的链接,这样运行速度要快得多,并且几乎不需要空间。
然后,当您开始修改历史记录时,即。提交新的变更集后,这些文件将取消链接并按需制作完整副本。
请注意,我不知道它为哪些文件创建或不为哪些文件创建此类硬链接的确切启发。您可以在 Mercurial wiki 硬链接克隆 中了解有关此功能的更多信息。
拉动不会这样做。它将从其他存储库读取并在目标存储库中创建/更新新文件。这需要更多时间和更多磁盘空间。
总结一下:
hg clone LOCAL_PATH
可以使用比hg init && 少得多的磁盘空间,并且运行速度快得多。 hg pull LOCAL_PATH
Well, yes and no.
I know that your question indicates you're using a remote repository as the source, but the title of the question is a bit broader, so I'm answering the broader question.
The seemingly apparent end-result is the same. Though the files inside the two repositories are not binary identical (note, I'm not talking about the files you track, I'm talking about the "database" that Mercurial uses to track those files in), the history, changesets, etc. are all the same.
So in that respect, yes, those two seem to do the same thing.
However, they do it in different ways.
If you do this:
Then there is no real difference.
However, if you do this:
(note, this clone/pull is from another repository already on your disk)
Then there might be a difference. A local clone will, if possible, use hardlinks for the repository. In other words, you're not making a new distinct copy of all the files in the repository, you're creating new links on disk for them, which runs vastly quicker and requires almost no space.
Then, when you start modifying the history, ie. committing new changesets, those files are unlinked and made full copies, on a on-demand basis.
Note that the exact heuristics for which files it does and does not make such hardlinks for is not known to me. You can read more about this feature in the Mercurial wiki, Hardlinked Clones.
Pulling will not do this. It will read from the other repository and create/update new files in the target repository. This takes more time, and more disk-space.
So to summarize:
hg clone LOCAL_PATH
can use a lot less disk-space and run a whole lot quicker than ahg init && hg pull LOCAL_PATH