0

我有 2 个存储库 A 和 B。我对 A 进行了 5 处更改,但其中只有 2 个也应该出现在 B 中。所以这就是我尝试的:

  1. 将 5 项更改推送到 repo A
  2. 将 repo B 的路径更改为 repo A 的路径
  3. 单击 repo B 的“检查传入的变更集”按钮

现在我看到了我为 repo A 所做的 5 个更改。这就是我卡住的地方,我现在怎么才能只获得 5 个更改集中的 2 个?我试过“拉到这里”,但这在我的情况下不起作用,它使所有变更集低于我选择的变更集。

例如,如何从列表中获取第一个和第三个变更集?有可能吗?

谢谢!:)

4

2 回答 2

2

当您在存储库之间拉取变更集时,您不能跳过它们之间的变更集。如果一个变更集在两个存储库中有不同的父项,则它不是同一个变更集。

您可以通过导出所需变更集的补丁然后将它们导入其他存储库来完成您的目标。这样,您就可以从 B 中的存储库 A 中获得所需的更改,但更改集在两个存储库中 不会具有相同的nodeid 。

于 2012-08-20T13:45:05.710 回答
1

It sounds like A and B were clones of the same repository. If that is the case, branching is probably what you need. If you have a history where A contains:

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

If your B was originally just rev0 and rev1 and you wanted rev3 and rev5 added to it, you can just update to rev1 and graft rev3 and rev5 onto it:

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

To avoid duplication of changesets and a little pre-planning, the changes that need to be on both A and B branches can be checked into B and merged into A, whereas changesets that only belong on A can be directly checked into 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
于 2012-08-21T04:30:53.233 回答