#!/bin/sh

# Reproduction recipe for a problem with delete (also move)
# and two consecutive merges from trunk into a branch working copy

DIR=`pwd`
URL=file://$DIR/repos

set -e
set -x

rm -rf repos trunk-wc branch-wc

svnadmin create repos

svn mkdir $URL/trunk $URL/branches -m "dirs"

# Put a file on trunk
svn co $URL/trunk trunk-wc
echo a > trunk-wc/a
svn add trunk-wc/a
svn ci trunk-wc -m "added a"

# Create branch
svn cp $URL/trunk $URL/branches/branch -m "creating branch"
svn co $URL/branches/branch branch-wc

# Delete file on trunk
svn rm trunk-wc/a
svn ci trunk-wc -m "removed a"
# Moving file on trunk instead of deleting will yield the same end result
#svn mv trunk-wc/a trunk-wc/b
#svn ci trunk-wc -m "moved a to b"

# In branch working copy, merge from trunk
(cd branch-wc && svn merge $URL/trunk)

# In branch working copy, merge from trunk again
svn co $URL/branches/branch branch-wc
(cd branch-wc && svn merge $URL/trunk)

# Should result in:
# subversion/libsvn_repos/reporter.c:778: (apr_err=160013)
# svn: Working copy path 'a' does not exist in repository

