abusalimov

svn-propcopy.sh

Jul 12th, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.99 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Copies SVN properties from one directory tree to another. Trees may be
  4. # versioned by different repos. The original tree must be a fresh working copy.
  5. # The target must have the identical structure as the source.
  6.  
  7. err_usage() { echo "Usage: $0 FROM_DIR TO_DIR" ; err "$1"; }
  8. err()       { echo "$1" ; exit 1; }
  9.  
  10. FROM_DIR=$2; [ -d "$FROM_DIR" ] || err_usage "'$FROM_DIR': directory not found"
  11. TO_DIR=$2;   [ -d "$TO_DIR" ]   || err_usage "'$TO_DIR': directory not found"
  12.  
  13. cd "$FROM_DIR"
  14. FILES=`svn -v status | awk '{print $4}'`
  15. cd -
  16.  
  17. for FILE in $FILES
  18. do
  19.     FROM="$FROM_DIR/$FILE" ;  [ -e "$FROM" ] || err "'$FROM': no such file or directory"
  20.     TO="$TO_DIR/$FILE" ;      [ -e "$TO" ]   || err "'$TO': no such file or directory"
  21.     for PROP in `svn proplist $FROM | tail -n +2`
  22.     do
  23.         VALUEX=`svn propget "$PROP" "$FROM"; echo -n x`
  24.         echo "         '$PROP'        '$TO'  =  '${VALUEX%x}'"
  25.         svn propset "$PROP" "${VALUEX%x}" "$TO" || err "'$TO': propset failed"
  26.         echo
  27.     done
  28. done
Advertisement
Add Comment
Please, Sign In to add comment