[Pkg-ocaml-maint-commits] r5329 - in /trunk/tools/svn2git: svn2git_alioth svn2git_pkg-ocaml-maint

zack at users.alioth.debian.org zack at users.alioth.debian.org
Tue Mar 18 08:00:46 UTC 2008


Author: zack
Date: Tue Mar 18 08:00:45 2008
New Revision: 5329

URL: http://svn.debian.org/wsvn/?sc=1&rev=5329
Log:
support for excuting stepwise the various phases of the conversion

Modified:
    trunk/tools/svn2git/svn2git_alioth
    trunk/tools/svn2git/svn2git_pkg-ocaml-maint

Modified: trunk/tools/svn2git/svn2git_alioth
URL: http://svn.debian.org/wsvn/trunk/tools/svn2git/svn2git_alioth?rev=5329&op=diff
==============================================================================
--- trunk/tools/svn2git/svn2git_alioth (original)
+++ trunk/tools/svn2git/svn2git_alioth Tue Mar 18 08:00:45 2008
@@ -15,46 +15,70 @@
 TGZ_PATTERN="*.tar.gz"	# find (-name) syntax
 
 usage () {
-  echo "Usage:   svn2git_alioth TRUNK_URL BRANCHES_URL TAGS_URL DESTDIR"
+  echo "Usage:   svn2git_alioth -T TRUNK_URL -b BRANCHES_URL -t TAGS_URL -o DESTDIR"
   echo "Example: svn2git_alioth \\"
-  echo "           svn+ssh://svn.debian.org/svn/pkg-ocaml-maint/trunk/packages/pcre-ocaml/trunk \\"
-  echo "           svn+ssh://svn.debian.org/svn/pkg-ocaml-maint/trunk/packages/pcre-ocaml/branches \\"
-  echo "           svn+ssh://svn.debian.org/svn/pkg-ocaml-maint/tags/packages/pcre-ocaml \\"
-  echo "           /some/where/pcre-ocaml.git"
+  echo "           -T svn://svn.debian.org/svn/pkg-ocaml-maint/trunk/packages/pcre-ocaml/trunk \\"
+  echo "           -b svn://svn.debian.org/svn/pkg-ocaml-maint/trunk/packages/pcre-ocaml/branches \\"
+  echo "           -t svn://svn.debian.org/svn/pkg-ocaml-maint/tags/packages/pcre-ocaml \\"
+  echo "           -o /some/where/pcre-ocaml.git"
 }
 
-TRUNK="$1"
-BRANCHES="$2"
-TAGS="$3"
-DESTDIR="$4"
+TRUNK=""
+BRANCHES=""
+TAGS=""
+DESTDIR=""
+PHASES=""
 
-if [ -z "$TRUNK" -o -z "$BRANCHES" -o -z "$TAGS" -o -z "$DESTDIR" ] ; then
-  usage
-  exit 1
-fi
-wdir=$(mktemp -d tmp.svn2git.XXXXXXXXXX)
-trap "rm -rf $wdir" EXIT
+parse_opts () {
+  while [ $# -gt 0 ]; do
+    case "$1" in
+      -T) TRUNK="$2" ; shift 2 ;;
+      -b) BRANCHES="$2" ; shift 2 ;;
+      -t) TAGS="$2" ; shift 2 ;;
+      -o) DESTDIR="$2" ; shift 2 ;;
+      -1) PHASES="$PHASES 1" ; shift ;;
+      -2) PHASES="$PHASES 2" ; shift ;;
+      -3) PHASES="$PHASES 3" ; shift ;;
+      -4) PHASES="$PHASES 4" ; shift ;;
+      -5) PHASES="$PHASES 5" ; shift ;;
+      --) shift ; break ;;
+      -*) usage ; exit 1
+    esac
+  done
+  if [ -z "$PHASES" ] ; then
+    PHASES="1 2 3 4 5"
+  fi
+  if echo "$PHASES" | grep -q 1 ; then	# phase 1 requires URLs info
+    if [ -z "$TRUNK" -o -z "$BRANCHES" -o -z "$TAGS" -o -z "$DESTDIR" ] ; then
+      usage
+      exit 1
+    fi
+  fi
+}
+
+parse_opts "$@"
 
 info () {
   echo "**$1"
 }
 
