[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: rename overwrites code: this a reasonable interim solution?

From: Eli Carter <eli.carter_at_commprove.com>
Date: 2007-04-12 21:43:04 CEST

On Wednesday 11 April 2007, lsuvkne@onemodel.org wrote:
> >>> Eli Carter <eli.carter@commprove.com> 04/11/07 1:25 pm >>>
> >What about wrapping svn merge in a script to check for the problematic
> >case and fixing up the problem?
> >Eli
>
>
> Thanks for the suggestion. Do you mean something doing like this?:
[snip]

This should detect the existance of a problem, but does not automate the
correction.

This detects the merge of deletions where the file being deleted has changed.
This is a little more general than the rename case, since you may have a file
that is just deleted on the branch, but modified on trunk... and it's not
clear you should still delete the file in that case.

So without further ado, a bash function (watch out for line wrapping):

function advanced_merge(){
    branch="$1"
    trunk=`svn info | grep ^URL: | sed 's/^URL: //'`
    revisions=`svn log --xml --stop-on-copy $branch | grep -A
1 "^<logentry$" | grep revision | sed 's/.*"\([0-9]\+\)".*/\1/g'`
    newest=`echo "$revisions" | head -1`
    oldest=`echo "$revisions" | tail -1`
    echo "advanced_merge: $revisions"
    mergeoutput=`svn merge -r$oldest:$newest $branch .`
    echo "$mergeoutput"
    conflict_count=`echo "$mergeoutput" | grep -e "^C" | wc -l`
    # For all deleted files, verify that the version deleted on the branch is
    # the same version as what is being merged into on trunk. If not, we have
    # a conflict.
    deletedfiles=`echo "$mergeoutput" | grep ^D | cut -c6-`
    for f in $deletedfiles; do
        branchrev=`svn info $branch/$f@$oldest | grep "Last Changed Rev"`
        trunkrev=`svn info $trunk/$f | grep "Last Changed Rev"`
        if [ "$branchrev" != "$trunkrev" ]; then
            echo "Conflict on \"$f\", changes lost."
            conflict_count=`expr $conflict_count + 1`
        fi
    done
    return $conflict_count
}

Usage:
svn switch your working copy to trunk (or whatever you are merging into), and
do advanced_merge <branch_url>

I have not tested this thoroughly... but hope this will get discussion moving
on a client-side work-around.

Comments? In particular, does this catch the cases we're interested in? Does
it give false positives?

Eli

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu Apr 12 21:43:59 2007

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.