Some notes: 1) This text does not include all of the uhs, ahs and ums from my speech but is otherwise written according to my actual speech in the video. 2) The timecodes are to give a pretty good idea of where you are in the video. 3) Two letters in quotes (e.g. "ls" or "dp") are commands and each letter should be pronounced (e.g. "ls" should be spoken as el es) 4) Some vocabulary/slang: cruft = junk, extra stuff that gets in the way and is unnecessary frickin = a nice way of saying f*cking me self = a slang way of saying myself BEGIN TRANSCRIPT ---------------- This is a quick and dirty video on rolling patches in Drupal. It's quick in the sense that I don't get into a whole lot of detail and it is dirty because there is a bunch of cruft on my screen because I sort of did this video on-the-fly, so, you'll just have to ignore that and play along. We're going to look at two utilities for creating patches, diff and CVS diff. Diff you can use if you don't have access to CVS or if you're a little bit afraid of it. It's a stand-alone way of getting a patch made. And then with CVS diff obviously you will be running that against CVS and it's a really nice, fast way to get a good patch made. So, we're going to start off by going to the handbooks and we'll go to Contributing to Development. And then we will go to the Patches section. When you get into Patches you're going to see there is "HOWTO: Create patches" as well as "HOWTO: Submit patches for Drupal" and you really should read both of them and become familiar with both of them. 0:57 We're going to start with "HOWTO: Create patches" which covers the basics about diff. And here in the middle here is the command that we're going to use when we do diff, which is the stand-alone. So, I need to go get my files. I want to make sure that I have the latest files to work from. So, I'm gonna go ahead and just go to the project page here because I happen to know what it is. And when I get here I'm going to go down to the tarballs. These are the official releases but I'm going to use the development version so that I can make sure I have the latest stuff and then they can back-port this if they want to. And let me open it up. And then we'll go have a look see here because it's on my desktop. So, and here's the README file which is the file I actually want to edit. I'm going to open that up in my text editor. 2:00 And I'm going, the first thing I'm going to do is save it as a new file so that the diff can compare two files and get a difference. So I'm just going to save it with the word "new" and I need to make sure I save into the right place as well. I always save, whenever I'm doing diffs, save the new file that your working on to the same location as the original. If you do diffs from strange locations it can be, you might end up making a patch that people can't actually apply on their end. And now I have my new file so I'm going to type in the changes that I want to make to the file. It would be the same thing if this was just, you know, code rather than a README, you just, whatever changes are that you're making go ahead and make them and then we will find out what the difference is when we run our command. 3:00 And I just need to type in all this good stuff that I'm changing. OK. And there we go. So I'll save this file. And now I'm going to go back to that diff page that we were looking so that we can review our command. And while that's coming up I can go and open up my terminal since we're doing command line here. And I'm going to change, I'm going to "cd" to the directory where that, where the files are, which is on my desktop and there's an "ls", a listing of files. You can see the new file is included in that directory now. 4:04 And here on the page, this is our command, so that's pretty much what I'm going to type in. So it's diff dash "up" and then the old file name, which is just README, and then my new file name. And then I want to output this to a patch file so I'm going to give it a, the patch file a name that sort of makes sense and people can understand what's going on here. You can save the patch file anywhere you want, you just need to type the path into this name and it will save it into that directory for you. So now when I list these, the contents of this directory, I'm going to see that my, my new patch file is in there. And there it is. 5:00 So that's doing regular diff, just a sort of stand-alone, local kind of a thing. And let's open it up and you can see what this one looks like. Red's been removed, green's been added, the top lists the file names - which aren't all that important. Now we're going to go ahead and do CVS diff. So, the first thing I need to do, is I already have a checkout of this module, a CVS checkout, so I need to go to where I have that CVS checkout and I need to update it and make sure that I have the latest files. So update "dp". Get the latest files, yes. Ok, I got the latest stuff so now I can begin working with it. So let's go ahead and open up that README file from here. 6:00 And you can see I've got a checkout of all the modules here but I'm just looking for imagecache. Go in. There's my README so, open her up. And again now I'm just, you know, I need to put in my text changes. I don't have to create a new file or anything like I did with the regular diff because what's going to happen is, CVS diff is going to just compare my local file to the one that is actually up at drupal.org. So that's how it's going to find the difference, is it's actually going to go out and find the latest file up there. So, I'm just going to type my junk in here and you can play along at home. Generally the, the CVS diffs are preferred by the maintainers because when you do it that way you will get the indication of the actual revision of the file which is useful information. 7:09 Ah, you also notice that there's a bunch of lines here. There's a bunch of whitespace on this file and typically I would remove that but in a patch you should not edit anything other than the actual text, the actual code that you're changing. So, that was diff what we just did. Now what we want to do is CVS diff so I'm going to go down to "Submit patches for Drupal" because that's, actually has the CVS diff information in it. And I will as the internet... here we go. So, again, you should read this whole page, it's got good stuff. This is our command that we are going to use. So, back to my terminal and we're going to go, we're already in the directory so we're just going to go ahead and write this command in. 7:57 So, I want to do cvs diff "up" and just need to put the file name. There's no new file. And again output it to a patch which I want to have saved locally in this directory so I can keep track of it, me self. And once I run that, list my files and boom, there's my patch. Easy. We'll take a look at this one and we can see how this one is different. When you look at this you'll see that at the top it looks a little bit different and there's this line that actually indicates the exact version of the file that I did the diff against and so a developer can be absolutely certain of which one I patched against. So, we'll close these and now I need to actually upload my patch. That's it, the patch is done so now I just need to upload it. If I go to issues and then I can submit an issue. 8:57 I would pick my project. If it was Drupal you would pick Drupal, but since this is for a particular contributed module I'll do imagecache. I need to fill in some information here. Version is the 5 1 dev because that is what I just patched against. And this is a documentation change and it's a feature request and you can fill out the rest of this information as well. I'm not going to do that because I actually already have an issue for this. So, I made an issue earlier so I wouldn't forget to actually do the patch. So, I'm going to go into that issue that already exists and I'll get rid of these frickin emails. And so here it is and to attach it I'll do a follow up to the initial issue. And I need to change this to dev because I originally did it against 1.2, 1.2 was the original version that I was using but the patch itself is actually against the development version. 10:05 And I'm going to just add a little description here so that people can know what I'm attaching and such. Also going to just explain that I changed the version from 1.2 to dev because I'm doing this against the CVS 5 branch and not against the actual release. And now once that's done I need to attach the actual patch. Doesn't do much good if you don't actually upload it. So, go back in here and find my patch which is in my CVS directory where I created it. 11:02 There's my patch. We'll add that. You can preview whenever you submit but if you have an attachment it zaps it so I'm just going to submit it. I don't have crazy text or anything that I need to check formatting on. And that's uploading it and boom, there it is. And if you click on that you'll see that this is the same thing that I had on my local server. Now one thing I realized after I did was that I forgot to change the status from active to patch (code needs review). So, I'm not going to bore you with the details of that and I'll go back and change that and that is rolling a patch in Drupal.