Changes between Version 16 and Version 17 of MercurialBranches


Ignore:
Timestamp:
Feb 17, 2011, 6:27:12 AM (14 years ago)
Author:
Luke Plant
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MercurialBranches

    v16 v17  
    3535function usage {
    3636    echo "Usage: hg_backport <branch> <hgrevision>";
     37    echo "   or: hg_backport <branch> --svnrev <svnrevision>";
    3738}
    3839
    39 if [ $# -ne 2 ]
     40if [ $# -lt 2 ]
    4041then
    4142        usage;
     
    4344fi
    4445
    45 SHORTBRANCH="$1"
    46 BRANCH="releases/$SHORTBRANCH" # we only backport to release branches.
    47 HGREV="$2"
    48 
    4946hg st -a -r -m | grep '' > /dev/null && { echo "Working directory not clean - exiting" > /dev/stderr; exit 1; }
    5047
    51 SVNREV=`hg svn info -r $HGREV | egrep '^Revision' | cut -f 2 -d ' '`
    52 if [ "x$SVNREV" = "x" ]
     48SHORTBRANCH="$1"
     49BRANCH="releases/$SHORTBRANCH"
     50if [ "$2" = "--svnrev" ]
    5351then
    54         echo "Can't find svn rev";
     52    SVNREV="$3"
     53    HGREV=`hg log -r "svnrev($SVNREV)" --template '{rev}'`
     54    if [ "x$HGREV" = "x" ]
     55    then
     56        echo "Can't find hg rev"
     57        exit 1;
     58    fi
     59else
     60    HGREV="$2"
     61    SVNREV=`hg svn info -r $HGREV | egrep '^Revision' | cut -f 2 -d ' '`
     62    if [ "x$SVNREV" = "x" ]
     63    then
     64        echo "Can't find svn rev";
    5565        exit 1;
     66    fi
    5667fi
    5768
    5869echo "Backporting Subversion revision $SVNREV"
    5970hg update $BRANCH || exit 1;
    60 # Make a commit message first in case the transplant fails.
    61 hg log -r $HGREV --template "[$SHORTBRANCH] {desc}\n\nBackport of [$SVNREV] from trunk\n" > hg-commit-message.txt || exit 1
     71# Make a commit message first in case the transplant fails
     72hg log -r $HGREV --template "[$SHORTBRANCH] {desc}\n\nBackport of [$SVNREV] from trunk.\n" > hg-commit-message.txt || exit 1
    6273hg transplant $HGREV || exit 1;
    6374# Modify the commit message
     
    6677echo "Backport committed."
    6778   }}}
    68    The command line is like:
     79   The command line is like one of the following:
    6980   {{{
    7081#!sh
    7182hg_backport 1.2.X 13643
     83hg_backport 1.2.X --svnrev 13237
    7284}}}
    73    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 to the local repo, but not 'pushed', so you can still rollback if changes need to be made.
     85   where 1.2.X is a directory under 'releases/' in the Subversion repo, 13643 is a hg revision ID, and 13237 is a Subversion revision ID.  The change is already committed to the local repo, but not 'pushed', so you can still rollback if changes need to be made.
    7486
    7587=== An alternate approach ===
     
    152164
    153165If you make two commits, and only want to push the first, you will have some trouble, since the !HgSubversion extensions doesn't support specifying revisions with the `hg push` command when pushing to a Subversion repository. Nice solutions to this welcome!
    154 
Back to Top