#!/bin/sh # TO USE THIS SCRIPT # ------------------ # # check out the monotone release to be used to the trunk - check out a # tagged release, or, for testing, a specific revision, using co and # the --revision option, use a new direcctory name (i.e. don't attempt # to check out to an existing directory.) # # For example: # # monotone --db=your.db --revision=t:OpenSlug-2.3-beta co monotone # # monotone will tell you which revision it checked out - make sure it # got it right! # # 'monotone' is a directory in the trunk/openslug SVN tree. # # Having done this simply run: # # copyclone monotone openembedded # # Take note of any warnings. If a file has been converted to a directory or # vice versa you are in untested territory - it should work, but the script # will ask for confirmation in each case. # # Use "-c" as the first argument to check the result (-c will just output the # svn etc commands to be used) c= test "$1" = -c && { c=echo shift } # from="$1" to="$2" test -d "$from"/MT -a -d "$from"/packages || { echo "copyclone: $from needs to be a monotone working directory containing the correct files!" >&2 exit 1 } test -d "$to"/.svn -a -d "$to"/packages || { echo "copyclone: $to needs to be the svn directory with the current (SVN) files!" >&2 exit 1 } echo -n "clone $from -> $to [N/y]: " >/dev/tty read ans # find all the non-bitkeeper files in bk clone "$1" findbkf() { where="$1" shift ( cd "$where" find . \( -name MT -type d -prune \) -o \ \( -name SCCS -type d -prune \) -o \ \( "$@" -print \) ) } # #findsvnf # find all the non-svn files in svn tree "$1" findsvnf() { where="$1" shift ( cd "$where" find . \( -name .svn -type d -prune \) -o \ \( "$@" -print \) ) } # #svn_mkdir file #svn_mkfile file # makes a directory in $to or copies a file from $from to $to svn_mkdir() { if test -n "$c" then echo mkdir "$to/$1" else if mkdir "$to/$1" then svn add "$to/$1" else echo "$to/$1: mkdir failed, not added" >&2 fi fi } svn_mkfile() { if test -n "$c" then echo add "$to/$1" else if cp -p "$from/$1" "$to/$1" then svn add "$to/$1" else echo "$to/$1: copy failed, not added" >&2 fi fi } svn_cpfile() { if test -n "$c" then echo update "$to/$1" else rm -rf "$to/$1" if cp -p "$from/$1" "$to/$1" then : else echo "$to/$1: copy failed, not updated (or damaged!)" >&2 fi fi } # # Find all the differences { echo "/FROM/" findbkf "$from" echo "/TO/" findsvnf "$to" } | awk 'BEGIN{ op="n" } $1=="/FROM/"{ op="f"; next } $1=="/TO/"{ op="t"; next } op=="f"{ from[$0] = 1 } op=="t"{ to[$0] = 1 } END{ for (f in from) { if (to[f] == 1) print "diff", f else print "add", f | "LCALL=C sort -k 2" } for (f in to) { if (from[f] != 1) print "remove", f | "LCALL=C sort -r -k 2" } }' | while read op file do case "$op" in add) if test -d "$from/$file" then svn_mkdir "$file" else svn_mkfile "$file" fi;; remove) if test -n "$c" then # the directory deletes are just scheduled, # so they remain in the tree until commited if test -d "$to/$file" then files="$(findsvnf "$to/$file" ! -type d)" if test -n "$files" then echo "WARNING: $to/$file: directory not empty!" >&2 fi else echo delete "$to/$file" fi else svn delete "$to/$file" fi;; diff) if test -d "$from/$file" then test -d "$to/$file" || { echo -n "FILE $to/$file is now DIRECTORY $from/$file, OK[N/y]" >/dev/tty read ans /dev/tty if test -n "$c" then echo "FILE->DIR $to/$file" else svn delete "$to/$file" rm -f "$to/$file" svn_mkdir "$file" fi } } elif test -d "$to/$file" then echo -n "DIRECTORY $to/$file is now FILE $from/$file, OK[N/y]" >/dev/tty read ans /dev/tty if test -n "$c" then echo "DIR->FILE $to/$file" else svn delete "$to/$file" svn_cpfile "$file" fi } elif cmp -s "$from/$file" "$to/$file" then : # echo "UNCHANGED: $file" else svn_cpfile "$file" fi;; *) echo "INTERNAL ERROR $op" >&2 exit 1;; esac done