Bazaar

Bazaar

 




Wiki Tools

  • Find Page
  • Recent Changes
  • Page History
  • Attachments

Getting Drupal

Four Kitchens keeps a copy of Drupal source code in a Bazaar repository. Bazaar is a revision control system, which lets programmers like yourself track the changes in source code over time. If you would like to use Bazaar to do Drupal work on the core, then download Bazaar from the DownloadBzr page and come right back here. Be careful though! You don't want a version of Bzr that is too old. Make sure that you get one that is at least version 1.0.

The first thing you'll need to know about bzr is how to get the drupal code. Getting your own copy of the Drupal core via bzr is very easy but can take some time. You can get the drupal branch by running:

$ bzr branch bzr://vcs.fourkitchens.com/drupal/7 my-drupal

The first thing you will see is a progress bar. Don't worry if the progress bar looks stuck. Bzr is just working hard and not being very open about the stuff its doing behind the scenes. After a few moments, you'll have you own copy of drupal core in the "my-drupal" directory. Congratulations!

Updating Drupal

Your drupal is getting older every moment. From time to time you will want to fix this by updating your drupal branch. You can do this by changing into the my-drupal directory and performing the following:

$ bzr pull

Bzr will download any changes that are happened recently and make sure that they're here. We update the copy of the drupal core that you branched from once an hour, but you can run "bzr pull" as often as you want.

Using my-drupal

One of the things we do with our drupal branch is that we use it for a working drupal install. You can do this too. You can move my-drupal to wherever your webserver has access and set it up just the same way.

Making changes to my-drupal

Its O.K. if you want to make changes in the my-drupal directory. Just edit the files the same way as you would always edit them. If you add new files or directories though, make sure that you tell bzr that they are there by running:

$ bzr add filename

Also, if you want to rename old files and directories, then you should use this command instead of mv:

$ bzr mv OldFilename NewFilename

Saving changes to my-drupal

One of the nice things about a revision control system is that we can checkpoint the way that my-drupal looks. That way, if there is a problem, we can do things like go back to the way things looked before, or compare how things looked at different points in time. We save these changes by running:

$ bzr commit -m "I changed my-drupal so that the theme looked better"

Don't worry if you forget about the -m part. If you just run "bzr commit", then bzr will start up an editor so that you can type your message in on the fly.

There is a small catch to saving your changes. If you save your own changes to my-drupal, then my-drupal really, truly becomes yours. That means that instead of running the "bzr pull" command to update my-drupal, you will instead have to do:

$ bzr merge
$ bzr commit -m"Merged from official drupal"

Keeping a local mirror

If you intend to do a lot of core hacking, the following procedure is recommended instead of hacking your local install of my-drupal directly:

Leave my-drupal as a local mirror. Do this by setting up a cron run which runs the 'bzr pull' command in my-drupal. You now have an exact copy of that mirror locally.

Anytime you want to hack core, create another local branch off of the my-drupal branch. You can do this in one of two ways:

1. Copy the contents of the my drupal folder to another folder. You can name this folder whatever you like--in the examples below we named it 'foo', and the new folder sits in the same directory as the my-drupal folder.

  • -- OR --

2. From the directory where the my-drupal folder exists, run the following command:

$ bzr branch my-drupal foo
  • where 'foo' is the name of the new folder

Now you can hack away at the contents of the foo folder. Since the cron script you set up is keeping your local mirror in sync with the main mirror, your main mirror will contain the latest changes in HEAD. From time to time you'll want to merge the changes that are happening in HEAD into the foo folder.. To do this, navigate to the foo folder and issue the following command:

$ bzr merge ../my-drupal

This merges the changes in your local mirror into the branch in the foo folder. Any conflicts that occured will need to be resolved. Once that is accomplish, commit the merge with the following command (once again issued from the foo folder):

$ bzr commit -m"Merged from official drupal"

Sending back your changes to my-drupal

If you really like your changes to your local branch and want to send them back to the drupal developers, then you can do that too. There are a lot of ways to do that, so if you have something you want to send back to us, contact either chx, hunmonk or JamesBlackwell. We'll show you how to do it.

Sending changes via bzr

One of the ways that you can have people get changes from your my-drupal branch is to make a copy of it in a public place. You can do this in any way that you want. Bzr has built-in support to push your my-drupal branch too, if you have a public web site that you can access with ssh. To make your my-drupal branch public you could cd into your my-drupal branch and do:

$ bzr push sftp://username@machinename/home/username/public_html/branches/

In this example, the my_drupal branch will be available at http://machinename/~username/branches/my-drupal

You can update this copy whenever you want by rerunning the bzr push command. If you get tired of typing the long url in, you can use the --remember option to bzr push so that it remembers for you.

Now that you've pushed your branch, other people can either make their own my-drupal based upon yours, or they can merge it in their own my-drupal.

Sending changes via email

This part needs to be written to match development specs. Needs to cover:

  • How to pick revisions
  • How to redirect into file
  • Where to email

You want to roll a patch?

bzr diff --diff-options -F^f ../head

Extra useful Tips

  • Can I have more than one my-drupal?
    • Yes. You can push and pull as many branches as you like. Just put them in different directories.

  • Do I have to branch off of the official drupal branch?
    • No. You can branch off of your own my-drupal branch. Again,put it in a different directory.
  • Where do I get more drupal help?
    • "bzr help" is great. If you're looking for advanced commands, you can sneak a peak at "bzr help commands"