読者です 読者をやめる 読者になる 読者になる

hg rebase が3-way mergeしてくれるという話

mercurial

hg rebaseは3-way mergeします。 mercurialでhg graftは3-way mergeしてくれるのが売りだけど、hg rebaseはどうなんだっけ?という話がよく出るので。

以下、試したログ

% hg version | head -n1
Mercurial Distributed SCM (version 2.7.1)
% hg init rebase-3-way-merge-test
% cd rebase-3-way-merge-test
% cat <<END > README
heredoc> = README
heredoc>
heredoc> hogehoge
heredoc> END
% hg add README
% hg ci -m "add README"
% hg mv README README.md
% hg ci -m "rename"
% hg up 0
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
% cat <<END > LICENSE
heredoc> public domain
heredoc> END
% hg add LICENSE
% hg ci -m "add LICENSE"
created new head
% cat <<END > README
heredoc> = README
heredoc>
heredoc> foobar
heredoc> END
% hg ci -m "fix README"
% hg bookmark foo
% hg log -G --style compact
@  3[tip][foo]   e694dde31a4e   2013-09-27 11:37 +0900   trot
|    fix README
|
o  2:0   62de681e75d2   2013-09-27 11:36 +0900   trot
|    add LICENSE
|
| o  1   9268fbcaa618   2013-09-27 11:31 +0900   trot
|/     rename
|
o  0   43847b1e4bc1   2013-09-27 11:31 +0900   trot
     add README

% hg log -pr 3
changeset:   3:e694dde31a4e
user:        Takumi IINO <trot.thunder@gmail.com>
date:        Fri Sep 27 11:37:21 2013 +0900
summary:     fix README

diff --git a/README b/README
--- a/README
+++ b/README
@@ -1,3 +1,3 @@
 = README

-hogehoge
+foobar

% hg rebase --source 3 --dest 1 --keep
merging README.md and README to README.md
% hg log -G --style compact
@  4[tip][foo]:1   5bdfb661c56c   2013-09-27 11:37 +0900   trot
|    fix README
|
| o  3   e694dde31a4e   2013-09-27 11:37 +0900   trot
| |    fix README
| |
| o  2:0   62de681e75d2   2013-09-27 11:36 +0900   trot
| |    add LICENSE
| |
o |  1   9268fbcaa618   2013-09-27 11:31 +0900   trot
|/     rename
|
o  0   43847b1e4bc1   2013-09-27 11:31 +0900   trot
     add README
% hg log -pr 4
changeset:   4:5bdfb661c56c
bookmark:    foo
tag:         tip
parent:      1:9268fbcaa618
user:        Takumi IINO <trot.thunder@gmail.com>
date:        Fri Sep 27 11:37:21 2013 +0900
summary:     fix README

diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -1,3 +1,3 @@
 = README

-hogehoge
+foobar

%