gpt4 book ai didi

git - merge : Hg/Git vs. SVN

转载 作者:IT王子 更新时间:2023-10-29 01:18:55 25 4
gpt4 key购买 nike

我经常读到 Hg(以及 Git 和...)在 merge 方面比 SVN 更好,但我从未见过 Hg/Git 可以在 SVN 失败的地方(或 SVN 需要手动干预的地方) merge 某些东西的实际例子。您能否发布一些分支/修改/提交/...-操作的分步列表,以显示在 Hg/Git 继续前进时 SVN 会在哪里失败?请实际的,不是非常特殊的情况......

一些背景:我们有几十个开发人员使用 SVN 开发项目,每个项目(或一组类似的项目)都在自己的存储库中。我们知道如何应用发布分支和功能分支,因此我们不会经常遇到问题(即,我们曾经遇到过这种情况,但我们学会了克服 Joel's problems “一个程序员给整个团队造成创伤”的问题”或“需要六名开发人员两周来重新整合一个分支机构”)。我们有非常稳定的发布分支,仅用于应用错误修复。我们的主干应该足够稳定,能够在一周内创建一个版本。我们有单个开发人员或开发人员组可以处理的功能分支。是的,它们在重新集成后被删除,因此它们不会弄乱存储库。 ;)

所以我仍在努力寻找 Hg/Git 相对于 SVN 的优势。我很想获得一些实践经验,但目前还没有任何更大的项目可以转移到 Hg/Git,所以我只能玩那些只包含一些组合文件的小型人工项目。我正在寻找一些您可以感受到 Hg/Git 令人印象深刻的力量的案例,因为到目前为止我经常读到它们,但我自己却没有找到它们。

最佳答案

我也一直在寻找这样一种情况,比如说,Subversion 无法 merge 分支,而 Mercurial(和 Git、Bazaar 等)做了正确的事情。

SVN 手册 describes how renamed files are merged incorrectly .这适用于 Subversion 1.5 , 1.6 , 1.7 , 和 1.8 !我试图重现以下情况:

cd /tmprm -rf svn-repo svn-checkoutsvnadmin create svn-reposvn checkout file:///tmp/svn-repo svn-checkoutcd svn-checkoutmkdir trunk branchesecho 'Goodbye, World!' > trunk/hello.txtsvn add trunk branchessvn commit -m 'Initial import.'svn copy '^/trunk' '^/branches/rename' -m 'Create branch.'svn switch '^/trunk' .echo 'Hello, World!' > hello.txtsvn commit -m 'Update on trunk.'svn switch '^/branches/rename' .svn rename hello.txt hello.en.txtsvn commit -m 'Rename on branch.'svn switch '^/trunk' .svn merge --reintegrate '^/branches/rename'

According to the book, the merge should finish cleanly, but with wrong data in the renamed file since the update on trunk is forgotten. Instead I get a tree conflict (this is with Subversion 1.6.17, the newest version in Debian at the time of writing):

--- Merging differences between repository URLs into '.':A    hello.en.txt   C hello.txtSummary of conflicts:  Tree conflicts: 1

There shouldn't be any conflict at all — the update should be merged into the new name of the file. While Subversion fails, Mercurial handles this correctly:

rm -rf /tmp/hg-repo
hg init /tmp/hg-repo
cd /tmp/hg-repo
echo 'Goodbye, World!' > hello.txt
hg add hello.txt
hg commit -m 'Initial import.'
echo 'Hello, World!' > hello.txt
hg commit -m 'Update.'
hg update 0
hg rename hello.txt hello.en.txt
hg commit -m 'Rename.'
hg merge

merge 之前,存储库看起来像这样(来自 hg glog):

@  changeset:   2:6502899164cc|  tag:         tip|  parent:      0:d08bcebadd9e|  user:        Martin Geisler |  date:        Thu Apr 01 12:29:19 2010 +0200|  summary:     Rename.|| o  changeset:   1:9d06fa155634|/   user:        Martin Geisler |    date:        Thu Apr 01 12:29:18 2010 +0200|    summary:     Update.|o  changeset:   0:d08bcebadd9e   user:        Martin Geisler    date:        Thu Apr 01 12:29:18 2010 +0200   summary:     Initial import.

merge 的输出是:

merging hello.en.txt and hello.txt to hello.en.txt0 files updated, 1 files merged, 0 files removed, 0 files unresolved(branch merge, don't forget to commit)

换句话说:Mercurial 将修订版 1 中的更改 merge 到修订版 2 中的新文件名中 (hello.en.txt)。为了支持重构,处理这种情况当然是必不可少的,而重构正是您希望在分支上做的事情。

关于git - merge : Hg/Git vs. SVN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2475831/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com