Changes between Version 16 and Version 17 of MercurialBranches
- Timestamp:
- Feb 17, 2011, 6:27:12 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
MercurialBranches
v16 v17 35 35 function usage { 36 36 echo "Usage: hg_backport <branch> <hgrevision>"; 37 echo " or: hg_backport <branch> --svnrev <svnrevision>"; 37 38 } 38 39 39 if [ $# - ne2 ]40 if [ $# -lt 2 ] 40 41 then 41 42 usage; … … 43 44 fi 44 45 45 SHORTBRANCH="$1"46 BRANCH="releases/$SHORTBRANCH" # we only backport to release branches.47 HGREV="$2"48 49 46 hg st -a -r -m | grep '' > /dev/null && { echo "Working directory not clean - exiting" > /dev/stderr; exit 1; } 50 47 51 SVNREV=`hg svn info -r $HGREV | egrep '^Revision' | cut -f 2 -d ' '` 52 if [ "x$SVNREV" = "x" ] 48 SHORTBRANCH="$1" 49 BRANCH="releases/$SHORTBRANCH" 50 if [ "$2" = "--svnrev" ] 53 51 then 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 59 else 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"; 55 65 exit 1; 66 fi 56 67 fi 57 68 58 69 echo "Backporting Subversion revision $SVNREV" 59 70 hg 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 171 # Make a commit message first in case the transplant fails 72 hg log -r $HGREV --template "[$SHORTBRANCH] {desc}\n\nBackport of [$SVNREV] from trunk.\n" > hg-commit-message.txt || exit 1 62 73 hg transplant $HGREV || exit 1; 63 74 # Modify the commit message … … 66 77 echo "Backport committed." 67 78 }}} 68 The command line is like :79 The command line is like one of the following: 69 80 {{{ 70 81 #!sh 71 82 hg_backport 1.2.X 13643 83 hg_backport 1.2.X --svnrev 13237 72 84 }}} 73 where 1.2.X is a directory under 'releases/' in the Subversion repo, and 13643 is a hgrevision 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. 74 86 75 87 === An alternate approach === … … 152 164 153 165 If 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