stack_quickref.rst (3244B)
1 Working with stack of patches Quick Reference 2 ============================================= 3 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. 7 8 As it can be complex for newcomers, this documentation explains the 9 various commands. 10 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. 13 14 This is also sometimes called "stack of revisions", "stack of commits" or "series of commits". 15 16 **Example:** 17 18 .. image:: img/example-stack.png 19 20 21 For the overall quick reference guide, see the :ref:`Firefox Contributors Quick Reference <Firefox Contributors' Quick Reference>` 22 23 Visualize the stack 24 ------------------- 25 26 .. code-block:: shell 27 28 $ git log 29 $ git log --graph --oneline --all 30 31 32 Merge two patches 33 ----------------- 34 35 It can happen that, instead of updating a patch, a new revision is 36 created on Phabricator. For this, merge the patches locally: 37 38 .. code-block:: shell 39 40 # Replace "pick" by "squash" or "fixup" 41 $ git rebase -i 42 43 Then, push to Phabricator and abandon the old change. 44 45 46 Submitting the first patch on the stack 47 --------------------------------------- 48 49 There are times when you are working on multiple patches and 50 just want to submit the first one. For this, you can use: 51 52 .. code-block:: shell 53 54 $ moz-phab submit . 55 56 57 Reorder the stack 58 ----------------- 59 60 Sometimes, we want to change the order the patches in the stack. 61 Fortunately, VCS support this easily. 62 63 .. code-block:: shell 64 65 # In the editor, just move the patches to the line below/above to 66 # reorder commits. 67 # Remove everything if you want to cancel the operation. 68 $ git rebase -i 69 70 71 Make a change on a patch at the beginning of the stack 72 ------------------------------------------------------ 73 74 In some cases, the reviewer is asking for a change at the bottom of the stack (ie not at the top). 75 So, a simple `git commit --amend` would not work. 76 77 In such case, the following approach can be used: 78 79 .. code-block:: shell 80 81 $ git commit --fixup <hash of the commit> 82 83 84 Removing patches in the stack 85 ----------------------------- 86 87 To remove a patch in the stack: 88 89 .. code-block:: shell 90 91 # Replace "pick" by "drop" 92 # Or simply remove the line for this commit 93 $ git rebase -i 94 95 96 Rebasing the stack 97 ------------------ 98 99 As the codebase moves fast, it can be necessary to pull changes from 100 mozilla-central before landing the changes. 101 102 .. code-block:: shell 103 104 $ git remote update 105 $ git rebase mozilla/central 106 107 108 Reorganizing the stack in Phabricator 109 ------------------------------------- 110 111 .. code-block:: shell 112 113 $ moz-phab reorg [start_rev] [end_rev] 114 115 allows you to reorganize the stack in Phabricator. 116 117 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. 118 119 .. code-block:: shell 120 121 $ moz-phab reorg 122 123 command will compare the stack, display what will be changed and ask for permission before taking any action. 124 125 .. note:: 126 127 Note that reviewbot will not restart the analysis.