听起来 A 和 B 是同一个存储库的克隆。如果是这种情况,分支可能就是您所需要的。如果您有 A 包含的历史记录:
C:\example>hg glog --template "rev{rev}:{desc}\r\n"
@ rev6:change7
|
o rev5:change6
|
o rev4:change5
|
o rev3:change4
|
o rev2:change3
|
o rev1:change2
|
o rev0:change1
如果您的 B 最初只是 rev0 和 rev1,而您想要将 rev3 和 rev5 添加到其中,则可以更新为 rev1 并将 rev3 和 rev5 添加到其中它:
C:\example>hg update 1
0 files updated, 0 files merged, 5 files removed, 0 files unresolved
C:\example>hg glog --template "rev{rev}:{desc}\r\n"
o rev6:change7
|
o rev5:change6
|
o rev4:change5
|
o rev3:change4
|
o rev2:change3
|
@ rev1:change2
|
o rev0:change1
C:\example>hg graft 3 5
grafting revision 3
grafting revision 5
C:\example>hg glog --template "rev{rev}:{desc}\r\n"
@ rev8:change6 <--- contains change 1, 2, 4, 6
|
o rev7:change4
|
| o rev6:change7 <--- contains changes 1-7.
| |
| o rev5:change6
| |
| o rev4:change5
| |
| o rev3:change4
| |
| o rev2:change3
|/
o rev1:change2
|
o rev0:change1
为了避免变更集的重复和一些预先计划,需要同时在 A 和 B 分支上的变更可以检入 B 并合并到 A,而只属于on A 可以直接签入A:
C:\example>hg glog --template "rev{rev}:{branch}:{desc}\r\n"
@ rev8:A:change7 <--- contains changes 1-7.
|
o rev7:A:Merge
|\
| o rev6:B:change6 <--- contains change 1, 2, 4, 6
| |
o | rev5:A:change5
| |
o | rev4:A:Merge
|\|
| o rev3:B:change4
| |
o | rev2:A:change3
|/
o rev1:default:change2
|
o rev0:default:change1