B.2. Patch Maker 2.0

Patch Maker is a free software program written by Gervase Markham that lets you change and improve Mozilla's user interface by using only a nightly build.

When you don't build the Mozilla source tree yourself, finding and getting to the files that need to be edited in Mozilla can be difficult. However, you can use the various Patch Maker commands in Build Mode to extract files from the right JARs, add them to your Patch Maker project, edit them, and create the patches, all in an integrated and easily traceable way. These patches can then be submitted back to mozilla.org so that developers working in the source tree can apply and test them. See the Section B.2.2 section later in this appendix for more information about using Patch Maker in this way.

This process is possible because Mozilla's user interface is written in XUL, JavaScript, and CSS, and interpreted at runtime. Because understanding CVS or compiling code isn't necessary, Patch Maker greatly lowers the barrier to entry for contributing code to Mozilla. Significant patches, such as one used for draggable toolbars, are made using this tool.

Patch Maker runs under Linux and Windows, and is experimental on Mac OS X. The latest version of Patch Maker is at http://www.gerv.net/software/patch-maker/. This application can be used in one of two modes. CVS mode is used by developers who develop and maintain code in a CVS tree and make their changes in the tree. Build mode makes it possible to produce patches that fix some bugs in Mozilla without downloading and compiling the source.

B.2.1. CVS Mode

In CVS mode, Patch Maker manages and tracks multiple patches to a bit of software. It uses unique tags (patch references such as bug numbers) to separate patches, knows what files are in each patch, and can perform operations on them. In CVS mode, Patch Maker can greatly speed up the process of creating, diffing, uploading, refreshing, and checking in a patch. CVS mode's basic commands for Patch Maker give you an idea of how developers working in the Mozilla source tree can use it to work more efficiently with patches and diffs. The basic CVS mode commands are described in Table B-3.

Table B-3. Patch Maker's CVS mode commands

Command

Description

pmlist

Shows the file list.

pmadd <filename>

Adds filename to the file list.

pmremove <filename>

Removes filename from the file list.

pmdiff

Does a cvs diff -u of all files in the file list. Extra arguments, such as -w, are passed through to diff. This command won't clobber your old diff if the new one has a size of zero.

pmview

Brings up your diff in an editor window.

pmupdate

Updates CVS on all files in the file list. Extra arguments to this command are passed through to the CVS update.

pmpatch

Patches your diff into your CVS tree. Takes a -R to back the patch out again.

pmedit <pattern>

Brings up files matching the pattern in your editor. The pattern is a glob, not a regexp. If there are no arguments supplied, then all files are opened.

pmwhich

Prints the current patch reference.

pmswitch <patchref>

Changes Patch Maker to work with a new patch reference. It automatically creates a pmupdate( ) and a pmpatch( ) (which won't have any effect if the patch is already applied.)

pmgrep <pattern>

Greps for pattern in all of the current patch's files. Good if you can't remember where you put some code.

pmcopy

Copies all files in the file list to their positions in your installed Mozilla tree. Takes a -f argument to force copying of all the files.

pmsetpath

Points Patch Maker to your current Mozilla-built installation's chrome directory. Use /usr/src/mozilla/dist/bin/chrome/ if you build yourself.

pmunjar

Unjars the chrome in your setpath installation.

pmexecute

Runs the executable in the setpath installation. Extra arguments to this command, such as &, are passed through to the executable.

pmcheckin

Runs pmwhich, pmupdate, pmdiff, and pmview to show what you are about to change, and then asks you if you really want to check in.

pmcvsadd

Does a CVS add of all files. Previously added files fail with a harmless message. You need to use this command for new files so the CVS diff will work properly.

See the CVS Mode instructions at the Patch Maker web site for instructions on how to use Patch Maker with your source tree.

B.2.2. Build Mode

The fact that Mozilla's user interface is interpreted at runtime rather than compile time makes it possible to change the interface and see your changes in the browser. In Build mode, Patch Maker can help you make these changes and apply, package, and send them to the developers who own the interface modules you edit. The Patch Maker's Build mode is a boon for Mozilla developers who do not build the CVS tree, but who want to take part in developing the interface, in the bug-fixing process, and in other aspects of Mozilla development.

In Mozilla-specific mode, which is triggered when you sit in a Mozilla build install point's chrome directory, you can make patches to Mozilla chrome without using a CVS tree. Patch Maker can cope with multiple patches and has a notion of the "current patch" -- the one you are working on at the moment. Patches are identified by a patch reference, or patchref, which is any combination of characters that make a legal filename on your platform. Bug numbers make very good patchrefs. You can add and remove files from Patch Maker's internal list of files that comprise the current patch.

B.2.2.1. Using Patch Maker in Build mode

Here are the steps to use Patch Maker in Build mode (flip the slashes in these paths if you are on Windows):

  1. Set up Patch Maker (see the installation instructions at http://www.gerv.net/software/patch-maker/build-mode.html).

  2. Change to the chrome directory of a Mozilla nightly build.

  3. Execute pmuj to unjar your chrome.

  4. Run Mozilla (../mozilla) to see if it still works. Turn off the XUL cache in the Debug > Networking preferences and quit Mozilla.

  5. Execute pms test. Patch Maker will tell you that you are working on patch "test."

  6. Confirm this with pmw.

  7. Execute pml. Note that no files are currently in your patch.

  8. Execute pma content/navigator/navigator.xul to add navigator.xul to your patch.

  9. Execute pml again and see if it was added. Experiment with pma and pmr if you like.

  10. Execute pme. Notice that navigator.xul appears in your editor. Try pme foo to make sure you have no files that match "foo."

  11. Change navigator.xul -- e.g., search for "&mainWindow.title;" and replace that string with "MyBrowser." Save this file.

  12. Run Mozilla (../mozilla).

  13. You should have a Mozilla titled "MyBrowser."

  14. Edit the file again to make it "YourBrowser." Save the file.

  15. Press Ctrl-N in your Mozilla window. The new window should be titled "YourBrowser."

  16. Execute pmd and pmv. You should now have an editor window with a unified diff showing the changes you made.

  17. You could attach your patch to a Bugzilla bug by fishing the CVS version (test.diff) out of your Patch Maker data directory.