Debian Codegraph @

lib/get-config-dir-hg

raw
1 #!/bin/bash
2
3 # (c) 2002-2006 Henning Glawe <[email protected]>
4 # (c) 2007 Holger Levsen <[email protected]> for the modifications to use git
5 # (c) 2009 Darshaka Pathirana <[email protected]> for the modifications to use hg
6
7 ### BEGIN SUBROUTINE INFO
8 # Provides-Var:
9 # Requires-Var: $FAI_CONFIG_SRC $FAI $LOGDIR
10 # Suggests-Var:
11 # Short-Description: get $FAI from a mercurial (hg) repository.
12 ### END SUBROUTINE INFO
13
14 # matched string: "hg://hgpath"
15 protocol=$(expr match "$FAI_CONFIG_SRC" '\([^:]*\)://')
16 hgpath=$(expr match "$FAI_CONFIG_SRC" '[^:]*://\([^[:space:]]\+\)')
17
18 case $protocol in
19 hg+http)
20 echo hg+http
21 hgurl="http://$hgpath"
22 ;;
23 hg+https)
24 echo hg+https
25 hgurl="https://$hgpath"
26 ;;
27 *)
28 echo "get-config-dir-hg: protocol $protocol not implemented"
29 exit 1
30 ;;
31 esac
32
33 if [ -d "$FAI/.hg" ] ; then
34 #TODO: check whether the checkout is from $hgurl
35 echo "Updating hg copy in $FAI"
36 cd $FAI
37 hg pull -u
38 task_error 881 $?
39 else
40 echo "Checking out from hg"
41 # cloning into an existing directory is not allowed
42 if [ -d $FAI ]; then rmdir $FAI; fi
43 hg clone $hgurl $FAI
44 task_error 882 $?
45 fi