Mercurial - 在新代码提示之上重新设置旧代码分支,忽略分支与旧代码的合并

发布于 2024-11-05 21:38:28 字数 994 浏览 2 评论 0 原文

我正在玩 Adium 源代码,发现他们在 adium-1.4 中有一个未发布的分支,它使用 XMPP 修复了 facebook 聊天集成,名为facebook-xmpp。一切都很好,遵守了它并且有效。

问题是,如果我想在最新的 Adium 1.5 中拥有相同的功能,它的代码大约在两年前从旧版本中分离出来(旧版本的一些变更集不时被移植),我想我' d 必须以某种方式对构成 facebook-xmpp 分支的整个变更集范围进行变基,并将其应用到较新的 adium-1.5 分支的尖端。我认为这可能会起作用,因为 facebook-xmpp 看起来主要添加了新代码,因此它应该可以轻松地与最新的开发代码集成。

然而,由于 facebook-xmpp 分支与 adium-1.4 合并了几次,我发现变基会引入 adium-1.4 的合并更改也到 adium-1.5 上,这会导致很多合并冲突。

---------------------------------------  adium-1.4
               |                   \---  facebook-xmpp (created 1 month ago)
               |
               \-----------------------  adium-1.5
               ^ sometime in 2009

问题是,有没有办法只将添加到 facebook-xmpp 分支的变更集移植到 adium-1.5 上,不包括与 adium- 合并的变更集1.4 ?

I was playing around with the Adium source code and discovered that they had an unreleased branch in the adium-1.4 that fixes the facebook chat integration by using XMPP, called facebook-xmpp. All good there, complied it and it works.

Problem is, if I wanted to have the same functionality in the latest Adium 1.5, whose code got split from the older version's about two years ago (with some changesets from the older version being transplanted over from time to time), I figured I'd have to somehow rebase the entire range of changesets that makes up the facebook-xmpp branch and apply it onto the tip of the newer adium-1.5 branch. I thought this might work since facebook-xmpp looks like it mostly adds new code, so it should be easily integrated with the newest development code.

However, since facebook-xmpp branch merged with adium-1.4 several times, I found that rebasing would pull in the merged changes from adium-1.4 onto adium-1.5 as well, which makes for a lot of merge conflicts.

---------------------------------------  adium-1.4
               |                   \---  facebook-xmpp (created 1 month ago)
               |
               \-----------------------  adium-1.5
               ^ sometime in 2009

Question is, is there a way to transplant onto adium-1.5 only the changesets that added to the facebook-xmpp branch, excluding the ones that merged with adium-1.4 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恰似旧人归 2024-11-12 21:38:28

方法1(手动补丁)

如果您只想在audium-1.5中使用facebook-xmpp功能,您可以

  1. 合并audium-1.4<的提示/code> 进入 facebook-xmpp,然后
  2. audium-1.4facebook-xmpp 的提示之间创建差异,并
  3. 尝试应用该补丁到尖端铝-1.5。

这应该可行,但新补丁与原始开发历史脱节。

--------o---o    <- tip of audium-1.4
   \     \   \
    \     o---o  <- tip of facebook-xmpp (all audium-1.4 changes merged in)
     \
      o-------o  <- tip of audium-1.5 (apply patch here)

基本上这些命令应该可以做到这一点:

$ hg up facebook-xmpp
$ hg merge audium-1.4
$ hg commit -m "Merge audium-1.4 into facebook-xmpp"
$ hg diff -r audium-1.4 -r facebook-xmpp > fbx.patch # facebook-only changes
$ hg up audium-1.5
$ hg import fbx.patch # good luck

方法 2(选择性合并)

另一种解决方案更加尊重历史图,是将 facebook-xmpp 直接合并到audium-1.5 中> 当使用使用 internal:local 作为默认合并工具(到阻止合并工具弹出 1000 次),但会定期合并任何 facebook-xmpp 相关文件(如果您知道哪些文件与其功能相关)。然后,在提交合并之前,恢复与 facebook 无关的所有文件。

