1Applying patches 2================ 3 4If you are a Skia committer and have been asked to commit an 5externally-submitted patch, this is how to do it. (This technique is useful in 6other situations too, like if you just want to try out somebody else's patch 7locally.) 8 9Notes: 10 11 * For the examples below, we will assume that this is the change you want 12 to patch into your local checkout: https://codereview.appspot.com/6201055/ 13 * These instructions should work on Mac or Linux; Windows is trickier, 14 because there is no standard Windows "patch" tool. 15 16See also [Contributing Code for The Chromium Projects] 17(http://dev.chromium.org/developers/contributing-code#TOC-Instructions-for-Reviewer:-Checking-in-the-patch-for-a-non-committer). 18 19If you use `git cl`, then you should be able to use the shortcut: 20 21~~~~ 22git cl patch 6201055 23~~~~ 24 25If you use `gcl`, or the above doesn't work, the following should always work. 26 271. Prepare your local workspace to accept the patch. 28 29 * cd into the root directory (usually `trunk/`) of the workspace where you 30 want to apply the patch. 31 * Make sure that the workspace is up-to-date and clean (or "updated and 32 clean enough" for your purposes). If the codereview patch was against 33 an old revision of the repo, you may need to sync your local workspace 34 to that same revision. 35 362. Download the raw patch set. 37 38 * Open the codereview web page and look for the "Download raw patch set" 39 link near the upper right-hand corner. Right-click on that link and copy 40 it to the clipboard. (In my case, the link is 41 https://codereview.appspot.com/download/issue6201055_1.diff ) 42 * If you are on Linux or Mac and have "curl" or "wget" installed, you can 43 download the patch from the command line: 44 45 ~~~~ 46 curl https://codereview.appspot.com/download/issue6201055_1.diff 47 --output patch.txt 48 # or... 49 wget https://codereview.appspot.com/download/issue6201055_1.diff 50 --output-document=patch.txt 51 ~~~~ 52 53 * Otherwise, figure out some other way to download this file and save it as 54 `patch.txt` 55 563. Apply this patch to your local checkout. 57 58 * You should still be in the root directory of the workspace where you want 59 to apply the patch. 60 61 ~~~~ 62 patch -p1 <patch.txt 63 ~~~~ 64 65 * Then you can run `diff` and visually check the local changes. 66 674. Complications: If the patch fails to apply, the following may be happening: 68 69 * Wrong revision. Maybe your local workspace is not up to date? Or maybe the 70 patch was made against an old revision of the repository, and cannot be applied 71 to the latest revision? (In that case, revert any changes and sync your 72 workspace to an older revision, then re-apply the patch.) 73 74