在 TFS2008 中重新设置分支的父级

发布于 2024-08-07 07:51:52 字数 653 浏览 2 评论 0原文

假设我在 TFS 中有分支 A,从中获取分支 B。在 B 上进行了一些更改集,然后从 B 中获取了分支 C,并在分支 C 上进行了更多更改

A ------------------------------
     |
B    ----1--2------------------
                 |
C                ----3-----4---

现在假设我们想要从 C 合并到 A,但是绕过 B.TFS 不允许这样做 - 我必须进行无基础的合并,这可能很容易出错。真的,我想让 C “重新设置父级”(如果这是正确的术语),因此它是 A 的子级,而不是 B。换句话说,我希望最终得到以下分支结构。 (C' 可以是原始的 C 分支,也可以是 C 本来应有的新分支)。

A ------------------------------
     |   |
B    |   ----1--2------------------
     |           
C'   |-------1--2----3-----4---

现在 C' 可以正确合并到 A 中,而无需进入 B。

我的问题是,是否有任何自动化工具/脚本可以设置创建 C' 分支所需的挂起更改,因为手动执行此操作将需要我们非常长时间很久?

Say I have branch A in TFS from which I take branch B. Some changesets are made on B, then from B, branch C is taken, and more changes are made on branch C

A ------------------------------
     |
B    ----1--2------------------
                 |
C                ----3-----4---

Now suppose we want to merge from C into A, but bypassing B. TFS won't allow this - I have to do a baseless merge, which can be very error prone. Really, I want to get C "reparented" (if that is the correct terminology) so it is a child of A, not B. In other words, I want to end up with the following branch structure. (C' can either be the original C branch, or a new branch that is what C should have been).

A ------------------------------
     |   |
B    |   ----1--2------------------
     |           
C'   |-------1--2----3-----4---

Now C' can be merged correctly into A without going into B.

My question is, is there any automated tool / script that could set up the pending changes required to create the C' branch, as to manually do this would take us a very long time?

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

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

发布评论

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

评论(1

失去的东西太少 2024-08-14 07:51:53

在 TFS 中重新设置分支父级是很困难的。您可以通过无基合并有效地给它一个额外的父级,但是:

  • 无基合并是乏味的&容易出错,正如您所知,
  • 没有命令或 API 可以删除与“真实”父级的合并关系,如果没有 Destroy,
  • 将无法通过 VS 2005/2008 合并向导在新方向上执行合并

您 所要求的——我同意这是最好的解决方案——是一个名为 C' 的全新分支,它的内容恰好与今天的 C 相同。这是实现这一目标的快速方法:

  1. 使用普通的“分支”对话框创建新分支。如果一定要和C同名也没关系,先把C重命名为C_old就可以了。您需要决定是否适合从 A 的最新版本或某个旧版本进行分支。(如果有帮助,您可以在“属性”对话框中看到 B 的分支版本。)
  2. 从磁盘中删除新的 C 目录。
  3. 将命令提示符导航到 C_old 目录,然后运行tfpt scorch -diff -deletes。这将确保 C_old 是最新的并且不包含任何无关文件(例如构建工件)。
  4. 复制C_old -> C.
  5. 导航到 C,然后运行 ​​tfpt online -adds -deletes -diffs 。 -r。这将等待添加、编辑和修改。根据需要进行删除,以便服务器记录 A [作为分支] 和 C [作为在磁盘上表示的] 之间的增量。
  6. 签入

此方法的唯一缺点是您不会看到更改 3 和 3。历史上有4个。当然,它们仍然位于 C_old 下,但像 Annotate 这样的工具不会知道这一点——它们会看到这些更改在您创建 C' 的日期一次性发生,没有单独的注释/工作项/ ETC。

Reparenting a branch in TFS is hard. You can effectively give it an additional parent via baseless merge, but:

  • baseless merges are tedious & error prone, as you know
  • there is no command or API for removiong the merge relationship with the "real" parent, short of Destroy
  • you will not be able to perform merges in the new direction via the VS 2005/2008 Merge Wizard

What you seem to be asking for -- and I agree is the best solution -- is a brand new branch named C' that happens to have the same contents that C does today. Here's a quick way to achieve that:

  1. Use the normal Branch dialog to create the new branch. If it must have the same name as C, that's ok, just rename C to C_old first. You'll need to decide whether it's appropriate to branch from Latest or from some older version of A. (If it helps, you can see the version that B was branched from in the Properties dialog.)
  2. Delete the new C directory from disk.
  3. Navigate a command prompt to the C_old directory, then run tfpt scorch -diff -deletes. This will ensure C_old is up to date and does not contain any extraneous files (e.g. build artifacts).
  4. Copy C_old -> C.
  5. Navigate to C, then run tfpt online -adds -deletes -diffs . -r. This will pend adds, edits, & deletes as necessary for the server to record the delta between A [as branched] and C [as represented on disk].
  6. Checkin

The only disadvantage of this method is that you won't see changes 3 & 4 in the history. They'll still be under C_old, of course, but tools like Annotate won't know that -- they'll see those changes as occurring all at once, on the date you created C', without the individual comments/work items/etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文