-git_svninit () {
+git_svn_init () {
   info " initializing git repository"
-  (cd "$wdir"
+  test -d "$DESTDIR" || mkdir -p "$DESTDIR"
+  (cd "$DESTDIR"
   git-svn init --shared=world --no-metadata \
     -T "$TRUNK" -b "$BRANCHES" -t "$TAGS")
 }
 
-gitsvn_fetch () {
+git_svn_fetch () {
   info " checking in svn history into git"
-  (cd "$wdir"
+  (cd "$DESTDIR"
   git-svn fetch --fetch-all)
 }
 
 fix_branches () {
   info " converting tag \"branches\" to git tags"
-  (cd "$wdir"
+  (cd "$DESTDIR"
   tag_branches=$(git branch -r | awk '{ print $1 }' | grep "^tags/")
   for branch in $tag_branches ; do
     version=$(echo $branch | cut -f 2 -d /)
@@ -65,7 +89,7 @@
   done)
 
   info " \"localizing\" remote branches"
-  (cd "$wdir"
+  (cd "$DESTDIR"
   remote_branches=$(git branch -r | awk '{ print $1 }')
   for branch in $remote_branches ; do
     if [ "$branch" != "trunk" ] ; then
@@ -77,7 +101,7 @@
 
 rm_tarballs () {
   info " remove .tar.gz tarballs from git history"
-  (cd "$wdir"
+  (cd "$DESTDIR"
   git filter-branch --tree-filter "find . -name \"$TGZ_PATTERN\" -exec rm {} \;" HEAD
   git reset --hard
   rm -rf .git/refs/original/
@@ -86,26 +110,31 @@
 
 clean_repo () {
   info " generic git repository clean up + making it bare"
-  (cd $wdir
+  (cd $DESTDIR
   git config core.bare true
   git config --unset core.logallrefupdates
   git config receive.denynonfastforwards true
   git config --remove-section svn-remote.svn)
-  mv $wdir/.git/ "$DESTDIR"
+  wdir=$(mktemp -t -d tmp.svn2git.XXXXXXXXXX)
+  trap "rm -rf $wdir" EXIT  # better safe than sorry
+  mv $DESTDIR/.git/ $wdir/
+  rm -rf $DESTDIR/
+  mv $wdir/.git/ $DESTDIR
   rm -rf $wdir
   (cd "$DESTDIR"
   git gc --prune --aggressive)
 }
 
-
-[ -z "$NO_INIT" ] && git_svninit
-[ -z "$NO_FETCH" ] && gitsvn_fetch
-[ -z "$NO_BRANCHFIX" ] && fix_branches
-[ -z "$NO_TARBALLS" ] && rm_tarballs
-if [ -z "$NO_CLEAN" ] ; then
-  clean_repo
-else
-  mv $wdir "$DESTDIR"
-fi
+info " executing phases: $PHASES"
+info " (1-git_svn_init; 2-git_svn_fetch; 3-fix_branches; 4-rm_tarballs; 5-clean_repo)"
+for phase in $PHASES ; do
+  case $phase in
+    1) git_svn_init ;;
+    2) git_svn_fetch ;;
+    3) fix_branches ;;
+    4) rm_tarballs ;;
+    5) clean_repo ;;
+  esac
+done
 info " all done, see ya."
 

Modified: trunk/tools/svn2git/svn2git_pkg-ocaml-maint
URL: http://svn.debian.org/wsvn/trunk/tools/svn2git/svn2git_pkg-ocaml-maint?rev=5329&op=diff
==============================================================================
--- trunk/tools/svn2git/svn2git_pkg-ocaml-maint (original)
+++ trunk/tools/svn2git/svn2git_pkg-ocaml-maint Tue Mar 18 08:00:45 2008
@@ -13,26 +13,26 @@
 set -e
 
 usage () {
-  echo "Usage:   svn2git_pkg-ocaml-maint SOURCE_PACKAGE [DESTDIR]"
-  echo "         DESTDIR defaults to CURDIR/SOURCE_PACKAGE.git"
-  echo "Example: svn2git_pkg-ocaml-maint pcre-ocaml /some/where/pcre-ocaml.git"
+  echo "Usage:   svn2git_pkg-ocaml-maint SOURCE_PACKAGE [OPTIONS...]"
+  echo "Extra options are for svn2git_alioth"
+  echo "Example: svn2git_pkg-ocaml-maint pcre-ocaml"
 }
 
 PKG="$1"
-BASEURL="svn+ssh://svn.debian.org/svn/pkg-ocaml-maint"
+BASEURL="svn://svn.debian.org/svn/pkg-ocaml-maint"
 
 if [ -z "$PKG" ] ; then
   usage
   exit 1
 fi
-DESTDIR="$(pwd)/$PKG.git"
-if [ -n "$2" ] ; then
-  DESTDIR="$2"
-fi
+shift
 
 trunk="$BASEURL/trunk/packages/$PKG/trunk"
 branches="$BASEURL/trunk/packages/$PKG/branches"
 tags="$BASEURL/tags/packages/$PKG"
 
-svn2git_alioth "$trunk" "$branches" "$tags" "$DESTDIR"
+if ! echo "$@" | grep -q -- "-o" ; then
+  destflag="-o $(pwd)/$PKG.git"
+fi
+svn2git_alioth -T "$trunk" -b "$branches" -t "$tags" $destflag "$@"
 




More information about the Pkg-ocaml-maint-commits mailing list