9 echo "usage: ikiwiki-makerepo cvs|svn|git|monotone|darcs 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
48 cat > "$repository/CVSROOT/post-commit-wrapper" <<EOF
51 IKIWIKI_POST_COMMIT_HOOK="$repository/CVSROOT/post-commit"
53 exists_ikiwiki_post_commit_hook() {
54 [ -x \$IKIWIKI_POST_COMMIT_HOOK ];
57 called_with_exactly_one_dir() {
58 echo "\$@" | grep 'New directory' >/dev/null 2>&1
62 exists_ikiwiki_post_commit_hook || exit 0
63 called_with_exactly_one_dir "\$@" && exit 0
64 # Return from commit and relinquish write lock. ikiwiki post-commit
65 # wants to "cvs update", which wants to take a read lock.
66 \$IKIWIKI_POST_COMMIT_HOOK &
73 chmod +x "$repository/CVSROOT/post-commit-wrapper"
75 cvs -Q -d "$repository" get -P CVSROOT
77 echo .ikiwiki >> cvsignore
79 echo "^ikiwiki $repository/CVSROOT/post-commit-wrapper %{sVv}" >> loginfo
80 cvs -Q commit -m "ikiwiki-makerepo setup" cvsignore loginfo
84 cvs -Q -d "$repository" import -m "initial import" ikiwiki IKIWIKI PRE_CVS
86 mv "$srcdir" "$srcdir.orig"
87 cvs -Q -d "$repository" get -P -d "$(basename "$srcdir")" ikiwiki
88 [ -d "$srcdir.orig/.ikiwiki" ] && mv "$srcdir.orig/.ikiwiki" "$srcdir"
90 echo "Directory $srcdir is now a checkout of $rcs repository $repository"
93 if [ -e "$srcdir/.svn" ]; then
94 echo "$srcdir already seems to be a svn working copy" >&2
97 svnadmin create "$repository"
98 svn mkdir "file://$repository/trunk" -m "create trunk directory"
100 svn co "file://$repository/trunk" .
101 svn propset svn:ignore ".ikiwiki" .
103 svn commit -m "initial import"
104 echo "Directory $srcdir is now a checkout of $rcs repository $repository"
107 # There are better ways to do this, but this works with older
109 mkdir -p "$repository"
110 (cd "$repository" && git --bare init --shared)
114 echo /.ikiwiki > .gitignore
115 echo /recentchanges >> .gitignore
117 git commit -m "initial commit"
118 git remote add origin "$repository"
119 git config branch.master.merge refs/heads/master
120 git config branch.master.remote origin
122 echo "Directory $srcdir is now a clone of $rcs repository $repository"
127 echo .ikiwiki > .hgignore
129 hg commit -m "initial import"
130 echo "Directory $srcdir is now set up as a mercurial repository"
135 echo .ikiwiki > .bzrignore
137 bzr commit -m "initial import"
138 echo "Directory $srcdir is now set up as a bzr repository"
141 if [ -e "$srcdir/_MTN" ]; then
142 echo "$srcdir already seems to be a monotone working copy" >&2
146 mkdir -p "$(dirname "$repository")"
147 mtn db init -d "$repository"
149 cleaned_srcdir=$(basename "$srcdir" | tr -s "[:space:]" "_" | sed 's/_$//g')
150 reverse_hostname=$( (hostname -f 2>/dev/null || hostname) |\
151 tr "." "\n" | ( tac 2>/dev/null || tail -r ) | tr "\n" "." )
152 branch_name="$reverse_hostname$cleaned_srcdir"
153 mtn setup -d "$repository" -b "$branch_name" "$srcdir"
156 echo \.ikiwiki$ > .mtn-ignore
158 # this expects that you already have a working mtn environment
159 # with a default key floating around...
160 mtn ci -m "initial import"
161 echo "Directory $srcdir is now set up as a monotone repository"
163 echo "Note: If your monotone key has a passphrase, you need to configure"
164 echo "monotone to automatically use it. Otherwise, web commits to ikiwiki"
167 echo "You can create a $srcdir/_MTN/monotonerc"
168 echo "containing the passphrase:"
170 echo "function get_passphrase (branchname)"
171 echo ' return "passphrasehere"'
175 if [ -e "$srcdir/_darcs" ]; then
176 echo "$srcdir already seems to be a darcs repository" >&2
180 mkdir -p "$repository"
181 (cd "$repository" && darcs initialize)
186 echo .ikiwiki >> _darcs/prefs/boring
187 darcs record -a -l -q -m "initial import"
188 darcs pull -a -q "$repository"
189 darcs push -a -q "$repository"
190 echo "Directory $srcdir is now a branch of darcs repo $repository"
192 # set up master repo's apply hook and tell user to adjust it if desired
193 darcsdefaults="$repository/_darcs/prefs/defaults"
194 echo "Preconfiguring apply hook in $darcsdefaults - adjust as desired!"
195 echo "apply posthook $repository/_darcs/ikiwiki-wrapper" >> "$darcsdefaults"
196 echo "apply run-posthook" >> "$darcsdefaults"
199 echo "Unsupported revision control system $rcs" >&2