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