Mercurial > dotfiles
annotate .shell.d/50.vcs_functions.sh @ 185:b5d71972aa72
apply-patchbomb: script to apply patchbomb from selected messages in Mail.app.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sat, 30 Jan 2010 12:21:00 -0600 |
parents | efa2bfc73d2d |
children | e1a49db5c6ff |
rev | line source |
---|---|
0 | 1 ## vcs_functions |
2 # This file contains a handful of functions that relate to using some version | |
3 # control tool or other. | |
4 | |
60
87b2ccf6ec44
Improved mq now works anywhere inside the parent hg repo.
Augie Fackler <durin42@gmail.com>
parents:
58
diff
changeset
|
5 function mq () { |
87b2ccf6ec44
Improved mq now works anywhere inside the parent hg repo.
Augie Fackler <durin42@gmail.com>
parents:
58
diff
changeset
|
6 ( wcroot ; |
87b2ccf6ec44
Improved mq now works anywhere inside the parent hg repo.
Augie Fackler <durin42@gmail.com>
parents:
58
diff
changeset
|
7 hg -R .hg/patches $@ |
87b2ccf6ec44
Improved mq now works anywhere inside the parent hg repo.
Augie Fackler <durin42@gmail.com>
parents:
58
diff
changeset
|
8 ) |
87b2ccf6ec44
Improved mq now works anywhere inside the parent hg repo.
Augie Fackler <durin42@gmail.com>
parents:
58
diff
changeset
|
9 } |
13
c22ca1514f3b
Add an alias to ease working with mq repos.
Augie Fackler <durin42@gmail.com>
parents:
10
diff
changeset
|
10 |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
11 function ezsvnsync() { |
169
040ac89ffe1e
ez-svn-sync: add usage help
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
12 if [ x"$1" = "x" ] ; then |
040ac89ffe1e
ez-svn-sync: add usage help
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
13 echo 'usage: ez-svn-sync repo url' |
040ac89ffe1e
ez-svn-sync: add usage help
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
14 return 0 |
040ac89ffe1e
ez-svn-sync: add usage help
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
15 fi |
63
1b4067cc97ca
Add a function to svnsync easier. Done this too many times because of hgsubversion.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
16 local repo |
1b4067cc97ca
Add a function to svnsync easier. Done this too many times because of hgsubversion.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
17 repo=$1 |
169
040ac89ffe1e
ez-svn-sync: add usage help
Augie Fackler <durin42@gmail.com>
parents:
167
diff
changeset
|
18 local url |
63
1b4067cc97ca
Add a function to svnsync easier. Done this too many times because of hgsubversion.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
19 url=$2 |
1b4067cc97ca
Add a function to svnsync easier. Done this too many times because of hgsubversion.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
20 svnadmin create $repo |
1b4067cc97ca
Add a function to svnsync easier. Done this too many times because of hgsubversion.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
21 echo '#!/bin/sh' >> $repo/hooks/pre-revprop-change |
1b4067cc97ca
Add a function to svnsync easier. Done this too many times because of hgsubversion.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
22 echo 'exit 0' >> $repo/hooks/pre-revprop-change |
1b4067cc97ca
Add a function to svnsync easier. Done this too many times because of hgsubversion.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
23 chmod +x $repo/hooks/pre-revprop-change |
1b4067cc97ca
Add a function to svnsync easier. Done this too many times because of hgsubversion.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
24 svnsync init file://`pwd`/$repo $url |
1b4067cc97ca
Add a function to svnsync easier. Done this too many times because of hgsubversion.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
25 svnsync sync file://`pwd`/$repo |
1b4067cc97ca
Add a function to svnsync easier. Done this too many times because of hgsubversion.
Augie Fackler <durin42@gmail.com>
parents:
62
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 alias ez-svn-sync=ezsvnsync |
63
1b4067cc97ca
Add a function to svnsync easier. Done this too many times because of hgsubversion.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
28 |
0 | 29 # Function to grab the url of an svn wc |
30 function svnurlof() { | |
31 local url | |
32 url=`svn info $1 2> /dev/null | grep '^URL: ' | sed 's/URL: //'` | |
33 if [ x"$url" = "x" ] ; then | |
34 url=`git svn info $1 2> /dev/null | grep '^URL: ' | sed 's/URL: //'` | |
35 fi | |
36 if [ x"$url" = "x" ] ; then | |
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
|
37 local dir |
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
|
38 dir=$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
|
39 if [ x"$dir" = "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
|
40 dir="." |
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
|
41 fi |
0 | 42 url=`hg -R $dir svn info 2> /dev/null | grep '^URL: ' | sed 's/URL: //'` |
43 fi | |
44 if [ x"$url" = "x" ] ; then | |
167
f485c32913cd
vcs functions: refer to hgsubversion by the real name
Augie Fackler <durin42@gmail.com>
parents:
156
diff
changeset
|
45 echo -n 'No repo found (tried svn, git-svn, hgsubversion)' |
0 | 46 fi |
47 echo $url | |
48 } | |
49 | |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 } |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
61 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
|
62 |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
63 function hgsvnrebaseall() { |
69
5232fa3d7ad3
Changes required by log being back to the default.
Augie Fackler <durin42@gmail.com>
parents:
67
diff
changeset
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 if [[ "$?" == "0" ]] ; then |
83
568f9f350844
hg svn rebase is now hg rebase --svn
Augie Fackler <durin42@gmail.com>
parents:
81
diff
changeset
|
74 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
|
75 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
|
76 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
|
77 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
|
78 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
|
79 } |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
80 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
|
81 |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
82 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
|
83 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
|
84 } |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
85 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
|
86 |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 } 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 } |
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
|
106 } |
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
|
107 }'` |
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
|
108 |
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
|
109 branchname=$br |
47
e80bc65439ac
Too clever for my own good in this function.
Augie Fackler <durin42@gmail.com>
parents:
46
diff
changeset
|
110 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
|
111 } |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
112 alias hg-svn-mkbranch=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
|
113 |
0 | 114 # Function to clean locks out of svn wcs |
115 function clean_svn_source_trees() { | |
116 for aa in */ ; do | |
117 pushd $aa > /dev/null | |
118 if [ -e .svn ] ; then | |
119 echo $aa 'is an svn checkout, cleaning' && svn cleanup | |
120 fi | |
121 popd > /dev/null | |
122 done | |
123 } | |
124 | |
125 # Function to update source trees of known VCS tools in the working dir. | |
126 # "known" means ones I'm forced to use on a regular basis | |
127 function update_source_trees() { | |
184
efa2bfc73d2d
update-source-trees: recurse to find all VCS working copies
Augie Fackler <durin42@gmail.com>
parents:
169
diff
changeset
|
128 if ! ls -l | egrep ^d > /dev/null ; then |
efa2bfc73d2d
update-source-trees: recurse to find all VCS working copies
Augie Fackler <durin42@gmail.com>
parents:
169
diff
changeset
|
129 ls -l | egrep ^d |
efa2bfc73d2d
update-source-trees: recurse to find all VCS working copies
Augie Fackler <durin42@gmail.com>
parents:
169
diff
changeset
|
130 return |
efa2bfc73d2d
update-source-trees: recurse to find all VCS working copies
Augie Fackler <durin42@gmail.com>
parents:
169
diff
changeset
|
131 fi |
efa2bfc73d2d
update-source-trees: recurse to find all VCS working copies
Augie Fackler <durin42@gmail.com>
parents:
169
diff
changeset
|
132 local hgpath |
0 | 133 for aa in */ ; do |
31
a5691a22c92b
Fix a bug in update_source_trees where it could eat any existing dirstack
Augie Fackler <durin42@gmail.com>
parents:
16
diff
changeset
|
134 pushd $aa > /dev/null || continue |
0 | 135 if [ -e .svn ] ; then |
136 echo $aa 'is an svn checkout, updating' | |
137 svn up | |
115
5f00625aa1ed
Add support for svnsync to update_source_trees, alias update_source_trees to update-source-trees
Augie Fackler <durin42@gmail.com>
parents:
83
diff
changeset
|
138 elif [ -e README.txt ] \ |
5f00625aa1ed
Add support for svnsync to update_source_trees, alias update_source_trees to update-source-trees
Augie Fackler <durin42@gmail.com>
parents:
83
diff
changeset
|
139 && [ -e format ] \ |
5f00625aa1ed
Add support for svnsync to update_source_trees, alias update_source_trees to update-source-trees
Augie Fackler <durin42@gmail.com>
parents:
83
diff
changeset
|
140 && grep "This is a Subversion repository; use the 'svnadmin' tool to examine" README.txt > /dev/null \ |
5f00625aa1ed
Add support for svnsync to update_source_trees, alias update_source_trees to update-source-trees
Augie Fackler <durin42@gmail.com>
parents:
83
diff
changeset
|
141 && svn pl --revprop -r 0 file://$(pwd) | fgrep svn:sync-from-url > /dev/null\ |
5f00625aa1ed
Add support for svnsync to update_source_trees, alias update_source_trees to update-source-trees
Augie Fackler <durin42@gmail.com>
parents:
83
diff
changeset
|
142 ; then |
5f00625aa1ed
Add support for svnsync to update_source_trees, alias update_source_trees to update-source-trees
Augie Fackler <durin42@gmail.com>
parents:
83
diff
changeset
|
143 echo "$aa looks like an svnsync clone, syncing" |
5f00625aa1ed
Add support for svnsync to update_source_trees, alias update_source_trees to update-source-trees
Augie Fackler <durin42@gmail.com>
parents:
83
diff
changeset
|
144 svnsync sync file://$(pwd) |
0 | 145 elif [ -e .git/svn ] ; then |
146 echo $aa 'is a git-svn checkout, updating' | |
147 git svn fetch | |
148 elif [ -e .git ] ; then | |
149 echo $aa 'is a git checkout, updating' | |
150 git pull origin master | |
151 elif [ -e .hg ] ; then | |
184
efa2bfc73d2d
update-source-trees: recurse to find all VCS working copies
Augie Fackler <durin42@gmail.com>
parents:
169
diff
changeset
|
152 echo $aa 'is an hg checkout, updating' |
efa2bfc73d2d
update-source-trees: recurse to find all VCS working copies
Augie Fackler <durin42@gmail.com>
parents:
169
diff
changeset
|
153 for hgpath in $(HGRCPATH=/dev/null hg paths | sed 's/.* = //g' | sort | uniq ) ; do |
efa2bfc73d2d
update-source-trees: recurse to find all VCS working copies
Augie Fackler <durin42@gmail.com>
parents:
169
diff
changeset
|
154 hg pull --update $hgpath |
efa2bfc73d2d
update-source-trees: recurse to find all VCS working copies
Augie Fackler <durin42@gmail.com>
parents:
169
diff
changeset
|
155 done |
35
7e9269048856
Fix update_source_trees to also pull versioned mq if it exists.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
156 if [ -e .hg/patches/.hg ] ; then |
7e9269048856
Fix update_source_trees to also pull versioned mq if it exists.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
157 echo $aa 'has an mq, updating that too...' |
7e9269048856
Fix update_source_trees to also pull versioned mq if it exists.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
158 hg -R .hg/patches pull -u |
7e9269048856
Fix update_source_trees to also pull versioned mq if it exists.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
159 fi |
0 | 160 elif [ -e _MTN ] ; then |
161 echo $aa "is an mtn co, updating" && mtn pull && mtn up | |
184
efa2bfc73d2d
update-source-trees: recurse to find all VCS working copies
Augie Fackler <durin42@gmail.com>
parents:
169
diff
changeset
|
162 else |
efa2bfc73d2d
update-source-trees: recurse to find all VCS working copies
Augie Fackler <durin42@gmail.com>
parents:
169
diff
changeset
|
163 update_source_trees |
0 | 164 fi |
165 popd > /dev/null | |
166 done | |
167 } | |
115
5f00625aa1ed
Add support for svnsync to update_source_trees, alias update_source_trees to update-source-trees
Augie Fackler <durin42@gmail.com>
parents:
83
diff
changeset
|
168 alias update-source-trees=update_source_trees |
0 | 169 |
170 function vcs_current_branch() { | |
10
b4bfce76123f
Reorder these checks. With my home being in hg, it was winning over any other
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
171 git branch 2> /dev/null > /dev/null |
0 | 172 if [ $? = 0 ] ; then |
173 git branch --verbose | grep '^*' | sed 's/* //;s/ /:/;s/ .*//;s/:/ /' | |
174 return 0 | |
175 fi | |
176 # when wc-ng comes out, we'll probably do the following | |
177 # svn info 2> /dev/null > /dev/null | |
178 if [ -e .svn ] ; then | |
179 local d=`svn info | grep URL | sed 's/.*://'` | |
180 local br=`echo $d | awk '{ | |
181 if ( index($1, "trunk") ) { | |
182 print "trunk" | |
183 } else { | |
184 x = index($1, "branches") ; | |
185 if ( x != 0 ) { | |
186 sub(".*/branches/", ""); | |
187 sub("/.*", ""); | |
188 print $0 | |
189 } | |
190 } | |
191 }'` | |
192 local rev=`svn info | grep Revision | sed 's/.*: /r/'` | |
193 echo $br $rev | |
194 return 0 | |
195 fi | |
10
b4bfce76123f
Reorder these checks. With my home being in hg, it was winning over any other
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
196 hg branch 2> /dev/null > /dev/null |
b4bfce76123f
Reorder these checks. With my home being in hg, it was winning over any other
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
197 if [ $? = 0 ] ; then |
b4bfce76123f
Reorder these checks. With my home being in hg, it was winning over any other
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
198 local br=`hg branch | head -c 10` |
b4bfce76123f
Reorder these checks. With my home being in hg, it was winning over any other
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
199 local rid=`hg parents | head -n 1 | awk '{print $2}' | head -c 7` |
b4bfce76123f
Reorder these checks. With my home being in hg, it was winning over any other
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
200 echo "$br $rid" |
b4bfce76123f
Reorder these checks. With my home being in hg, it was winning over any other
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
201 return 0 |
b4bfce76123f
Reorder these checks. With my home being in hg, it was winning over any other
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
202 fi |
0 | 203 return 1 |
204 } | |
205 | |
156
59ea03d7029a
vcs_functions: add a function to grab the path of the next unmerged file from git
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
206 function git_next_unmerged_file() { |
59ea03d7029a
vcs_functions: add a function to grab the path of the next unmerged file from git
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
207 git status | grep unmerged | head -n 1 | sed 's/.*: //' |
59ea03d7029a
vcs_functions: add a function to grab the path of the next unmerged file from git
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
208 } |
59ea03d7029a
vcs_functions: add a function to grab the path of the next unmerged file from git
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
209 alias git-next-unmerged-file=git_next_unmerged_file |
59ea03d7029a
vcs_functions: add a function to grab the path of the next unmerged file from git
Augie Fackler <durin42@gmail.com>
parents:
133
diff
changeset
|
210 |
0 | 211 # change to the root dir of the current wc |
212 function wcroot() { | |
213 local root=`hg root 2> /dev/null` | |
214 if [ x$root != 'x' ] ; then | |
215 cd $root | |
216 return 0 | |
217 fi | |
218 git branch 2> /dev/null > /dev/null | |
219 if [ $? = 0 ] ; then | |
220 while [ ! -e .git ] ; do | |
221 cd .. | |
222 done | |
223 return 0 | |
224 fi | |
225 if [ -e .svn ] ; then | |
226 while [ -e ../.svn ] ; do | |
227 cd .. | |
228 done | |
229 return 0 | |
230 fi | |
231 echo No working copy found'!' | |
232 } |