Using cross commit

cross-commit is a script that allows a single patch to be easily checked in on multiple branches.

Getting the script

"make -f client.mk pull_all" from a working copy of the trunk now pulls cross-commit, and that'll work on the 1.8 branch soon, too, so you might already have the script. If you don't, however, then from the parent directory of your source dir, do:

 cvs co mozilla/tools/cross-commit

Note that you will need to have $CVSROOT and such set up correctly for this to work.

Using the script

Quick overview

There are a couple of common ways to use cross-commit:

Land something simultaneously on the trunk and MOZILLA_1_8_BRANCH
 # Modify the files (probably by applying the patch)
 patch -p0 < ~/caret.patch

 # Commit on trunk and branch at once
 # Make sure to use -m "Commit message" when doing so
 tools/cross-commit -m "Fix some sort of security bug" layout/base/nsCaret.h
Land something on two other branches that has already landed on the trunk
 # update to the first branch you want to land on
 cvs update -rMOZILLA_1_8_BRANCH layout/base/nsCaret.h

 # Modify the files (probably by applying the patch)
 patch -p0 < ~/caret.patch

 # Commit on all the branches at once
 # Make sure to use -m "Commit message" when doing so
 tools/cross-commit --moz18 --branch MOZILLA_1_8_0_BRANCH -m "Fix some sort of security bug" layout/base/nsCaret.h

Notes

Note that you MUST use a -m option with a CVS checkin message. Otherwise cross-commit will end up waiting forever for you to type a CVS checkin message in an editor that it never shows you! (Although it works without specifying -m on the command line if you are using X-enabled emacs on Linux.)

Also note that if you don't specify any branches to commit on, cross-commit will commit to the trunk and the MOZILLA_1_8_BRANCH by default.

Details

cross-commit accepts the following options:

  • all CVS options (those to the left of the specific CVS command) and CVS commit options (those to the right of a commit command), although the -r and -f CVS options need to be specified as --cvs-r and --cvs-f to avoid conflict with the similarly named (but different in meaning) CVS commit options. You can list the files/directories you want it to commit on the command line or leave them out and let it recursively troll the current directory.
  • --verbose=[0|1] makes the script output more text as it runs. This defaults to 1.
  • --trunk makes cross-commit land the patch on HEAD in addition to any other branches specified. This is equivalent to --branch HEAD.
  • --moz18 makes cross-commit land the patch on MOZILLA_1_8_BRANCH in addition to any other branches specified. This is equivalent to --branch MOZILLA_1_8_BRANCH.
  • --branch=branch-tag adds a branch to the list of branches to land the patch on. This may be specified multiple times, each time with a different branch name. This may also be used in combination with --trunk and --moz18.

If no branches are specified, cross-commit will default to landing on HEAD and MOZILLA_1_8_BRANCH.