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 if [ -z "$(git config user.name)" ]; then
89 git config user.name IkiWiki
91 if [ -z "$(git config user.email)" ]; then
92 git config user.email ikiwiki.info
94 echo /.ikiwiki > .gitignore
96 git commit -m "initial commit"
97 git remote add origin "$repository"
98 git config branch.master.merge refs/heads/master
99 git config branch.master.remote origin
101 echo "Directory $srcdir is now a clone of $rcs repository $repository"
106 echo .ikiwiki > .hgignore
108 hg commit -m "initial import"
109 echo "Directory $srcdir is now set up as a mercurial repository"
114 echo .ikiwiki > .bzrignore
116 bzr commit -m "initial import"
117 echo "Directory $srcdir is now set up as a bzr repository"
120 if [ -e "$srcdir/_MTN" ]; then
121 echo "$srcdir already seems to be a monotone working copy" >&2
125 mkdir -p "$(dirname "$repository")"
126 mtn db init -d "$repository"
128 cleaned_srcdir=$(basename "$srcdir" | tr -s "[:space:]" "_" | sed 's/_$//g')
129 reverse_hostname=$( (hostname -f 2>/dev/null || hostname) |\
130 tr "." "\n" | ( tac 2>/dev/null || tail -r ) | tr "\n" "." )
131 branch_name="$reverse_hostname$cleaned_srcdir"
132 mtn setup -d "$repository" -b "$branch_name" "$srcdir"
135 echo \.ikiwiki$ > .mtn-ignore
137 # this expects that you already have a working mtn environment
138 # with a default key floating around...
139 mtn ci -m "initial import"
140 echo "Directory $srcdir is now set up as a monotone repository"
142 echo "Note: If your monotone key has a passphrase, you need to configure"
143 echo "monotone to automatically use it. Otherwise, web commits to ikiwiki"
146 echo "You can create a $srcdir/_MTN/monotonerc"
147 echo "containing the passphrase:"
149 echo "function get_passphrase (branchname)"
150 echo ' return "passphrasehere"'
154 if [ -e "$srcdir/_darcs" ]; then
155 echo "$srcdir already seems to be a darcs repository" >&2
159 mkdir -p "$repository"
160 (cd "$repository" && darcs initialize)
165 echo .ikiwiki >> _darcs/prefs/boring
166 darcs record -a -l -q -m "initial import"
167 darcs pull -a -q "$repository"
168 darcs push -a -q "$repository"
169 echo "Directory $srcdir is now a branch of darcs repo $repository"
171 # set up master repo's apply hook and tell user to adjust it if desired
172 darcsdefaults="$repository/_darcs/prefs/defaults"
173 echo "Preconfiguring apply hook in $darcsdefaults - adjust as desired!"
174 echo "apply posthook $repository/_darcs/ikiwiki-wrapper" >> "$darcsdefaults"
175 echo "apply run-posthook" >> "$darcsdefaults"
178 echo "Unsupported revision control system $rcs" >&2