30 | | * To backport a changeset from trunk, use the [http://mercurial.selenic.com/wiki/TransplantExtension transplant] extension |
| 30 | * To backport a changeset from trunk, use the [http://mercurial.selenic.com/wiki/TransplantExtension transplant] extension. Or use this handy script which will generate the commit message for you: |
| 31 | {{{ |
| 32 | #!sh |
| 33 | #!/bin/bash |
| 34 | |
| 35 | function usage { |
| 36 | echo "Usage: hg_backport <branch> <hgrevision>"; |
| 37 | } |
| 38 | |
| 39 | if [ $# -ne 2 ] |
| 40 | then |
| 41 | usage; |
| 42 | exit 1; |
| 43 | fi |
| 44 | |
| 45 | SHORTBRANCH="$1" |
| 46 | BRANCH="releases/$SHORTBRANCH" |
| 47 | HGREV="$2" |
| 48 | |
| 49 | hg st -a -r -m | grep '' > /dev/null && { echo "Working directory not clean - exiting" > /dev/stderr; exit 1; } |
| 50 | |
| 51 | SVNREV=`hg svn info -r $HGREV | egrep '^Revision' | cut -f 2 -d ' '` |
| 52 | if [ "x$SVNREV" = "x" ] |
| 53 | then |
| 54 | echo "Can't find svn rev"; |
| 55 | exit 1; |
| 56 | fi |
| 57 | |
| 58 | echo "Backporting Subversion revision $SVNREV" |
| 59 | hg update $BRANCH || exit 1; |
| 60 | hg transplant $HGREV || exit 1; |
| 61 | # Modify the commit message |
| 62 | hg log -r -1 --template "[$SHORTBRANCH] {desc}\n\nBackport of [$SVNREV] from trunk\n" > hg-commit-message.txt || exit 1 |
| 63 | hg rollback > /dev/null || exit 1 |
| 64 | hg commit -l hg-commit-message.txt || exit 1 |
| 65 | echo "Backport committed." |
| 66 | }}} |
| 67 | The command line is like: |
| 68 | {{{ |
| 69 | #!sh |
| 70 | hg_backport 1.2.X 13643` |
| 71 | }}} |
| 72 | where 1.2.X is a directory under 'releases/' in the Subversion repo, and 13643 is a hg revision ID. The change is already committed, but not 'pushed', so you can still rollback if changes need to be made. |
| 73 | |