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

Re: "svn copy -rHEAD" copies the wrong version.

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2003-10-07 23:39:52 CEST

Philip Martin wrote:
> Julian Foad <julianfoad@btopenworld.com> writes:
>
>>It was a very trivial bug that prevented this particular case from
>>working. Fixed "-rHEAD" in r7331.
>
> Good stuff, but I'd encourage you to write regression tests for things
> that obviously aren't covered by the current tests.

It's on the way :-)

As I mentioned in the same e-mail, I found other, related bugs, namely that "-r" doesn't work with BASE, COMMITTED or PREV with a local source. What I didn't say is that I have written a reproduction script (below) which I intend to convert into regression tests, and it covers -rHEAD as well as the other cases.

I thought I'd get that simple fix in first because the others are significantly more difficult.

Thanks for being on the ball and advocating the Right Way.

- Julian

[[[
#!/bin/bash
# Show bugs in "svn copy"

set -e
TEST_DIR=svn-copy-test
if [ -f $TEST_DIR/wc/a ]; then
  cd $TEST_DIR/wc
  svn revert a[0-9]*
  rm a[0-9]*
else
  mkdir $TEST_DIR
  cd $TEST_DIR
  svnadmin create repos
  REPOS=file://`pwd`/repos
  svn co $REPOS wc
  cd wc

  # Now we have a repository and a WC, start playing in the WC.
  echo "r1" > r1
  echo "r2" > r2
  echo "rWC" > rWC
  cp r1 a
  svn add a
  svn ci -m ""
  cp r2 a
  svn ci -m ""
fi
svn up -r1 a
cp rWC a

# cp_from_rev FILE EXPECTED_REV
# Check that the file was copied from the expected revision.
cp_from_rev () {
  R=`svn info $1 | grep "Copied From Rev: " | sed "s/Copied From Rev: //"`
  if [ "$R" != "$2" ]; then
    echo "ERROR: '$1' was copied from revision $R; should be $2."
  fi
}

# cp_test DST FROM_REV_EXPECTED CP_ARGS
cp_test () {
  DST=$1
  FROM_REV=$2
  shift 2
  echo "TEST $DST: svn copy $@ a $DST"
  svn copy "$@" a $DST &&
  cp_from_rev $DST $FROM_REV
}

set +e
cp_test a0 1 &&
diff -q rWC a0

cp_test a1 2 -rHEAD &&
diff -q r2 a1

cp_test a2 1 -rBASE &&
diff -q r1 a2

cp_test a3 1 -rCOMMITTED &&
diff -q r1 a3

cp_test a4 0 -rPREV # should fail: file did not exist at r0

rm a &&
svn up a > /dev/null &&
cp_test a5 1 -rPREV &&
diff -q r1 a5
]]]

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Oct 7 23:39:12 2003

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

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