Mercurial > dotfiles
comparison .shell.d/50.hg_functions.sh @ 210:0590f34b92a0
shell.d: split hg and git functions out of vcs functions
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sun, 16 May 2010 20:43:00 -0500 |
parents | .shell.d/50.vcs_functions.sh@9e45ac5350fd |
children | 0c8939baa35c |
comparison
equal
deleted
inserted
replaced
209:c28a1e2c746a | 210:0590f34b92a0 |
---|---|
1 ## hg_functions | |
2 # various hg utility functions | |
3 | |
4 function mq () { | |
5 ( wcroot ; | |
6 hg -R .hg/patches $@ | |
7 ) | |
8 } | |
9 | |
10 function mq-snapshot () { | |
11 mq ci -m "Applied on $(hg log -r qparent --template '{node|short}\n')" | |
12 } | |
13 | |
14 function hgsvnmergebranch() { | |
15 local targetrev | |
16 local striprev | |
17 targetrev=$(hg id | cut -d ' ' -f 1) | |
18 hg merge $1 | |
19 hg ci -m "Merging $1" | |
20 striprev=$(hg id | cut -d ' ' -f 1) | |
21 hg co $targetrev | |
22 hg diff -r$targetrev:$striprev | hg import - -m "Merged branch $1." | |
23 hg strip $striprev | |
24 } | |
25 alias hg-svn-merge-branch=hgsvnmergebranch | |
26 | |
27 function hgsvnrebaseall() { | |
28 for b in `hg log -u 'Augie Fackler <durin42@gmail.com>' --template '{branches}\n' | sort | uniq` | |
29 do | |
30 echo "rebase $b" | |
31 hg co $b | |
32 if [[ "$?" != "0" ]] ; then | |
33 echo "abort: could not checkout $b" | |
34 return | |
35 fi | |
36 hg parent --svn > /dev/null | |
37 if [[ "$?" == "0" ]] ; then | |
38 hg rebase --svn || return | |
39 else | |
40 echo "Skip $b since it has a merge." | |
41 fi | |
42 done | |
43 } | |
44 alias hg-svn-rebase-all=hgsvnrebaseall | |
45 | |
46 function hgamend() { | |
47 hg qimport -r . && hg qref && hg qfin qtip | |
48 } | |
49 alias hg-amend=hgamend | |
50 | |
51 function hg_verify_all() { | |
52 for x in $(find . -name '.hg') ; do | |
53 y=$(dirname $x) | |
54 echo $y | |
55 hg verify -R $y | |
56 done | |
57 } | |
58 | |
59 function hgsvnmkbranch() { | |
60 local upstream | |
61 upstream=$(hg paths default | sed 's%/*$%%') | |
62 local branchname | |
63 if [ "x$1" = "x" ] ; then | |
64 echo 'Must provide new branch name.' | |
65 return 1 | |
66 fi | |
67 local d=`hg svn info | grep URL | sed 's/.*://'` | |
68 local br=`echo $d | awk '{ | |
69 if ( index($1, "trunk") ) { | |
70 print "trunk" | |
71 } else { | |
72 x = index($1, "branches") ; | |
73 if ( x != 0 ) { | |
74 sub(".*/branches/", ""); | |
75 sub("/.*", ""); | |
76 print $0 | |
77 } | |
78 } | |
79 }'` | |
80 | |
81 branchname=$br | |
82 echo svn cp $upstream/$branchname $upstream/branches/$1 | |
83 } | |
84 alias hg-svn-mkbranch=hgsvnmkbranch |