@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1@title Arcanist User Guide: arc diff
2@group userguide
3
4Guide to running `arc diff`, to send changes to Differential for review.
5
6This article assumes you have `arc` installed and running; if not, see
7@{article:Arcanist User Guide} for help getting it set up.
8
9Before running `arc diff`, you should create a `.arcconfig` file. If someone
10set things up for you, they may already have done this. See
11@{article:Arcanist User Guide: Configuring a New Project} for instructions and
12information.
13
14= Overview =
15
16While `arc` has a large number of commands that interface with various
17Phorge applications, the primary use of `arc` is to send changes for
18review in Differential (for more information on Differential, see
19@{article:Differential User Guide}). If you aren't familiar with Differential,
20it may be instructive to read that article first to understand the big picture
21of how the code review workflow works.
22
23You send changes for review by running `arc diff`. The rest of this document
24explains how to use `arc diff`, and how the entire review workflow operates for
25different version control systems.
26
27= Subversion =
28
29In Subversion, `arc diff` sends the **uncommitted changes in the working copy**
30for review.
31
32To **create a revision** in SVN:
33
34 $ nano source_code.c # Make changes.
35 $ arc diff
36
37This will prompt you for information about the revision. To later **update an
38existing revision**, just do the same thing:
39
40 $ nano source_code.c # Make more changes.
41 $ arc diff
42
43This time, `arc` will prompt you to update the revision. Once your revision has
44been accepted, you can commit it like this:
45
46 $ arc commit
47
48= Git =
49
50In Git, `arc diff` sends **all commits in a range** for review. By default,
51this range is:
52
53 `git merge-base origin/master HEAD`..HEAD
54
55That's a fancy way of saying "all the commits on the current branch that
56you haven't pushed yet". So, to **create a revision** in Git, run:
57
58 $ nano source_code.c # Make changes.
59 $ git commit -a # Commit changes.
60 $ arc diff # Creates a new revision out of ALL unpushed commits on
61 # this branch.
62
63The `git commit` step is optional. If there are uncommitted changes in the
64working copy then Arcanist will ask you to create a commit from them.
65
66Since it uses **all** the commits on the branch, you can make several commits
67before sending your changes for review if you prefer.
68
69You can specify a different commit range instead by running:
70
71 $ arc diff <commit>
72
73This means to use the range:
74
75 `git merge-base <commit> HEAD`..HEAD
76
77However, this is a relatively advanced feature. The default is usually correct
78if you aren't creating branches-on-branches, juggling remotes, etc.
79
80To **update a revision**, just do the same thing:
81
82 $ nano source_code.c # Make more changes.
83 $ git commit -a # Commit them.
84 $ arc diff # This prompts you to update revision information.
85
86The `git commit` step is optional. If there are uncommitted changes in the
87working copy then Arcanist will ask you to amend them to the commit.
88
89When your revision has been accepted, you can usually push it like this:
90
91 $ arc land <branch> # Merges <branch> into master and pushes.
92
93`arc land` makes some assumptions about your workflow which might not be
94true. Consult the documentation before you use it. You should also look at
95`arc amend`, which may fit your workflow better.
96
97= Mercurial =
98
99In Mercurial, `arc diff` sends **all commits in a range** for review. By
100default, this range is changes between the first non-outgoing parent of any
101revision in history and the directory state. This is a fancy way of saying
102"every outgoing change since the last merge". It includes any uncommitted
103changes in the working copy, although you will be prompted to include these.
104
105To **create a revision** in Mercurial, run:
106
107 $ nano source_code.c # Make changes.
108 $ hg commit # Commit changes.
109 $ arc diff # Creates a new revision out of ALL outgoing commits
110 # on this branch since the last merge.
111
112The `hg commit` step is optional. If there are uncommitted changes in the
113working copy then Arcanist will ask you to create a commit from them.
114
115Since it uses **all** the outgoing commits on the branch, you can make several
116commits before sending your changes for review if you prefer.
117
118You can specify a different commit range instead by running:
119
120 $ arc diff <commit>
121
122This means to use the range from that commit to the directory state. However,
123this is an advanced feature and the default is usually correct.
124
125To **update a revision**, just do the same thing:
126
127 $ nano source_code.c # Make changes.
128 $ hg commit # Commit changes.
129 $ arc diff # This prompts you to update revision information.
130
131The `hg commit` step is optional. If there are uncommitted changes in the
132working copy then Arcanist will ask you to create a commit from them (or amend
133them to the previous commit if supported).
134
135When your revision has been accepted, push it normally. (`arc` does not have
136push integration in Mercurial because it can't force merges and thus can't
137guarantee it will be able to do anything useful.)
138
139= Pushing and Closing Revisions =
140
141After changes have been accepted, you generally push them and close the
142revision. `arc` has several workflows which help with this, by:
143
144 - squashing or merging changes from a feature branch into a master branch
145 (if relevant);
146 - formatting a good commit message (see //Write Sensible Commit Messages// in
147 @{article:Writing Reviewable Code}) with all the information from
148 Differential; and
149 - automatically closing the revision.
150
151You don't need to use any of these workflows: you can just run `git push`,
152`hg push` or `svn commit` and then manually close the revision from the web.
153However, these workflows can make common development strategies more convenient,
154and give you better commit messages in the repository. The workflows `arc`
155supports are:
156
157 - `arc land`: Works in Git if you develop in feature branches. Does a merge
158 or squash-merge from your feature branch into some master branch, provides
159 a detailed commit message, pushes master, and then deletes your branch.
160 - `arc amend`: Works in Git if you can't use `arc land`. Amends HEAD with
161 a detailed commit message.
162 - `arc commit`: Works in Subversion. Runs `svn commit` with a detailed commit
163 message.
164 - `arc close-revision`: Works anywhere, closes a revision from the CLI
165 without going through the web UI.
166
167You can use `arc help <command>` for detailed help with any of these.
168Differential will make a guess about a next step on accepted revisions, but it
169may not be the best next step for your workflow.
170
171Phorge will also automatically close revisions if the changes are pushed
172to a repository that is tracked in Diffusion. Specifically, it will close
173revisions based on commit and tree hashes, and `Differential Revision`
174identifiers in commit messages.
175
176If you push to an untracked repository (or `arc` can't figure out that it's
177tracked), `arc land`, `arc amend` and `arc commit` will implicitly run
178`arc close-revision`.
179
180= General Information =
181
182This information is not unique to a specific version control system.
183
184== Force Diff Only ==
185
186You can create just a diff (rather than a revision) with `--preview` (or
187`--only`, but this disables other features). You can later use it to create
188or update a revision from the web UI.
189
190== Other Diff Sources ==
191
192You can create a diff out of an arbitrary patch file by using `--raw` and piping
193it to stdin. In most cases this will only create a diff, not a revision. You
194can use the web UI to create a revision from the diff, or update an existing
195revision.
196
197== Force Create / Update ==
198
199`arc` uses information about the working copy (like the path, branch name, local
200commit hashes, and local tree hashes, depending on which version control system
201you are using) to figure out whether you intend to create or update a revision.
202If it guesses incorrectly, you can force it to either create or update a
203revision with:
204
205 $ arc diff --create # Force "create".
206 $ arc diff --update <revision> # Force "update".
207
208You can figure out what `arc` believes to be in the working copy with
209`arc which`.