Mercurial > dotfiles
annotate .shell.d/50.hg_functions.sh @ 224:7ca719e40c58
modes: enable Go mode if it can be found
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 20 Sep 2010 07:35:29 -0500 |
parents | 0590f34b92a0 |
children | 0c8939baa35c |
rev | line source |
---|---|
210
0590f34b92a0
shell.d: split hg and git functions out of vcs functions
Augie Fackler <durin42@gmail.com>
parents:
204
diff
changeset
|
1 ## hg_functions |
0590f34b92a0
shell.d: split hg and git functions out of vcs functions
Augie Fackler <durin42@gmail.com>
parents:
204
diff
changeset
|
2 # various hg utility functions |
0 | 3 |
60
87b2ccf6ec44
Improved mq now works anywhere inside the parent hg repo.
Augie Fackler <durin42@gmail.com>
parents:
58
diff
changeset
|
4 function mq () { |
87b2ccf6ec44
Improved mq now works anywhere inside the parent hg repo.
Augie Fackler <durin42@gmail.com>
parents:
58
diff
changeset
|
5 ( wcroot ; |
87b2ccf6ec44
Improved mq now works anywhere inside the parent hg repo.
Augie Fackler <durin42@gmail.com>
parents:
58
diff
changeset
|
6 hg -R .hg/patches $@ |
87b2ccf6ec44
Improved mq now works anywhere inside the parent hg repo.
Augie Fackler <durin42@gmail.com>
parents:
58
diff
changeset
|
7 ) |
87b2ccf6ec44
Improved mq now works anywhere inside the parent hg repo.
Augie Fackler <durin42@gmail.com>
parents:
58
diff
changeset
|
8 } |
13
c22ca1514f3b
Add an alias to ease working with mq repos.
Augie Fackler <durin42@gmail.com>
parents:
10
diff
changeset
|
9 |
200
a563c21235ad
vcs-functions: add mq-snapshot
Augie Fackler <durin42@gmail.com>
parents:
195
diff
changeset
|
10 function mq-snapshot () { |
a563c21235ad
vcs-functions: add mq-snapshot
Augie Fackler <durin42@gmail.com>
parents:
195
diff
changeset
|
11 mq ci -m "Applied on $(hg log -r qparent --template '{node|short}\n')" |
a563c21235ad
vcs-functions: add mq-snapshot
Augie Fackler <durin42@gmail.com>
parents:
195
diff
changeset
|
12 } |
a563c21235ad
vcs-functions: add mq-snapshot
Augie Fackler <durin42@gmail.com>
parents:
195
diff
changeset
|
13 |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
14 function hgsvnmergebranch() { |
61
79c2c3932362
Add hg-svn-merge-branch which does all the steps of merging an hg branch for me.
Augie Fackler <durin42@gmail.com>
parents:
60
diff
changeset
|
15 local targetrev |
79c2c3932362
Add hg-svn-merge-branch which does all the steps of merging an hg branch for me.
Augie Fackler <durin42@gmail.com>
parents:
60
diff
changeset
|
16 local striprev |
79c2c3932362
Add hg-svn-merge-branch which does all the steps of merging an hg branch for me.
Augie Fackler <durin42@gmail.com>
parents:
60
diff
changeset
|
17 targetrev=$(hg id | cut -d ' ' -f 1) |
79c2c3932362
Add hg-svn-merge-branch which does all the steps of merging an hg branch for me.
Augie Fackler <durin42@gmail.com>
parents:
60
diff
changeset
|
18 hg merge $1 |
79c2c3932362
Add hg-svn-merge-branch which does all the steps of merging an hg branch for me.
Augie Fackler <durin42@gmail.com>
parents:
60
diff
changeset
|
19 hg ci -m "Merging $1" |
79c2c3932362
Add hg-svn-merge-branch which does all the steps of merging an hg branch for me.
Augie Fackler <durin42@gmail.com>
parents:
60
diff
changeset
|
20 striprev=$(hg id | cut -d ' ' -f 1) |
79c2c3932362
Add hg-svn-merge-branch which does all the steps of merging an hg branch for me.
Augie Fackler <durin42@gmail.com>
parents:
60
diff
changeset
|
21 hg co $targetrev |
79c2c3932362
Add hg-svn-merge-branch which does all the steps of merging an hg branch for me.
Augie Fackler <durin42@gmail.com>
parents:
60
diff
changeset
|
22 hg diff -r$targetrev:$striprev | hg import - -m "Merged branch $1." |
79c2c3932362
Add hg-svn-merge-branch which does all the steps of merging an hg branch for me.
Augie Fackler <durin42@gmail.com>
parents:
60
diff
changeset
|
23 hg strip $striprev |
79c2c3932362
Add hg-svn-merge-branch which does all the steps of merging an hg branch for me.
Augie Fackler <durin42@gmail.com>
parents:
60
diff
changeset
|
24 } |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
25 alias hg-svn-merge-branch=hgsvnmergebranch |
61
79c2c3932362
Add hg-svn-merge-branch which does all the steps of merging an hg branch for me.
Augie Fackler <durin42@gmail.com>
parents:
60
diff
changeset
|
26 |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
27 function hgsvnrebaseall() { |
69
5232fa3d7ad3
Changes required by log being back to the default.
Augie Fackler <durin42@gmail.com>
parents:
67
diff
changeset
|
28 for b in `hg log -u 'Augie Fackler <durin42@gmail.com>' --template '{branches}\n' | sort | uniq` |
58
20834b97b814
Add function to rebase all local named branches to HEAD of their parent svn branch.
Augie Fackler <durin42@gmail.com>
parents:
47
diff
changeset
|
29 do |
67
9f8bd97da0d4
hg-svn-rebase-all: improved rebasing so that merges no longer abort rebasing other branches.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
30 echo "rebase $b" |
9f8bd97da0d4
hg-svn-rebase-all: improved rebasing so that merges no longer abort rebasing other branches.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
31 hg co $b |
9f8bd97da0d4
hg-svn-rebase-all: improved rebasing so that merges no longer abort rebasing other branches.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
32 if [[ "$?" != "0" ]] ; then |
9f8bd97da0d4
hg-svn-rebase-all: improved rebasing so that merges no longer abort rebasing other branches.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
33 echo "abort: could not checkout $b" |
9f8bd97da0d4
hg-svn-rebase-all: improved rebasing so that merges no longer abort rebasing other branches.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
34 return |
9f8bd97da0d4
hg-svn-rebase-all: improved rebasing so that merges no longer abort rebasing other branches.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
35 fi |
9f8bd97da0d4
hg-svn-rebase-all: improved rebasing so that merges no longer abort rebasing other branches.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
36 hg parent --svn > /dev/null |
9f8bd97da0d4
hg-svn-rebase-all: improved rebasing so that merges no longer abort rebasing other branches.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
37 if [[ "$?" == "0" ]] ; then |
83
568f9f350844
hg svn rebase is now hg rebase --svn
Augie Fackler <durin42@gmail.com>
parents:
81
diff
changeset
|
38 hg rebase --svn || return |
67
9f8bd97da0d4
hg-svn-rebase-all: improved rebasing so that merges no longer abort rebasing other branches.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
39 else |
9f8bd97da0d4
hg-svn-rebase-all: improved rebasing so that merges no longer abort rebasing other branches.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
40 echo "Skip $b since it has a merge." |
9f8bd97da0d4
hg-svn-rebase-all: improved rebasing so that merges no longer abort rebasing other branches.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
41 fi |
58
20834b97b814
Add function to rebase all local named branches to HEAD of their parent svn branch.
Augie Fackler <durin42@gmail.com>
parents:
47
diff
changeset
|
42 done |
20834b97b814
Add function to rebase all local named branches to HEAD of their parent svn branch.
Augie Fackler <durin42@gmail.com>
parents:
47
diff
changeset
|
43 } |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
44 alias hg-svn-rebase-all=hgsvnrebaseall |
58
20834b97b814
Add function to rebase all local named branches to HEAD of their parent svn branch.
Augie Fackler <durin42@gmail.com>
parents:
47
diff
changeset
|
45 |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
46 function hgamend() { |
62
f9e826bd1f1b
Add a function to ammend the latest revision in hg. I don't do this often, but when I need it it is handy.
Augie Fackler <durin42@gmail.com>
parents:
61
diff
changeset
|
47 hg qimport -r . && hg qref && hg qfin qtip |
f9e826bd1f1b
Add a function to ammend the latest revision in hg. I don't do this often, but when I need it it is handy.
Augie Fackler <durin42@gmail.com>
parents:
61
diff
changeset
|
48 } |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
49 alias hg-amend=hgamend |
62
f9e826bd1f1b
Add a function to ammend the latest revision in hg. I don't do this often, but when I need it it is handy.
Augie Fackler <durin42@gmail.com>
parents:
61
diff
changeset
|
50 |
204
9e45ac5350fd
vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
51 function hg_verify_all() { |
9e45ac5350fd
vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
52 for x in $(find . -name '.hg') ; do |
9e45ac5350fd
vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
53 y=$(dirname $x) |
9e45ac5350fd
vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
54 echo $y |
9e45ac5350fd
vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
55 hg verify -R $y |
9e45ac5350fd
vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
56 done |
9e45ac5350fd
vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
57 } |
9e45ac5350fd
vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents:
200
diff
changeset
|
58 |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
59 function hgsvnmkbranch() { |
46
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
60 local upstream |
129
1286c27cf0c0
Need to use paths default instead of the outdated svn url now.
Augie Fackler <durin42@gmail.com>
parents:
115
diff
changeset
|
61 upstream=$(hg paths default | sed 's%/*$%%') |
46
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
62 local branchname |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
63 if [ "x$1" = "x" ] ; then |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
64 echo 'Must provide new branch name.' |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
65 return 1 |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
66 fi |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
67 local d=`hg svn info | grep URL | sed 's/.*://'` |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
68 local br=`echo $d | awk '{ |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
69 if ( index($1, "trunk") ) { |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
70 print "trunk" |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
71 } else { |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
72 x = index($1, "branches") ; |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
73 if ( x != 0 ) { |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
74 sub(".*/branches/", ""); |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
75 sub("/.*", ""); |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
76 print $0 |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
77 } |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
78 } |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
79 }'` |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
80 |
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
81 branchname=$br |
47
e80bc65439ac
Too clever for my own good in this function.
Augie Fackler <durin42@gmail.com>
parents:
46
diff
changeset
|
82 echo svn cp $upstream/$branchname $upstream/branches/$1 |
46
8946e6ae2747
Stopgap hg-svn-mkbranch command to save me typing until the feature goes into hgsubversion itself.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
83 } |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
84 alias hg-svn-mkbranch=hgsvnmkbranch |