#!/bin/bash # ## # Author: James Bottomley ## # Tool to backport from bitkeeper repositories ## # $Id: bkexport,v 1.1 2002/03/16 15:50:50 jejb Exp $ ## usage() { echo "Usage: $0 {-C |-R } "; exit 1; } tmp=/tmp/$$ tmpdiff=$tmp.diff tmpfile=$tmp.file if [ $# -ne 3 ]; then usage; fi case $1 in -C) changeset=$2 dir=$3;; -R) changeset=`bk changes -d':REV:\n' -L $2|sort -n` dir=$3;; *) usage;; esac if [ ! -d $dir ]; then echo "DIRECTORY $dir MUST EXIST" 2>&1 exit 1; fi # get the changes for c in $changeset; do echo "Applying ChangeSet $c" bk export -tpatch -du -r$c > $tmpdiff pushd $dir > /dev/null bk get -e `awk '/^diff/{print substr($3,3)}' < $tmpdiff` patch -p1 < $tmpdiff popd > /dev/null bk changes -v -n -d':GFILE: :REV:' -r$c | { while read file rev; do if [ "$file" = "ChangeSet" ]; then continue fi echo "Applying change log for $file revision $rev" bk prs -h -d'$each(:C:){(:C:)\n}' -r$rev $file > $tmpfile pushd $dir > /dev/null bk ci -y"`cat $tmpfile`" $file popd > /dev/null done bk prs -h -d'$each(:C:){(:C:)\n}' -r$c ChangeSet > $tmpfile pushd $dir > /dev/null echo "Commiting ChangeSet $c" bk commit -d -Y$tmpfile popd > /dev/null } done rm -f $tmpdiff $tmpfile