9 echo "usage: ikiwiki-makerepo svn|git|svn|monotone|darcs|cvs 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; $r=shift; $r=getcwd.q{/}.$r if $r!~m!^/!; print $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/CVS" ]; then
44 echo "$srcdir already seems to be a cvs working copy" >&2
47 cvs -Q -d "$repository" init
49 cvs -Q -d "$repository" get -P CVSROOT
51 echo .ikiwiki >> cvsignore
53 echo "^ikiwiki $repository/CVSROOT/post-commit %{sVv} &" >> loginfo
54 cvs -Q commit -m "ikiwiki-makerepo setup" cvsignore loginfo
58 cvs -Q -d "$repository" import -m "initial import" ikiwiki IKIWIKI PRE_CVS
60 mv "$srcdir" "$srcdir.orig"
61 cvs -Q -d "$repository" get -P -d "$(basename "$srcdir")" ikiwiki
62 [ -d "$srcdir.orig/.ikiwiki" ] && mv "$srcdir.orig/.ikiwiki" "$srcdir"
64 echo "Directory $srcdir is now a checkout of $rcs repository $repository"
67 if [ -e "$srcdir/.svn" ]; then
68 echo "$srcdir already seems to be a svn working copy" >&2
71 svnadmin create "$repository"
72 svn mkdir "file://$repository/trunk" -m "create trunk directory"
74 svn co "file://$repository/trunk" .
75 svn propset svn:ignore ".ikiwiki" .
77 svn commit -m "initial import"
78 echo "Directory $srcdir is now a checkout of $rcs repository $repository"
81 # There are better ways to do this, but this works with older
83 mkdir -p "$repository"
84 (cd "$repository" && git --bare init --shared)
88 echo /.ikiwiki > .gitignore
89 echo /recentchanges >> .gitignore
91 git commit -m "initial commit"
92 git remote add origin "$repository"
93 git config branch.master.merge refs/heads/master
94 git config branch.master.remote origin
96 echo "Directory $srcdir is now a clone of $rcs repository $repository"
101 echo .ikiwiki > .hgignore
103 hg commit -m "initial import"
104 echo "Directory $srcdir is now set up as a mercurial repository"
109 echo .ikiwiki > .bzrignore
111 bzr commit -m "initial import"
112 echo "Directory $srcdir is now set up as a bzr repository"
115 if [ -e "$srcdir/_MTN" ]; then
116 echo "$srcdir already seems to be a monotone working copy" >&2
120 mkdir -p "$(dirname "$repository")"
121 mtn db init -d "$repository"
123 cleaned_srcdir=$(basename "$srcdir" | tr -s "[:space:]" "_" | sed 's/_$//g')
124 reverse_hostname=$( (hostname -f 2>/dev/null || hostname) |\
125 tr "." "\n" | ( tac 2>/dev/null || tail -r ) | tr "\n" "." )
126 branch_name="$reverse_hostname$cleaned_srcdir"
127 mtn setup -d "$repository" -b "$branch_name" "$srcdir"
130 echo \.ikiwiki$ > .mtn-ignore
132 # this expects that you already have a working mtn environment
133 # with a default key floating around...
134 mtn ci -m "initial import"
135 echo "Directory $srcdir is now set up as a monotone repository"
137 echo "Note: If your monotone key has a passphrase, you need to configure"
138 echo "monotone to automatically use it. Otherwise, web commits to ikiwiki"
141 echo "You can create a $srcdir/_MTN/monotonerc"
142 echo "containing the passphrase:"
144 echo "function get_passphrase (branchname)"
145 echo ' return "passphrasehere"'
149 if [ -e "$srcdir/_darcs" ]; then
150 echo "$srcdir already seems to be a darcs repository" >&2
154 mkdir -p "$repository"
155 (cd "$repository" && darcs initialize)
160 echo .ikiwiki >> _darcs/prefs/boring
161 darcs record -a -l -q -m "initial import"
162 darcs pull -a -q "$repository"
163 darcs push -a -q "$repository"
164 echo "Directory $srcdir is now a branch of darcs repo $repository"
166 # set up master repo's apply hook and tell user to adjust it if desired
167 darcsdefaults="$repository/_darcs/prefs/defaults"
168 echo "Preconfiguring apply hook in $darcsdefaults - adjust as desired!"
169 echo "apply posthook $repository/_darcs/ikiwiki-wrapper" >> "$darcsdefaults"
170 echo "apply run-posthook" >> "$darcsdefaults"
173 echo "Unsupported revision control system $rcs" >&2