]> sipb.mit.edu Git - ikiwiki.git/blob - ikiwiki-makerepo
web commit by bremner
[ikiwiki.git] / ikiwiki-makerepo
1 #!/bin/sh
2 set -e
3
4 rcs="$1"
5 srcdir="$2"
6 repository="$3"
7         
8 usage () {
9         echo "usage: ikiwiki-makerepo svn|git srcdir repository" >&2
10         echo "       ikiwiki-makerepo bzr|mercurial srcdir" >&2
11         exit 1
12 }
13
14 if [ -z "$rcs" ] || [ -z "$srcdir" ]; then
15         usage
16 fi
17
18 if [ ! -d "$srcdir" ]; then
19         echo "srcdir $srcdir not found" >&2 
20         exit 1
21 fi
22
23 if [ "$rcs" != mercurial ] && [ "$rcs" != bzr ]; then
24         if [ -e "$repository" ]; then
25                 echo "repository $repository already exists, aborting" >&2 
26                 exit 1
27         fi
28         repository="$(perl -e 'use Cwd q{abs_path}; $r=shift; $r=~s/\/*$//; print abs_path($r)' $repository)"
29         if [ -z "$repository" ]; then
30                 echo "internal error finding repository abs_path" >&2
31                 exit 1
32         fi
33 fi
34
35 echo "Importing $srcdir into $rcs"
36
37 case "$rcs" in
38 svn)
39         if [ -e "$srcdir/.svn" ]; then
40                 echo "$srcdir already seems to be a svn working copy" >&2
41                 exit 1
42         fi
43         svnadmin create "$repository"
44         svn mkdir "file://$repository/trunk" -m "create trunk directory"
45         cd "$srcdir"
46         svn co "file://$repository/trunk" .
47         svn propset svn:ignore ".ikiwiki" .
48         svn add *
49         svn commit -m "initial import"
50         echo "Directory $srcdir is now a checkout of $rcs repository $repository"
51 ;;
52 git)
53         # There are better ways to do this, but this works with older
54         # versions of git.)
55         mkdir -p "$repository"
56         (cd "$repository" && git --bare init --shared)
57
58         cd "$srcdir"
59         git init
60         echo /.ikiwiki > .gitignore
61         git add .
62         git commit -m "initial commit"
63         git remote add origin "$repository"
64         git config branch.master.merge refs/heads/master
65         git push --all
66         echo "Directory $srcdir is now a clone of $rcs repository $repository"
67 ;;
68 mercurial)
69         hg init "$srcdir"
70         cd "$srcdir"
71         echo .ikiwiki > .hgignore
72         hg add * .hgignore
73         hg commit -m "initial import"
74         echo "Directory $srcdir is now set up as a mercurial repository"
75 ;;
76 bzr)
77         bzr init "$srcdir"
78         cd "$srcdir"
79         echo .ikiwiki > .bzrignore
80         bzr add * .bzrignore
81         bzr commit -m "initial import"
82         echo "Directory $srcdir is now set up as a bzr repository"
83 ;;
84 *)
85         echo "Unsupported revision control system $rcs" >&2
86         usage
87 ;;
88 esac