Initial add of defaria.com
[clearscm.git] / defaria.com / GD / rc / clearcase
1 #!/bin/bash
2 ################################################################################
3 #
4 # File:         $RCSfile: clearcase,v $
5 # Revision:     $Revision: 1.8 $ 
6 # Description:  This script set up some useful environment variables and aliases
7 #               for Clearcase execution. File should be sourced (e.g . 
8 #               clearcase)
9 # Author:       Andrew@DeFaria.com
10 # Created:      Wed Jun  5 21:08:03 PDT 1996
11 # Modified:     $Date: 2006/05/15 17:59:30 $
12 # Assumptions:  ARCH is set represent the host's architecture (e.g. "sun", 
13 #               "cygwin", etc.)
14 # Language:     bash
15 #
16 # (c) Copyright 2000-2005, Andrew@DeFaria.com, all rights reserved.
17 #
18 ################################################################################
19 if [ $ARCH = "cygwin" ]; then
20   export CCHOME=${CCHOME:-"$SYSTEMDRIVE/Program Files/Rational/ClearCase"}
21 else 
22   export CCHOME=/opt/rational/clearcase
23 fi
24
25 if [ ! -d "$CCHOME" ]; then
26   unset CCHOME
27   return
28 fi
29
30 export CLEARTOOL="$CCHOME/bin/cleartool"
31 export CLEARCASE_BLD_HOST_TYPE=unix
32
33 if [ -f "$CCHOME/etc/utils/creds" ]; then
34   if [ $ARCH = "cygwin" ]; then
35     alias creds=$(cygpath "$CCHOME/etc/utils/creds")
36   else 
37     alias creds="$CCHOME/etc/utils/creds"
38   fi
39 fi
40
41 if [ -x "$CLEARTOOL" ]; then
42   alias clist='ct lsco -short -cview -all'
43   alias ciwork='ct ci -cq `ct lsco -cview -me -all -sh`'
44   alias lsbr='ct lstype -brtype'
45   alias lslab='ct lstype -lbtype'
46   #export WINEDITOR=edit
47   export RGY="$CCHOME/var/atria/rgy"
48   export LOGS="$CCHOME/var/log"
49 fi
50
51 function ct {
52   if [ -x "$CLEARTOOL" ]; then
53     "$CLEARTOOL" "$@"
54   else
55     echo "ClearCase is not installed on this system!"
56   fi
57 } # ct
58
59 # View related functions
60 function setview {
61   if [ $ARCH = "cygwin" ]; then 
62     # Save off where we are
63     back=$PWD
64
65     # Start the view
66     startview "$@"
67
68     # Setup /vob
69     mount -bf X:/$1 /vob
70
71     # Chdir to the view root
72     cd /view/$1
73
74     # Start a bash shell
75     bash --noprofile
76
77     # Remove /vob mount
78     umount /vob
79
80     # Chdir back to were we started
81     cd $back
82   else
83     ct setview "$@"
84   fi
85
86   set_title
87   set_prompt
88 } # setview
89
90 function startview {
91   ct startview "$@"
92
93   _cd /view/$1
94 } # startview
95
96 function endview {
97   ct endview "$@"
98 } # endview
99
100 function killview {
101   ct endview -server "$@"
102 } # killview
103
104 function mkview {
105   ct mkview "$@"
106 } # mkview
107
108 function rmview {
109   ct rmview "$@"
110 } # rmview
111
112 function lsview {
113   if [ $# = 0 ]; then
114     ct lsview | $PAGER
115   elif [ $# = 1 ]; then
116     ct lsview | grep "$1"
117   else
118     ct lsview "$@"
119   fi
120 } # lsview
121
122 function myviews {
123   # Well they asked for my "views"...
124   if [ $(whence fortune) ]; then
125     fortune
126     echo
127   fi    
128
129   # List my views and their associated activities
130   for view in $(ct lsview -s 2>&1 | tr -d \r | grep $USER); do
131     headline=$(ct lsact -cact -fmt "%[headline]p" -view $view 2> /dev/null)
132    
133     if [ "$headline" = "" ]; then
134       headline="<no activity set>"
135     fi
136
137     echo -e "$view\t$headline"
138   done
139 } # myviews
140
141 function llview {
142   if [ $# = 0 ]; then
143     ct lsview -long | $PAGER
144   else 
145     ct lsview -long "$@"
146   fi
147 } # llview
148
149 # Vob related functions
150 function lsvob {
151   if [ $# = 0 ]; then
152     ct lsvob | $PAGER
153   elif [ $# = 1 ]; then
154     ct lsvob | grep "$1"
155   else
156     ct lsvob "$@"
157   fi
158 } # lsvob
159
160 function llvob {
161   if [ $# = 0 ]; then
162     ct lsvob -long | $PAGER
163   else 
164     ct lsvob -long "$@"
165   fi
166 } # llvob
167
168 # Config spec functions
169 function setcs {
170   ct setcs "$@"
171 } # setcs
172
173 function edcs {
174   ct edcs "$@"
175 } # edcs
176
177 function catcs {
178   ct catcs "$@"
179 } # catcs
180
181 function pwv {
182   ct pwv -s "$@"
183 } # pwv
184
185 function rmtag {
186   ct rmtag "$@"
187 } # rmtag
188
189 function mktag {
190   ct mktag "$@"
191 } # mktag
192
193 function describe {
194   ct describe "$@"
195 } # describe
196
197 # Action functions
198 function vtree {
199   if [ $# != 1 ]; then
200     echo "vtree: Error: Must specify a file to view."
201   else
202     if [ $ARCH = "cygwin" ]; then
203       ct lsvtree -g "$@"
204     else
205       xlsvtree "$@"
206     fi
207   fi
208 } # vtree
209
210 function unco {
211   if [ $# = 0 ]; then
212     echo "unco: Error: No files specified"
213   else
214     ct unco -rm "$@"
215   fi
216 } # unco
217
218 function merge {
219   ct merge "$@"
220 } # merge
221
222 function findmerge {
223   ct findmerge "$@"
224 } # findmerge
225
226 function cdiff {
227   if [ $# = 1 ]; then
228     ct diff -graphical -pred $1
229   else
230     ct diff -graphical -diff "$@"
231   fi
232 } # cdiff
233
234 function ctdiff {
235   if [ $# = 1 ]; then
236     ct xdiff -vstack -pred $1
237   else
238     ct xdiff -vstack $@
239   fi
240 } # ctdiff
241
242 # Administrative functions
243 function space {
244   ct space "$@"
245 } # space
246
247 function register {
248   ct register "$@"
249 } # register
250
251 function unregister {
252   ct unregister "$@"
253 } # unregister
254
255 # Information functions
256 function hostinfo {
257   ct hostinfo "$@"
258 } # hostinfo
259
260 function lstrig {
261   if [ $# = 2 ]; then
262     trig_name=$1
263     vob=$2
264     ct lstype trtype:$trig_name@$vob
265   else
266     ct lstype -kind trtype "$@" | $PAGER
267   fi
268 } # lstrig
269
270 function lltrig {
271   if [ $# = 1 ]; then
272     ct lstype -long trtype:$1
273   else
274     ct lstype -long -kind trtype "$@"| $PAGER
275   fi
276 } # lltrig
277
278 # UCM oriented functions
279 function lsstream {
280   if [ $# = 0 ]; then
281     ct lsstream | $PAGER
282   else
283     ct lsstream "$@"
284   fi
285 } # lsstream
286
287 function llstream {
288   if [ $# = 0 ]; then
289     ct lsstream -l | $PAGER
290   else
291     ct lsstream -l "$@"
292   fi
293 } # llstream
294
295 function rebase {
296   ct rebase "$@"
297 } # rebase
298
299 function deliver {
300   ct deliver "$@"
301 } # deliver
302
303 function lsbl {
304   ct lsbl "$@"
305 } # lsbl
306
307 function lsproject {
308   if [ $# = 0 ]; then
309     ct lsproject | $PAGER
310   else
311     ct lsproject "$@"
312   fi
313 } # lsproject
314
315 function llproject {
316   if [ $# = 0 ]; then
317     ct lsproject -l | $PAGER
318   else
319     ct lsproject -l "$@"
320   fi
321 } # llproject
322
323 function lsstgloc {
324   if [ $# = 0 ]; then
325     ct lsstgloc | $PAGER
326   else
327     ct lsstgloc "$@"
328   fi
329 } # lsstgloc
330
331 function llstgloc {
332   if [ $# = 0 ]; then
333     ct lsstgloc -l | $PAGER
334   else
335     ct lsstgloc -l "$@"
336   fi
337 } # llstgloc
338
339 function lsstream {
340   if [ $# = 0 ]; then
341     ct lsstream | $PAGER
342   else
343     ct lsstream "$@"
344   fi
345 } # lsstream
346
347 function llstream {
348   if [ $# = 0 ]; then
349     ct lsstream -l | $PAGER
350   else
351     ct lsstream -l "$@"
352   fi
353 } # llstream