9 echo "usage: ikiwiki-makerepo svn|git|monotone srcdir repository" >&2
10 echo " ikiwiki-makerepo bzr|mercurial srcdir" >&2
14 if [ -z "$rcs" ] ||
[ -z "$srcdir" ]; then
18 if [ ! -d "$srcdir" ]; then
19 echo "srcdir $srcdir not found" >&2
23 if [ "$rcs" != mercurial
] && [ "$rcs" != bzr
]; then
24 if [ -z "$repository" ]; then
25 echo "you need to specify both a srcdir and a repository for $rcs" >&2
28 if [ -e "$repository" ]; then
29 echo "repository $repository already exists, aborting" >&2
32 repository
="$(perl -e 'use Cwd q{abs_path}; $r=shift; $r=~s/\/*$//; print abs_path($r)' "$repository")"
33 if [ -z "$repository" ]; then
34 echo "internal error finding repository abs_path" >&2
39 echo "Importing $srcdir into $rcs"
43 if [ -e "$srcdir/.svn" ]; then
44 echo "$srcdir already seems to be a svn working copy" >&2
47 svnadmin create
"$repository"
48 svn mkdir
"file://$repository/trunk" -m "create trunk directory"
50 svn co
"file://$repository/trunk" .
51 svn propset svn
:ignore
".ikiwiki" .
53 svn commit
-m "initial import"
54 echo "Directory $srcdir is now a checkout of $rcs repository $repository"
57 # There are better ways to do this, but this works with older
59 mkdir
-p "$repository"
60 (cd "$repository" && git
--bare init
--shared)
64 echo /.ikiwiki
> .gitignore
65 echo /recentchanges
>> .gitignore
67 git commit
-m "initial commit"
68 git remote add origin
"$repository"
69 git config branch.master.merge refs
/heads
/master
70 git config branch.master.remote origin
72 echo "Directory $srcdir is now a clone of $rcs repository $repository"
77 echo .ikiwiki
> .hgignore
79 hg commit
-m "initial import"
80 echo "Directory $srcdir is now set up as a mercurial repository"
85 echo .ikiwiki
> .bzrignore
87 bzr commit
-m "initial import"
88 echo "Directory $srcdir is now set up as a bzr repository"
91 if [ -e "$srcdir/_MTN" ]; then
92 echo "$srcdir already seems to be a monotone working copy" >&2
96 mkdir
-p "$(dirname "$repository")"
97 mtn db init
-d "$repository"
99 cleaned_srcdir
=$
(basename "$srcdir" |
tr -s "[:space:]" "_" |
sed 's/_$//g')
100 reverse_hostname
=$
( (hostname
-f 2>/dev
/null || hostname
) |\
101 tr "." "\n" |
( tac 2>/dev
/null ||
tail -r ) |
tr "\n" "." )
102 branch_name
="$reverse_hostname$cleaned_srcdir"
103 mtn setup
-d "$repository" -b "$branch_name" "$srcdir"
106 echo \.ikiwiki$
> .mtn-ignore
108 # this expects that you already have a working mtn environment
109 # with a default key floating around...
110 mtn ci
-m "initial import"
111 echo "Directory $srcdir is now set up as a monotone repository"
113 echo "Note: If your monotone key has a passphrase, you need to configure"
114 echo "monotone to automatically use it. Otherwise, web commits to ikiwiki"
117 echo "You can create a $srcdir/_MTN/monotonerc"
118 echo "containing the passphrase:"
120 echo "function get_passphrase (branchname)"
121 echo ' return "passphrasehere"'
125 echo "Unsupported revision control system $rcs" >&2