“弧形嫁接”和“弧形补丁”之间有什么区别?

时间:2019-01-17 02:01:35

标签: git phabricator arcanist

arc help --full | lessgraft揭示了这一点:

  graft revision

      Grafts revision and its dependencies (if any) onto your working tree.

      --force
          Do not run any sanity checks.

      --skip-landed
          Do not try to patch landed/closed diffs.

patch中的这个:

  patch D12345
  patch --revision revision_id
  patch --diff diff_id
  patch --patch file
  patch --arcbundle bundlefile
      Supports: git, svn, hg
      Apply the changes in a Differential revision, patchfile, or arc
      bundle to the working copy.

      --arcbundle bundlefile
          Apply changes from an arc bundle generated with 'arc export'.

这对我来说是模糊的。用“嫁接”一词来描述“嫁接”的含义对我没有多大帮助。


对于不认识的人,arc(Arcanist)是“ Phabricator”内部的命令行工具,其作用类似于Git(甚至是Mercurial和Subversion)的高级包装,以帮助大型软件项目的开发过程。这里有一些链接:

https://phacility.com/phabricator/

  

Phabricator最初是作为Facebook的内部工具开发的。[7] [8] [9] Phabricator的主要开发人员是Evan Priestley。[1] Priestley离开了Facebook,在一家名为Phacility的新公司中继续Phabricator的开发。[2]   https://en.wikipedia.org/wiki/Phabricator

2 个答案:

答案 0 :(得分:2)

因此,经过一些试验和反复试验,我想我已经知道了:

arc graftarc patch都在后台使用git cherry-pick,并完成类似的操作。但是,它们之间存在一些细微的差异,有时arc patch会失败,并且您必须将arc graft--skip-landed标志一起使用(更新:或者将arc patch与{{1} }标志也可以使用?)。

示例:

--skip-dependencies

OR

arc patch --skip-dependencies D999 # cherry-pick their "D999" "diff" (branch) onto your current branch, while creating a new single branch for you named "arcpatch-D999", skipping dependencies in case they've already landed on the branch (ex: master) you currently have checked out.

想象一下,您的arc graft --skip-landed D999 # cherry-pick their "D999" "diff" (branch), *as well as all parent branch(es) it depends on*, onto your current branch, while creating the entire dependency tree of branches for you, exactly as the submitter originally had on their local machine, skipping any commits that have already landed on your local branch (ex: master) you currently have checked out 依赖关系树仅包含“ master”分支:

arc flow

但是,一位同事具有以下master 依赖关系树:

arc flow

简短地说:什么是master └──new_feature_1 └──new_feature_2 依赖树?回答:这是一个树形结构,通过arc flow命令显示,它显示了哪些分支取决于什么。作为一个人,您手动进行跟踪是有点武断的事情,因为您知道一个功能取决于另一个功能。要建立“依赖关系”,您有两个选择:

  1. 在您当前要签出要成为父级的分支时,调用arc flow创建一个新的子分支,或者:
  2. 使用git创建一个新分支,然后将其上游设置为您希望成为父分支的分支。例如:

    arc flow new_branch_name

现在,git branch new_branch_name git checkout new_branch_name # Or use `git checkout -b new_branch_name` to do both at once git branch --set-upstream-to=upstream_branch_name # or `git branch -u upstream_branch_name` for short 将显示您的依赖关系树。这样一来,您可以将arc flow从父级下放到子级,这只是从父级到子级进行自动递归git rebase,即将子级重新定级到父级。

一旁结束。


无论如何,有了上面显示的依赖关系树,您的同事已签出“ new_feature_2”,他们arc cascade进行审核。您转到基于Web的“差异”工具并开始查看更改。但是,您要对其进行测试。这意味着您需要将它们的差异拉到本地计算机上。您有两种选择:1.将它们的差异(依赖树感知分支)arc diff到本地主服务器上,或2。arc patch将它们的差异连接到本地主计算机上。

假设它们的差异为“ D999”,并且您当前已将“ master”分支检出,则命令和生成的依赖关系树如下所示:

  1. arc graft。现在,您有了这棵树,其中新创建的“ arcpatch-D999”是其“ new_feature_2”分支:

    arc patch D999
  2. master └──arcpatch-D999 。您现在有了这棵树,就像它们一样:

    arc graft D999

但是,(基于我的问题,我认为)有时候,当他们拥有像这样的多代依赖树时,master └──new_feature_1 └──new_feature_2 将会失败(给出一个错误,指出“ Cherry Pick Failed!”),并且在这种情况下,您必须改为使用arc patch!但是,如果他们的主人与您的主人不完全相同(几乎可以肯定不会,因为他们可能把主人拉了一段时间,您应该把主人拉出来以确保您拥有最新的主人),然后尝试移植物或补丁将失败。失败可能与以下事实有关:分支历史中的某些提交包含已登陆并存在于您的主数据库中的更改。 解决方案是使用arc graft,这将使您能够抓住他们的差异并将其拉下,从而镜像他们的arc graft D999 --skip-landed依赖关系树。在这种情况下,{{1} }可能会继续失败,直到他们拉出最新的master和arc flow(或git rebase两次),然后重新arc patch D999将他们的更改推送到服务器,此时您可以{{1 }}成功加入到您的主人。但是,由于无法始终让它们立即重新变基/ arc cascade,因此,请立即执行arc diff并完成操作!让他们重新定位并重新arc patch D999

但是,一个小问题是,如果您arc cascade从事过多工作,可能会混淆谁创建了哪个分支(您还是其他人?),所以我建议您养成嫁接到哪个分支的习惯。您为自己命名的新分支,如下所示,仅用于组织:

arc graft D999 --skip-landed

您的依赖树现在如下:

arc diff

太好了!尼斯和有条理。现在,您可以签出“ new_feature_2”并进行编译和测试。但是请注意,“ master”和“ graft-D999”将是完全相同的分支,但这没关系。

答案 1 :(得分:0)

这可能与git grafts有关,您需要进行提交/修订,并更改其父提交,从而更改存储库的历史记录。
(尽管是since Git 2.18, Q2 2018, graft has been superseded by git ref/replace/

与补丁相反,补丁只是从现有的差异创建一个新的提交/修订,从而增加了回购的历史记录。

相关问题