更新:以下是第二个解决方案的一些示例说明。假设 facebook-xmpp 分支创建了一些名为 fb-.c 的新文件,并更改了现有文件 foo.c 和 < code>bar.c (您可以从 facebook-xmpp 及其与 audium-1.4 的最新合并之间的差异中获取这些文件)。将 facebook-xmpp 合并到 audium-1.5 时,请使用以下合并工具配置:

$ hg up audium-1.5
$ hg --config ui.merge=internal:local \
     --config merge-patterns.fb-*.c=internal:merge \
     --config merge-patterns.foo.c=internal:merge \
     --config merge-patterns.bar.c=internal:merge \
     merge facebook-xmpp

第一个合并配置确保通常 audium-1.5 更改是保留在 audium-1.4audium-1.5 中更改的文件。其他配置选项确保对于 facebook-xmpp 分支涉及的任何文件执行常规合并,可能存在需要手动解决的冲突。例如,如果 foo.c 引发冲突,请运行

$ hg resolve foo.c

以使用您最喜欢的手动合并工具解决冲突。最后,您必须提交合并,同时不提交源自 audium-1.4 的任何新文件。只需提交 facebook-xmpp 内容即可:

$ hg ci -I "fb-*.c" -I foo.c -I bar.c
$ hg up -C # get rid of remaining new files from audium-1.4

Method 1 (manual patch)

If you just want the facebook-xmpp functionality to be available in audium-1.5, you could

  1. merge the tip of audium-1.4 into facebook-xmpp, then
  2. create a diff between the tips of audium-1.4 and facebook-xmpp and
  3. try to apply that patch onto the tip of adium-1.5.

That should work but the new patch is disconnected from the original development history.

--------o---o    <- tip of audium-1.4
   \     \   \
    \     o---o  <- tip of facebook-xmpp (all audium-1.4 changes merged in)
     \
      o-------o  <- tip of audium-1.5 (apply patch here)

Basically these commands should do it:

$ hg up facebook-xmpp
$ hg merge audium-1.4
$ hg commit -m "Merge audium-1.4 into facebook-xmpp"
$ hg diff -r audium-1.4 -r facebook-xmpp > fbx.patch # facebook-only changes
$ hg up audium-1.5
$ hg import fbx.patch # good luck

Method 2 (selective merge)

Another solution, which shows more respect to the history graph, would be to directly merge facebook-xmpp into audium-1.5 while using a merge tool configuration that uses internal:local as the default merge tool (to stop your merge tool from popping up 1000 times) but that merges regularly for any facebook-xmpp related files (if your know which files are related to its functionality). Then, before committing the merge, revert all files not related to the facebook thing.

UPDATE: Here are some example instructions for this second solution. Supposed the facebook-xmpp branch created some new files named fb-<something>.c and changed the existing files foo.c and bar.c (you get these files from a diff between facebook-xmpp and its latest merge with audium-1.4). When merging facebook-xmpp into audium-1.5, use the following merge tool configuration:

$ hg up audium-1.5
$ hg --config ui.merge=internal:local \
     --config merge-patterns.fb-*.c=internal:merge \
     --config merge-patterns.foo.c=internal:merge \
     --config merge-patterns.bar.c=internal:merge \
     merge facebook-xmpp

The first merge config ensures that generally audium-1.5 changes are kept on files changed in both audium-1.4 and audium-1.5. The other config options ensure that for any files touched by the facebook-xmpp branch a regular merge is performed, potentially with conflicts which need to be resolved manually. For instance if foo.c raised conflicts, run

$ hg resolve foo.c

to resolve the conflicts with your favorite manual merge tool. Finally, you have to commit the merge while not committing any new files originating in audium-1.4. Just commit the facebook-xmpp stuff:

$ hg ci -I "fb-*.c" -I foo.c -I bar.c
$ hg up -C # get rid of remaining new files from audium-1.4
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文