Re: Dev - Request to Use a Distributed Version Control System When Code Base Changes

Posted by Adam Heath-3 on
URL: http://ofbiz.116.s1.nabble.com/Dev-Request-to-Use-a-Distributed-Version-Control-System-When-Code-Base-Changes-tp167349p167352.html

On Thu, 23 Mar 2006, Vinay Agarwal wrote:

> Adam,
>
> Would you like to share your procedure to create and maintain local
> repositories with SVK? I have tried and failed.

The following script and instructions are based on several scripts we use
locally.  I created these scripts after much trial and error.  Most important
in this, was the ability to recreate everything from scratch, as I learned
each new step.

==
#!/bin/bash
# bash required, as we use local, which isn't posix
depot="externals"
internal_svn_host="svn-internal"
internal_username="[hidden email]"

die() {
        local result
        result=$1
        shift
        echo "$@" 1>&2
        exit $result
}

create_internal_job() {
        local client job
        client="$1"
        job="$2"
        shift 2 || die 1 "create_internal_job: incorrect parameter count"
        (
                cat << _VARS_
client="$client"
job="$job"
_VARS_
                cat << "_SCRIPT_"
set -x
rm -rf "/svn/$client-$job"
svnadmin create --fs-type bdb "/svn/$client-$job"
chmod -v g+ws $(find "/svn/$client-$job" -type d)
chmod -v g+w $(find "/svn/$client-$job" -type f)
ln -sf "../../.conf/passwd" "/svn/$client-$job/conf/passwd"
perl -pni.bak \
        -e 's/^\s*#.*\[general\].*/[general]/;' \
        -e 's/^\s*#\s*auth-access.*/auth-access = write/;' \
        -e 's/^\s*#\s*password-db.*/password-db = passwd/' \
        "/svn/$client-$job/conf/svnserve.conf"
_SCRIPT_
        ) | ssh "$internal_svn_host" /bin/sh -s
        rm -rf /tmp/svk.tmp
        svn co "svn://$internal_svn_host/$client-$job" /tmp/svk.tmp
        cd /tmp/svk.tmp
        mkdir trunk
        cd trunk
        mkdir ofbiz etc var components
        cd components
        mkdir "$job"
        cd "$job"
        mkdir config data entitydef lib script servicedef src webapp widget
        cd webapp
        mkdir "$job"
        cd "$job"
        mkdir WEB-INF
        cd ../../../../..
        svn add trunk
        svn ci --username "$username" -m "Initial paths"
        rm -rf /tmp/svk.tmp
        svk mirror "/$depot/repos/$client-$job" \
                "svn://$internal_svn_host/$client-$job/trunk"
        svk sync "/$depot/repos/$client-$job"
        svk cp -p -m "Branching for local development." \
                "/$depot/repos/$client-$job" \
                "/$depot/jobs/$client-$job"
        time svk smerge -BIl "/$depot/projects/ofbiz/trunk" \
                "/$depot/jobs/$client-$job/ofbiz"
        time svk smerge -Il "/$depot/jobs/$client-$job" \
                "/$depot/repos/$client-$job"
}

svk_init() {
        rm -rf "$HOME/.svk/$depot"
        svk depotmap "/$depot" "$HOME/.svk/$depot"
        rm -rf /tmp/svk.tmp
        svk co "/$depot/" /tmp/svk.tmp
        cd /tmp/svk.tmp
        mkdir -p projects/ofbiz repos
        cd projects/ofbiz
        mkdir features fixes branches tags
        cd ../..
        svk add *
        svk ci -m "Initial directories"
        svk mkdir /ofbiz/mirror
        svk mirror http://svn.ofbiz.org/svn/ofbiz \
                "/$depot/repos/ofbiz"
        # This next command will take a *long* time, while it
        # copies the entire ofbiz svn repository.
        svk sync "/$depot/repos/ofbiz"
        svk cp -m "Branching for local development." \
                "/$depot/repos/ofbiz" \
                "/$depot/projects/ofbiz/current"
        svk cp -m "Branching for internal trunk merging." \
                "/$depot/projects/ofbiz/current" \
                "/$depot/projects/ofbiz/trunk"
        svk cp -m "All fixes" \
                "/$depot/projects/ofbiz/current" \
                "/$depot/projects/ofbiz/fixes/all"
}

# you can pass -m "checkin message" to this as well.
create_new_fix() {
        local project fix
        project="$1"
        fix="$2"
        shift 2 || die 1 "create_new_fix: incorrect parameter count"
        svk cp -p "$@" \
                "/$depot/projects/$project/current" \
                "/$depot/projects/$project/fixes/$fix"
}

# you can pass -m "checkin message" to this as well.
create_new_feature() {
        local project feature
        project="$1"
        feature="$2"
        shift 2 || die 1 "create_new_feature: incorrect parameter count"
        svk cp -p "$@" \
                "/$depot/projects/$project/fixes/all" \
                "/$depot/projects/$project/features/$feature"
}

# you can pass -m "checkin message" to this as well.
merge_fix() {
        local project fix
        project="$1"
        fix="$2"
        shift 2 || die 1 "merge_fix: incorrect parameter count"
        svk smerge -Il "$@" \
                "/$depot/projects/$project/fixes/$fix" \
                "/$depot/projects/$project/fixes/all"
        svk smerge -Il "$@" \
                "/$depot/projects/$project/fixes/all" \
                "/$depot/projects/$project/trunk"
}

# you can pass -m "checkin message" to this as well.
merge_feature() {
        local project feature
        project="$1"
        feature="$2"
        shift 2 || die 1 "create_new_feature: incorrect parameter count"
        svk smerge -Il "$@" \
                "/$depot/projects/$project/features/$feature" \
                "/$depot/projects/$project/trunk"
}

==
. path/to/file/above
svk_init    # do this first time only, or when you want to start over
create_fix ofbiz fix-npe-in-random-code
svk co \
        "/$depot/projects/ofbiz/fixes/fix-npe-in-random-code" \
        "$HOME/work/ofbiz_fix_fix-npe-in-random-code"
cd "$HOME/work/ofbiz_fix_fix-npe-in-random-code"
# change files, fix one(and only one) bug, do several checkins if required.
merge_fix ofbiz fix-npe-in-random-code
# repeat above for features, too.
create_internal_job microsoft website
svk co \
        "svn://$internal_svn_host/microsoft-website/trunk" \
        "$HOME/work/microsoft-website"
cd "$HOME/work/microsoft-website"
# do work, do checkins, which get committed immediately back to svn-internal.
# to fetch new commits from other users who have committed to svn-internal, do
# either:
# svk sync "/$depot/repos/$client-$job"
# svk up "$HOME/work/microsoft-website"
# or
# svk pull "$HOME/work/microsoft-website"

# merge all fixes and whatever features into client-job
svk smerge -Il \
        "/$depot/projects/ofbiz/trunk" \
        "/$depot/repos/microsoft-website"
==
 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev