2020 年 3 月 19 日更新:
注意arc flow
and arc cascade
显然不属于Pacility 奥术师的主流版本 https://github.com/phacility/arcanist。相反,它们只是其中的一部分奥术师的 Uber 分叉 https://github.com/uber/arcanist。一些arc flow
找到源代码了here https://github.com/uber/arcanist/blob/master/src/flow/ICFlowSummary.php#L87, 例如。此外,arc cascade
也只是 Uber 分叉奥术师功能,并且它的一些arc cascade
找到源代码了here https://github.com/uber/arcanist/blob/master/src/flow/workflow/ICCascadeWorkflow.php#L75.
了解如何安装 Uber 的 arcanist 分支,以便开始在常规中使用这些功能git
工作流程(如果不需要,您不需要使用奥术师的任何其他功能),跳到这个答案的底部.
2019 年 1 月原始答案:
因此,经过一些实验和反复试验后,我想我已经弄清楚了:
Both arc graft
and arc patch
use git cherry-pick
在幕后,并完成类似的事情。然而,它们有一些细微的差别,有时arc patch
失败,你必须使用arc graft
与--skip-landed
标记代替(更新:或者也许arc patch
与--skip-dependencies
标志也可以工作吗?)。
例子:
# 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 patch --skip-dependencies D999
OR
# 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
arc graft --skip-landed D999
想象一下你的arc flow
依赖树仅包含“master”分支:
master
然而,一位同事有以下情况arc flow
依赖树:
master
└──new_feature_1
└──new_feature_2
简而言之:什么是arc flow
依赖树?并且:它是一个树结构,通过arc flow
命令,它显示哪些分支依赖于什么。作为人类,手动跟踪是一件有点武断的事情,因为您知道一个功能依赖于另一个功能。要建立“依赖关系”,您有两种选择:
- Call
arc flow new_branch_name
在您当前签出要成为父分支的情况下创建新的子分支,或者:
-
使用 git 创建一个新分支,然后将其上游设置为您想要的父分支。前任:
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
Now, arc flow
将显示您的依赖树。这可以让你做类似的事情arc cascade
从父级到子级,这只是执行从父级到子级的自动递归 git rebase(即:将子级重新设置为父级)。
一边结束。
无论如何,通过上面显示的依赖关系树,您的同事已签出“new_feature_2”,并且他们arc diff
供您审查。您转到基于网络的“差异”工具并开始检查更改。但是,您想测试它。这意味着您需要将它们的差异拉到本地计算机上。您有两个选择:1。arc patch
将它们的 diff(依赖关系树感知分支)复制到本地 master 上,或者 2。arc graft
他们的差异到你当地的主人。
假设它们的差异是“D999”,并且您当前已签出“master”分支,则您的命令和生成的依赖关系树将如下所示:
-
arc patch D999
。现在您拥有了这棵树,其中新创建的“arcpatch-D999”是其“new_feature_2”分支:
master
└──arcpatch-D999
-
arc graft D999
。你现在有了这棵树,就像他们一样:
master
└──new_feature_1
└──new_feature_2
然而,(我认为,根据我的问题)有时当他们有这样的多代依赖树时,arc patch
将失败(给出错误“Cherry Pick Failed!”),在这种情况下您必须使用arc graft
反而!然而,如果他们的主人与你的主人不完全相同(这几乎肯定不会,因为他们可能不久前拉了他们的主人,你应该拉你的主人以确保你拥有最新的),那么你的尝试移植或修补将会失败。失败很可能与以下事实有关:分支历史记录中的某些提交包含已经落地并存在于您的 master 中的更改。解决方案是使用arc graft D999 --skip-landed
,这将允许你抓住他们的差异并将其拉下来,镜像他们arc flow
依赖树。在这种情况下,arc patch D999
可能会继续失败,直到他们拉出最新的主控并且arc cascade
(或 git rebase 两次),然后重新arc diff
将他们的更改推送到服务器,此时您可以arc patch D999
成功到你的主人身上。因为你不能总是让他们变基/arc cascade
但是,立即执行arc graft D999 --skip-landed
现在就完成吧!让他们变基并重新arc diff
当他们到达时。
然而,一个小问题是,如果您arc graft
说得太多,可能会让人困惑谁创建了哪些分支(你,还是其他人?),所以我建议你养成移植到你自己命名的新分支上的习惯,如下所示,只是为了组织:
git checkout master # same as `arc flow master`
git pull origin master # pull latest master
arc flow graft-D999 # create and checkout a new child branch you are calling "graft-D999" (name it appropriately)
arc graft D999 --skip-landed # graft their entire dependency tree onto your branch "graft-D999"
您的依赖树现在如下所示:
master
└──graft-D999
└──new_feature_1
└──new_feature_2
出色的!很好而且有组织。现在您可以查看“new_feature_2”并编译和测试它。但请注意,“master”和“graft-D999”将是完全相同的分支,但这没关系。
如何安装 Uber 的 arcanist 分支
(如果您想开始使用arc flow
and arc cascade
在你自己的 git 工作流程中):
注意:Arcanist 在 Windows 上运行(在适用于 Windows 的 git https://git-scm.com/download/wingit bash 终端)、Mac 和 Linux。我将仅介绍 Linux 安装说明。要获得在其他系统中安装的帮助,请首先查看下面的参考资料。
Linux Ubuntu 安装:
cd
到您希望安装文件所在的位置,然后执行以下操作:
# 1. Obtain the Uber fork of the arcanist program by cloning it into an "uber" directory.
mkdir uber
git clone https://github.com/uber/arcanist.git uber
# 2. Symbolically link the `arc` program to your ~/bin directory so you can call `arc` from anywhere.
# - this assumes that ~/bin is in your PATH.
# Ensure the ~/bin dir exists; if just creating this dir for the first time you may need to log out of Ubuntu
# and log back in AFTER running the `mkdir` command below, in order to force your ~/.profile script to
# automatically add ~/bin to your PATH (assuming your ~/.profile script does this, as default Ubuntu scripts do).
mkdir -p ~/bin
ln -s $PWD/uber/arcanist/bin/arc ~/bin
现在尝试运行arc
。它应该失败并显示以下消息:
$ arc
ERROR: Unable to load libphutil. Put libphutil/ next to arcanist/, or update your PHP 'include_path' to include the parent directory of libphutil/, or symlink libphutil/ into arcanist/externals/includes/.
因此,请执行以下操作:
# 3. Obtain the libphutil program.
# - Note that git cloning it like this `git clone https://github.com/phacility/libphutil.git` will NOT work anymore
# for Uber's fork of arcanist because the libphutil project is now empty. So, do this instead:
sudo apt install libphutil
# 4. symbolically link the libphutil program into arcanist.
# First, we need to know where it is installed.
dpkg -L libphutil
# Now look at the output from the above command. Mine shows libphutil is installed in "/usr/share/libphutil/",
# so do the following:
ln -s /usr/share/libphutil uber/arcanist/externals/includes
现在测试arc
命令,您应该看到以下内容:
$ arc
Usage Exception: No command provided. Try `arc help`.
Run arc help
查看帮助菜单,或者arc help --full
获取完整的帮助菜单。
让我们来看看flow
and cascade
证明它们仅出现在 Uber 分叉的帮助菜单中(但不适用于主要奥术师):
正在寻找flow
在完整的帮助菜单中:
$ arc help --full | grep flow
This workflow is primarily useful for writing scripts which integrate
soft version of '' used by other workflows.
flow [options]
flow name [options]
flow name upstream [options]
step in the standard Differential pre-publish code review workflow.
The workflow selects a target branch to land onto and a remote where
Consulting mystical sources of power, the workflow makes a guess
step in the standard Differential pre-publish code review workflow.
The workflow selects a target branch to land onto and a remote where
Consulting mystical sources of power, the workflow makes a guess
code review workflow.
The workflow selects a target branch to land onto and a remote where
And cascade
在完整的帮助菜单中:
$ arc help --full | grep -A 4 cascade
cascade [--halt-on-conflict] [rootbranch]
Automates the process of rebasing and patching local working branches
and their associated differential diffs. Cascades from current branch
if branch is not specified.
--
Rather than aborting any rebase attempts, cascade will drop the
user
into the conflicted branch in a rebase state.
参考:
- Pacility的奥术师(缺少
arc flow
and arc cascade
特征):https://github.com/phacility/arcanist https://github.com/phacility/arcanist
- Uber 的 Arcanist 分叉(有
arc flow
and arc cascade
添加的功能):https://github.com/uber/arcanist https://github.com/uber/arcanist
- 奥术师用户指南:https://secure.phabricator.com/book/phabricator/article/arcanist/ https://secure.phabricator.com/book/phabricator/article/arcanist/--> 请参阅“安装 Arcanist”部分,了解如何在 Windows、Mac、Linux 或 FreeBSD 中安装它的说明。
- 错误:无法加载 libphutil https://stackoverflow.com/questions/45278745/error-unable-to-load-libphutil/60764589#60764589
Related:
- 像时尚树一样的 git 分支的输出 https://stackoverflow.com/questions/2421011/output-of-git-branch-in-tree-like-fashion/54897514#54897514