Mercurial > dotfiles
annotate .shell.d/50.vcs_functions.sh @ 171:2f865a7f84e6
textmate: do not trust cached project root of $HOME
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Wed, 16 Dec 2009 22:18:43 -0600 |
parents | 59ea03d7029a |
children | f485c32913cd |
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() { |
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
|
12 local 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
|
13 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
|
14 repo=$1 |
1b4067cc97ca
Add a function to svnsync easier. Done this too many times because of hgsubversion.
Augie Fackler <durin42@gmail.com>
parents:
62
diff
changeset
|
15 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
|
16 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
|
17 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
|
18 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
|
19 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
|
20 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
|
21 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
|
22 } |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
23 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
|
24 |
0 | 25 # Function to grab the url of an svn wc |
26 function svnurlof() { | |
27 local url | |
28 url=`svn info $1 2> /dev/null | grep '^URL: ' | sed 's/URL: //'` | |
29 if [ x"$url" = "x" ] ; then | |
30 url=`git svn info $1 2> /dev/null | grep '^URL: ' | sed 's/URL: //'` | |
31 fi | |
32 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
|
33 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
|
34 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
|
35 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
|
36 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
|
37 fi |
0 | 38 url=`hg -R $dir svn info 2> /dev/null | grep '^URL: ' | sed 's/URL: //'` |
39 fi | |
40 if [ x"$url" = "x" ] ; then | |
41 echo -n 'No repo found (tried svn, git-svn, hgsvnclient)' | |
42 fi | |
43 echo $url | |
44 } | |
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 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
|
47 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
|
48 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 } |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
57 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
|
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 hgsvnrebaseall() { |
69
5232fa3d7ad3
Changes required by log being back to the default.
Augie Fackler <durin42@gmail.com>
parents:
67
diff
changeset
|
60 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 if [[ "$?" == "0" ]] ; then |
83
568f9f350844
hg svn rebase is now hg rebase --svn
Augie Fackler <durin42@gmail.com>
parents:
81
diff
changeset
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 } |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
76 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
|
77 |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
78 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
|
79 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
|
80 } |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
81 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
|
82 |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
83 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
|
84 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 } 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 } |
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 } |
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 }'` |
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 |
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 branchname=$br |
47
e80bc65439ac
Too clever for my own good in this function.
Augie Fackler <durin42@gmail.com>
parents:
46
diff
changeset
|
106 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
|
107 } |
133
5b0b8ad2cb2c
vcs_functions: some versions of the shell don't like - in function names.
Augie Fackler <durin42@gmail.com>
parents:
129
diff
changeset
|
108 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
|
109 |
0 | 110 # Function to clean locks out of svn wcs |
111 function clean_svn_source_trees() { | |
112 for aa in */ ; do | |
113 pushd $aa > /dev/null | |
114 if [ -e .svn ] ; then | |
115 echo $aa 'is an svn checkout, cleaning' && svn cleanup | |
116 fi | |
117 popd > /dev/null | |
118 done | |
119 } | |
120 | |
121 # Function to update source trees of known VCS tools in the working dir. | |
122 # "known" means ones I'm forced to use on a regular basis | |
123 function update_source_trees() { | |
124 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
|
125 pushd $aa > /dev/null || continue |
0 | 126 if [ -e .svn ] ; then |
127 echo $aa 'is an svn checkout, updating' | |
128 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
|
129 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
|
130 && [ -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
|
131 && 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
|
132 && 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
|
133 ; 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
|
134 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
|
135 svnsync sync file://$(pwd) |
0 | 136 elif [ -e .git/svn ] ; then |
137 echo $aa 'is a git-svn checkout, updating' | |
138 git svn fetch | |
139 git repack | |
140 git gc | |
141 elif [ -e .git ] ; then | |
142 echo $aa 'is a git checkout, updating' | |
143 git pull origin master | |
144 git repack | |
145 git gc | |
146 elif [ -e .hg ] ; then | |
147 echo $aa 'is an hg checkout, updating' && hg pull && hg up | |
35
7e9269048856
Fix update_source_trees to also pull versioned mq if it exists.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
148 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
|
149 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
|
150 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
|
151 fi |
0 | 152 elif [ -e _MTN ] ; then |
153 echo $aa "is an mtn co, updating" && mtn pull && mtn up | |
154 fi | |
155 popd > /dev/null | |
156 done | |
157 } | |
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
|
158 alias update-source-trees=update_source_trees |
0 | 159 |
160 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
|
161 git branch 2> /dev/null > /dev/null |
0 | 162 if [ $? = 0 ] ; then |
163 git branch --verbose | grep '^*' | sed 's/* //;s/ /:/;s/ .*//;s/:/ /' | |
164 return 0 | |
165 fi | |
166 # when wc-ng comes out, we'll probably do the following | |
167 # svn info 2> /dev/null > /dev/null | |
168 if [ -e .svn ] ; then | |
169 local d=`svn info | grep URL | sed 's/.*://'` | |
170 local br=`echo $d | awk '{ | |
171 if ( index($1, "trunk") ) { | |
172 print "trunk" | |
173 } else { | |
174 x = index($1, "branches") ; | |
175 if ( x != 0 ) { | |
176 sub(".*/branches/", ""); | |
177 sub("/.*", ""); | |
178 print $0 | |
179 } | |
180 } | |
181 }'` | |
182 local rev=`svn info | grep Revision | sed 's/.*: /r/'` | |
183 echo $br $rev | |
184 return 0 | |
185 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
|
186 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
|
187 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
|
188 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
|
189 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
|
190 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
|
191 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
|
192 fi |
0 | 193 return 1 |
194 } | |
195 | |
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
|
196 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
|
197 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
|
198 } |
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
|
199 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
|
200 |
0 | 201 # change to the root dir of the current wc |
202 function wcroot() { | |
203 local root=`hg root 2> /dev/null` | |
204 if [ x$root != 'x' ] ; then | |
205 cd $root | |
206 return 0 | |
207 fi | |
208 git branch 2> /dev/null > /dev/null | |
209 if [ $? = 0 ] ; then | |
210 while [ ! -e .git ] ; do | |
211 cd .. | |
212 done | |
213 return 0 | |
214 fi | |
215 if [ -e .svn ] ; then | |
216 while [ -e ../.svn ] ; do | |
217 cd .. | |
218 done | |
219 return 0 | |
220 fi | |
221 echo No working copy found'!' | |
222 } |