#!/bin/sh
# [Issue 1751] svn switch on non-recursive checked-out-wc breaks

set -x -e
mkdir svn-switch-N-test
cd svn-switch-N-test

# Make a repository and a WC, "wc1"
svnadmin create repos
REPOS=file://`pwd`/repos
svn co $REPOS wc1

# Make and commit a basic tree in "wc1"
(
  cd wc1
  mkdir branch
  mkdir trunk; touch trunk/readme
  mkdir trunk/dir1; touch trunk/dir1/file1  # the bugs appear even without this
  svn add trunk branch
  svn ci -m ""
)

# Check out a non-recursive WC, "wc2"
svn co -N $REPOS/trunk wc2

# Make a branch, and add a file "aaa", in "wc1" and repository
svn cp -m "" $REPOS/trunk $REPOS/branch/version1
svn up wc1
touch wc1/branch/version1/aaa
svn add wc1/branch/version1/aaa
svn ci -m "" wc1

# Try to switch "wc2" to the branch (non-recursively)
svn switch -N $REPOS/branch/version1 wc2

# Check the result
svn ls -vR $REPOS  # repository is OK
svn info wc2  # OK
svn info wc2/readme  # not switched
svn info wc2/aaa  # bad URL

# Try to switch the "wc2" branch to itself
# svn switch -N $REPOS/branch/version1 wc2  # fails on "aaa" due to bad URL
