first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / scripts / rev_control / rev_control.sh
1 #!/bin/bash
2
3 # these are helper functions for doing localized revision control.
4 # this script should be sourced into other scripts that use it.
5
6 this_host=
7 # gets the machine's hostname and stores it in the variable "this_host".
8 function get_our_hostname()
9 {
10   if [ "$OS" == "Windows_NT" ]; then
11     this_host=$(hostname)
12   elif [ ! -z "$(echo $MACHTYPE | grep apple)" ]; then
13     this_host=$(hostname)
14   elif [ ! -z "$(echo $MACHTYPE | grep suse)" ]; then
15     this_host=$(hostname --long)
16   else
17     this_host=$(hostname)
18   fi
19   #echo "hostname is $this_host"
20 }
21
22 # this function sets a variable called "home_system" to "true" if the
23 # machine is considered one of fred's home machines.  if you are not
24 # fred, you may want to change the machine choices.
25 export home_system=
26 function is_home_system()
27 {
28   # load up the name of the host.
29   get_our_hostname
30   # reset the variable that we'll be setting.
31   home_system=
32   if [[ $this_host == *.gruntose.blurgh ]]; then
33     home_system=true
34 #temp code
35 elif [[ $this_host == buildy ]]; then
36 home_system=true
37 elif [[ $this_host == simmy ]]; then
38 home_system=true
39 #temp code
40   fi
41 }
42
43 # we only want to totally personalize this script if the user is right.
44 function check_user()
45 {
46   if [ "$USER" == "fred" ]; then
47     export SVNUSER=fred_t_hamster@
48     export EXTRA_PROTOCOL=+ssh
49   else
50     export SVNUSER=
51     export EXTRA_PROTOCOL=
52   fi
53 }
54
55 # calculates the right modifier for hostnames / repositories.
56 modifier=
57 function compute_modifier()
58 {
59   modifier=
60   directory="$1"; shift
61   in_or_out="$1"; shift
62   check_user
63   # some project specific overrides.
64   if [[ "$directory" == hoople* ]]; then
65     modifier="svn${EXTRA_PROTOCOL}://${SVNUSER}svn.code.sf.net/p/hoople2/svn/"
66   fi
67   if [[ "$directory" == yeti* ]]; then
68     modifier="svn${EXTRA_PROTOCOL}://${SVNUSER}svn.code.sf.net/p/yeti/svn/"
69   fi
70   # see if we're on one of fred's home machines.
71   is_home_system
72   # special override to pick local servers when at home.
73   if [ "$home_system" == "true" ]; then
74     if [ "$in_or_out" == "out" ]; then
75       # need the right home machine for modifier when checking out.
76       modifier="svn://shaggy/"
77     else 
78       # no modifier for checkin.
79       modifier=
80     fi
81   fi
82 }
83