Mercurial > dotfiles
annotate .zsh/50.vcs_functions.zsh @ 27:614a83a1c5dd
Add js2-mode.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Tue, 30 Dec 2008 13:25:23 -0600 |
parents | 0de17fe9c428 |
children | a5691a22c92b |
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 | |
13
c22ca1514f3b
Add an alias to ease working with mq repos.
Augie Fackler <durin42@gmail.com>
parents:
10
diff
changeset
|
5 alias mq='hg -R .hg/patches' |
c22ca1514f3b
Add an alias to ease working with mq repos.
Augie Fackler <durin42@gmail.com>
parents:
10
diff
changeset
|
6 |
0 | 7 # Function to grab the url of an svn wc |
8 function svnurlof() { | |
9 local url | |
10 url=`svn info $1 2> /dev/null | grep '^URL: ' | sed 's/URL: //'` | |
11 if [ x"$url" = "x" ] ; then | |
12 url=`git svn info $1 2> /dev/null | grep '^URL: ' | sed 's/URL: //'` | |
13 fi | |
14 if [ x"$url" = "x" ] ; then | |
15 local dir | |
16 dir=$1 | |
17 if [ x"$dir" = "x" ] ; then | |
18 dir="." | |
19 fi | |
20 url=`hg -R $dir svn info 2> /dev/null | grep '^URL: ' | sed 's/URL: //'` | |
21 fi | |
22 if [ x"$url" = "x" ] ; then | |
23 echo -n 'No repo found (tried svn, git-svn, hgsvnclient)' | |
24 fi | |
25 echo $url | |
26 } | |
27 | |
28 # Function to clean locks out of svn wcs | |
29 function clean_svn_source_trees() { | |
30 for aa in */ ; do | |
31 pushd $aa > /dev/null | |
32 if [ -e .svn ] ; then | |
33 echo $aa 'is an svn checkout, cleaning' && svn cleanup | |
34 fi | |
35 popd > /dev/null | |
36 done | |
37 } | |
38 | |
39 # Function to update source trees of known VCS tools in the working dir. | |
40 # "known" means ones I'm forced to use on a regular basis | |
41 function update_source_trees() { | |
42 for aa in */ ; do | |
43 pushd $aa > /dev/null | |
44 if [ -e .svn ] ; then | |
45 echo $aa 'is an svn checkout, updating' | |
46 svn up | |
47 elif [ -e .hg/svn ] ; then | |
48 echo $aa 'is an hg-svn checkout, updating' | |
49 hg svn pull | |
50 hg up | |
51 elif [ -e .git/svn ] ; then | |
52 echo $aa 'is a git-svn checkout, updating' | |
53 git svn fetch | |
54 git repack | |
55 git gc | |
56 elif [ -e .git ] ; then | |
57 echo $aa 'is a git checkout, updating' | |
58 git pull origin master | |
59 git repack | |
60 git gc | |
61 elif [ -e .hg ] ; then | |
62 echo $aa 'is an hg checkout, updating' && hg pull && hg up | |
63 elif [ -e _MTN ] ; then | |
64 echo $aa "is an mtn co, updating" && mtn pull && mtn up | |
65 fi | |
66 popd > /dev/null | |
67 done | |
68 } | |
69 | |
70 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
|
71 git branch 2> /dev/null > /dev/null |
0 | 72 if [ $? = 0 ] ; then |
73 git branch --verbose | grep '^*' | sed 's/* //;s/ /:/;s/ .*//;s/:/ /' | |
74 return 0 | |
75 fi | |
76 # when wc-ng comes out, we'll probably do the following | |
77 # svn info 2> /dev/null > /dev/null | |
78 if [ -e .svn ] ; then | |
79 local d=`svn info | grep URL | sed 's/.*://'` | |
80 local br=`echo $d | awk '{ | |
81 if ( index($1, "trunk") ) { | |
82 print "trunk" | |
83 } else { | |
84 x = index($1, "branches") ; | |
85 if ( x != 0 ) { | |
86 sub(".*/branches/", ""); | |
87 sub("/.*", ""); | |
88 print $0 | |
89 } | |
90 } | |
91 }'` | |
92 local rev=`svn info | grep Revision | sed 's/.*: /r/'` | |
93 echo $br $rev | |
94 return 0 | |
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 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
|
102 fi |
0 | 103 return 1 |
104 } | |
105 | |
106 # change to the root dir of the current wc | |
107 function wcroot() { | |
108 local root=`hg root 2> /dev/null` | |
109 if [ x$root != 'x' ] ; then | |
110 cd $root | |
111 return 0 | |
112 fi | |
113 git branch 2> /dev/null > /dev/null | |
114 if [ $? = 0 ] ; then | |
115 while [ ! -e .git ] ; do | |
116 cd .. | |
117 done | |
118 return 0 | |
119 fi | |
120 if [ -e .svn ] ; then | |
121 while [ -e ../.svn ] ; do | |
122 cd .. | |
123 done | |
124 return 0 | |
125 fi | |
126 echo No working copy found'!' | |
127 } |