1 Working with stack of patches Quick Reference
2 =============================================
4 Working on Firefox, we strongly recommend working with stack of patches.
5 Patches should be small and could be landed in the order used to push them.
6 This also helps to breakdown the work for different reviewers.
8 As it can be complex for newcomers, this documentation explains the
11 In Phabricator, the stack can be seen in the `Revision Contents` section.
12 The top of the stack (most recent change) is first in the list.
14 This is also sometimes called "stack of revisions", "stack of commits" or "series of commits".
18 .. image:: img/example-stack.png
21 For the overall quick reference guide, see the :ref:`Firefox Contributors Quick Reference <Firefox Contributors' Quick Reference>`
38 It can happen that, instead of updating a patch, a new revision is
39 created on Phabricator. For this, merge the patches locally:
44 # Mark the patch to be merged with "roll" (key: "r")
45 # or "fold" (key: "f")
49 # Replace "pick" by "squash" or "fixup"
52 Then, push to Phabricator and abandon the old change.
55 Submitting the first patch on the stack
56 ---------------------------------------
58 There are times when you are working on multiple patches and
59 just want to submit the first one. For this, you can use:
69 Sometimes, we want to change the order the patches in the stack.
70 Fortunately, VCS support this easily.
75 # Just change the order of the patches. The tool should highlight
76 # potential risks of conflicts.
77 # Note that ctrl+c works well if used.
81 # In the editor, just move the patches to the line below/above to
83 # Remove everything if you want to cancel the operation.
87 Make a change on a patch at the beginning of the stack
88 ------------------------------------------------------
90 In some cases, the reviewer is asking for a change at the bottom of the stack (ie not at the top).
91 So, a simple `hg/git commit --amend` would not work.
93 In such case, the following approach can be used:
98 # hg will try to guess in which an unambiguous prior commit
101 # if this doesn't work, create a temporary commit
102 # and merge it using "fold" or "roll"
106 $ git commit --fixup <hash of the commit>
109 Removing patches in the stack
110 -----------------------------
112 To remove a patch in the stack:
114 .. code-block:: shell
117 # select "drop" (letter "d")
121 # Replace "pick" by "drop"
122 # Or simply remove the line for this commit
129 As the codebase moves fast, it can be necessary to pull changes from
130 mozilla-central before landing the changes.
132 .. code-block:: shell
135 # First, see where your patches are in the stack
138 # If you are a beginner, don't hesitate to add "--dry-run"
140 $ hg rebase -b . -d central
145 $ git rebase mozilla/central
148 Reorganizing the stack in Phabricator
149 -------------------------------------
151 .. code-block:: shell
153 $ moz-phab reorg [start_rev] [end_rev]
155 allows you to reorganize the stack in Phabricator.
157 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.
159 .. code-block:: shell
163 command will compare the stack, display what will be changed and ask for permission before taking any action.
167 Note that reviewbot will not restart the analysis.