1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
Working with stack of patches Quick Reference
=============================================
Working on Firefox, we strongly recommend working with stack of patches.
Patches should be small and could be landed in the order used to push them.
This also helps to breakdown the work for different reviewers.
As it can be complex for new comers, this documentation explains the
various commands.
In Phabricator, the stack can be seen in the `Revision Contents` section.
The top of the stack (most recent change) is first in the list.
This is also sometimes called "stack of revisions", "stack of commits" or "series of commits".
**Example:**
.. image:: img/example-stack.png
For the overall quick reference guide, see the :ref:`Firefox Contributors Quick Reference <Firefox Contributors' Quick Reference>`
Visualize the stack
-------------------
.. code-block:: shell
# Mercurial
$ hg wip
# Git
$ git log
Merge two patches
-----------------
It can happen that, instead of updating a patch, a new revision is
created on Phabricator. For this, merge the patches locally:
.. code-block:: shell
# Mercurial
# Mark the patch to be merged with "roll" (key: "r")
# or "fold" (key: "f")
$ hg histedit
# Git
# Replace "pick" by "squash" or "fixup"
$ git rebase -i
Then, push to Phabricator and abandon the old change.
Submitting the first patch on the stack
---------------------------------------
There are times when you are working on multiple patches and
just want to submit the first one. For this, you can use:
.. code-block:: shell
$ moz-phab submit .
Reorder the stack
-----------------
Sometimes, we want to change the order the patches in the stack.
Fortunately, VCS support this easily.
.. code-block:: shell
# Mercurial
# Just change the order the patch. The tool should highlight
# potential risks of conflicts.
# Note that ctrl+c works well if used
$ hg histedit
# Git
# In the editor, just move the line below/above
# Remove everything if you want to cancel the operation
$ git rebase -i
Make a change on a patch at the beginning of the stack
------------------------------------------------------
In some cases, the reviewer is asking for a change at the bottom of the stack (ie not at the top).
So, a simple `hg/git commit --amend` would not work.
In such case, the following approach can be used:
.. code-block:: shell
# Mercurial
# hg will try to guess in which an unambiguous prior commit
$ hg absorb
# if this doesn't work, create a temporary commit
# and merge it using "fold" or "roll"
$ hg histedit
# Git
$ git commit --fixup <hash of the commit>
Removing patches in the stack
-----------------------------
To remove a patch in the stack:
.. code-block:: shell
# Mercurial
# select "drop" (letter "d")
$ hg histedit
# Git
# Replace "pick" by "drop"
# Or simply remove the line for this commit
$ git rebase -i
Rebasing the stack
------------------
As the codebase moves fast, it can be necessary to pull changes from
mozilla-central before landing the changes.
.. code-block:: shell
# Mercurial
# First, see where your patches are in the stack
$ hg wip
# Then, rebase it:
# If you are a beginner, don't hesitate to add "--dry-run"
$ hg pull
$ hg rebase -b . -d central
# Git
$ git remote update
$ git rebase mozilla/central
Reorganizing the stack in Phabricator
-------------------------------------
.. code-block:: shell
$ moz-phab reorg [start_rev] [end_rev]
allows you to reorganize the stack in Phabricator.
If you've changed the local stack by adding, removing or moving the commits around, you need to change the parent/child relation of the revisions in Phabricator.
.. code-block:: shell
$ moz-phab reorg
command will compare the stack, display what will be changed and ask for permission before taking any action.
.. note::
Note that reviewbot will not restart the analysis.
|