comparison .shell.d/50.hg_functions.sh @ 231:6da5a4729bc7

hg-rebase-all: fix bogus loop
author Augie Fackler <durin42@gmail.com>
date Sat, 09 Oct 2010 15:47:24 -0500
parents 0c8939baa35c
children 369d869082fd
comparison
equal deleted inserted replaced
230:ff600674c701 231:6da5a4729bc7
20 if [ "$1" = "tip" ] ; then 20 if [ "$1" = "tip" ] ; then
21 echo 'abort: tip is essentially never what you mean here' 21 echo 'abort: tip is essentially never what you mean here'
22 return 2 22 return 2
23 fi 23 fi
24 for b in $(hg book | sed 's/^ \*/ /' | awk '{ print $1 }') ; do 24 for b in $(hg book | sed 's/^ \*/ /' | awk '{ print $1 }') ; do
25 hg co --clean $book 25 hg co --clean $b
26 hg rebase -d "$1" 26 hg rebase -d "$1"
27 done 27 done
28 } 28 }
29 alias hg-rebase-all=hg_rebase_all 29 alias hg-rebase-all=hg_rebase_all
30 30
42 alias hg-svn-merge-branch=hgsvnmergebranch 42 alias hg-svn-merge-branch=hgsvnmergebranch
43 43
44 function hgsvnrebaseall() { 44 function hgsvnrebaseall() {
45 for b in `hg log -u 'Augie Fackler <durin42@gmail.com>' --template '{branches}\n' | sort | uniq` 45 for b in `hg log -u 'Augie Fackler <durin42@gmail.com>' --template '{branches}\n' | sort | uniq`
46 do 46 do
47 echo "rebase $b" 47 echo "rebase $b"
48 hg co $b 48 hg co $b
49 if [[ "$?" != "0" ]] ; then 49 if [[ "$?" != "0" ]] ; then
50 echo "abort: could not checkout $b" 50 echo "abort: could not checkout $b"
51 return 51 return
52 fi 52 fi
53 hg parent --svn > /dev/null 53 hg parent --svn > /dev/null
54 if [[ "$?" == "0" ]] ; then 54 if [[ "$?" == "0" ]] ; then
55 hg rebase --svn || return 55 hg rebase --svn || return
56 else 56 else
57 echo "Skip $b since it has a merge." 57 echo "Skip $b since it has a merge."
58 fi 58 fi
59 done 59 done
60 } 60 }
61 alias hg-svn-rebase-all=hgsvnrebaseall 61 alias hg-svn-rebase-all=hgsvnrebaseall
62 62
63 function hgamend() { 63 function hgamend() {
76 function hgsvnmkbranch() { 76 function hgsvnmkbranch() {
77 local upstream 77 local upstream
78 upstream=$(hg paths default | sed 's%/*$%%') 78 upstream=$(hg paths default | sed 's%/*$%%')
79 local branchname 79 local branchname
80 if [ "x$1" = "x" ] ; then 80 if [ "x$1" = "x" ] ; then
81 echo 'Must provide new branch name.' 81 echo 'Must provide new branch name.'
82 return 1 82 return 1
83 fi 83 fi
84 local d=`hg svn info | grep URL | sed 's/.*://'` 84 local d=`hg svn info | grep URL | sed 's/.*://'`
85 local br=`echo $d | awk '{ 85 local br=`echo $d | awk '{
86 if ( index($1, "trunk") ) { 86 if ( index($1, "trunk") ) {
87 print "trunk" 87 print "trunk"
88 } else { 88 } else {
89 x = index($1, "branches") ; 89 x = index($1, "branches") ;
90 if ( x != 0 ) { 90 if ( x != 0 ) {
91 sub(".*/branches/", ""); 91 sub(".*/branches/", "");
92 sub("/.*", ""); 92 sub("/.*", "");
93 print $0 93 print $0
94 } 94 }
95 } 95 }
96 }'` 96 }'`
97 97
98 branchname=$br 98 branchname=$br
99 echo svn cp $upstream/$branchname $upstream/branches/$1 99 echo svn cp $upstream/$branchname $upstream/branches/$1
100 } 100 }
101 alias hg-svn-mkbranch=hgsvnmkbranch 101 alias hg-svn-mkbranch=hgsvnmkbranch