annotate .shell.d/50.vcs_functions.sh @ 60:87b2ccf6ec44

Improved mq now works anywhere inside the parent hg repo.
author Augie Fackler <durin42@gmail.com>
date Tue, 03 Mar 2009 09:42:36 -0600
parents 20834b97b814
children 79c2c3932362
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 ## vcs_functions
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2 # This file contains a handful of functions that relate to using some version
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 # control tool or other.
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
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
0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11 # Function to grab the url of an svn wc
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12 function svnurlof() {
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13 local url
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14 url=`svn info $1 2> /dev/null | grep '^URL: ' | sed 's/URL: //'`
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 if [ x"$url" = "x" ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 url=`git svn info $1 2> /dev/null | grep '^URL: ' | sed 's/URL: //'`
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 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
19 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
20 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
21 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
22 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
23 fi
0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 url=`hg -R $dir svn info 2> /dev/null | grep '^URL: ' | sed 's/URL: //'`
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26 if [ x"$url" = "x" ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 echo -n 'No repo found (tried svn, git-svn, hgsvnclient)'
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29 echo $url
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30 }
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31
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
32 function hg-svn-rebase-all() {
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
33 for b in `hg llog -u 'Augie Fackler <durin42@gmail.com>' --template '{branches}\n' | sort | uniq`
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
34 do
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
35 hg co $b && hg svn rebase || return
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
36 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
37 }
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
38
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
39 function hg-svn-mkbranch() {
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 local upstream
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 upstream=$(hg svn url)
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
42 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
43 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
44 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
45 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
46 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
47 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
48 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
49 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
50 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
51 } 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
52 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
53 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
54 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
55 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
56 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
57 }
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
58 }
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
59 }'`
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
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
61 branchname=$br
47
e80bc65439ac Too clever for my own good in this function.
Augie Fackler <durin42@gmail.com>
parents: 46
diff changeset
62 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
63 }
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
0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
65 # Function to clean locks out of svn wcs
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
66 function clean_svn_source_trees() {
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
67 for aa in */ ; do
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
68 pushd $aa > /dev/null
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
69 if [ -e .svn ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
70 echo $aa 'is an svn checkout, cleaning' && svn cleanup
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
71 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
72 popd > /dev/null
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
73 done
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
74 }
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
75
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
76 # Function to update source trees of known VCS tools in the working dir.
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
77 # "known" means ones I'm forced to use on a regular basis
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
78 function update_source_trees() {
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
79 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
80 pushd $aa > /dev/null || continue
0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
81 if [ -e .svn ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
82 echo $aa 'is an svn checkout, updating'
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
83 svn up
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
84 elif [ -e .hg/svn ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
85 echo $aa 'is an hg-svn checkout, updating'
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
86 hg svn pull
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
87 hg up
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
88 elif [ -e .git/svn ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
89 echo $aa 'is a git-svn checkout, updating'
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
90 git svn fetch
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
91 git repack
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
92 git gc
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
93 elif [ -e .git ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
94 echo $aa 'is a git checkout, updating'
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
95 git pull origin master
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
96 git repack
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
97 git gc
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
98 elif [ -e .hg ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
99 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
100 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
101 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
102 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
103 fi
0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
104 elif [ -e _MTN ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
105 echo $aa "is an mtn co, updating" && mtn pull && mtn up
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
106 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
107 popd > /dev/null
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
108 done
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
109 }
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
110
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
111 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
112 git branch 2> /dev/null > /dev/null
0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
113 if [ $? = 0 ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
114 git branch --verbose | grep '^*' | sed 's/* //;s/ /:/;s/ .*//;s/:/ /'
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
115 return 0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
116 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
117 # when wc-ng comes out, we'll probably do the following
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
118 # svn info 2> /dev/null > /dev/null
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
119 if [ -e .svn ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
120 local d=`svn info | grep URL | sed 's/.*://'`
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
121 local br=`echo $d | awk '{
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
122 if ( index($1, "trunk") ) {
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
123 print "trunk"
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
124 } else {
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
125 x = index($1, "branches") ;
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
126 if ( x != 0 ) {
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
127 sub(".*/branches/", "");
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
128 sub("/.*", "");
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
129 print $0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
130 }
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
131 }
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
132 }'`
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
133 local rev=`svn info | grep Revision | sed 's/.*: /r/'`
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
134 echo $br $rev
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
135 return 0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
136 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
137 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
138 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
139 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
140 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
141 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
142 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
143 fi
0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
144 return 1
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
145 }
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
146
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
147 # change to the root dir of the current wc
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
148 function wcroot() {
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
149 local root=`hg root 2> /dev/null`
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
150 if [ x$root != 'x' ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
151 cd $root
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
152 return 0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
153 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
154 git branch 2> /dev/null > /dev/null
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
155 if [ $? = 0 ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
156 while [ ! -e .git ] ; do
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
157 cd ..
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
158 done
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
159 return 0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
160 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
161 if [ -e .svn ] ; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
162 while [ -e ../.svn ] ; do
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
163 cd ..
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
164 done
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
165 return 0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
166 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
167 echo No working copy found'!'
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
168 }