You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Julian Foad <ju...@btopenworld.com> on 2003/09/30 17:00:05 UTC

"svn copy -rHEAD" copies the wrong version.

svn cp -rHEAD WC-FILE NEW-WC-FILE

does not contact the repository to determine "-rHEAD".  Instead it copies the version that currently exists in the WC.  The following script demonstrates it.

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

set -x -e
TEST_DIR=svn-copy-test
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 "File a." > a
svn add a
svn ci -m "One line in a." a
echo "a: line 2" >> a
svn ci -m "Second line."
svn up -r1 a

svn copy -rHEAD a b  ### copies the wrong version
# file b should have two lines but only has one
svn info b
svn cat b
svn cat -rHEAD a
]]]

I couldn't find an issue for this and I haven't filed one yet.

- Julian



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

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

Posted by Julian Foad <ju...@btopenworld.com>.
Ben Collins-Sussman wrote:
> Julian Foad <ju...@btopenworld.com> writes:
> 
>>>Or, if you want to take a harder road, 'svn cp -rX WC WC' could simply be
>>>converted (quietly, under the hood) to 'svn cp -rX URL WC'.
>>
>>This is what seems to be happening; just with a bug in it.  Either
>>that or some unintended functionality is operating and should be
>>blocked.
>>
>>I don't mind whether "-r" is allowed with a local path.  Anyone want
>>to choose?
> 
> Well, heck, if '-r' is already working in the WC->WC case most of the
> time, why don't you investigate the bug?  It sounds like we're almost
> there.  Maybe it's really trivial to make -rHEAD work correctly.

OK.  I'm busy for a few days but it's on my list of things to do after that.

> If it isn't trivial, then I'd suggest going the other route:  forbid
> -r completely in the WC->WC case, and make docs very clear about it.

Agreed.

- Julian


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

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

Posted by Julian Foad <ju...@btopenworld.com>.
Philip Martin wrote:
> Julian Foad <ju...@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

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

Posted by Julian Foad <ju...@btopenworld.com>.
Philip Martin wrote:
> Julian Foad <ju...@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.

Committed a regression test in r7351.  It contains commented-out lines for the additional revision-kind keywords that do not yet work.  (As they are all related, it made more sense this way than to have a separate XFail test containing the other cases.)

- Julian


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

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

Posted by Philip Martin <ph...@codematters.co.uk>.
Julian Foad <ju...@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.

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

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

Posted by Julian Foad <ju...@btopenworld.com>.
Ben Collins-Sussman wrote:
> Julian Foad <ju...@btopenworld.com> writes:
> 
>>>Or, if you want to take a harder road, 'svn cp -rX WC WC' could simply be
>>>converted (quietly, under the hood) to 'svn cp -rX URL WC'.
>>
>>This is what seems to be happening; just with a bug in it.  Either
>>that or some unintended functionality is operating and should be
>>blocked.
>>
>>I don't mind whether "-r" is allowed with a local path.  Anyone want
>>to choose?
> 
> Well, heck, if '-r' is already working in the WC->WC case most of the
> time, why don't you investigate the bug?  It sounds like we're almost
> there.  Maybe it's really trivial to make -rHEAD work correctly.

It was a very trivial bug that prevented this particular case from working.  Fixed "-rHEAD" in r7331.  Now, "-rHEAD" and "-rN" work but "-r" with any of the local keywords (BASE, COMMITTED, PREV) do not work.  But at least they fail with an error, rather than silently doing the wrong thing.

- Julian


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

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

Posted by Ben Collins-Sussman <su...@collab.net>.
Julian Foad <ju...@btopenworld.com> writes:

> > Or, if you want to take a harder road, 'svn cp -rX WC WC' could simply be
> > converted (quietly, under the hood) to 'svn cp -rX URL WC'.
> 
> This is what seems to be happening; just with a bug in it.  Either
> that or some unintended functionality is operating and should be
> blocked.
> 
> I don't mind whether "-r" is allowed with a local path.  Anyone want
> to choose?

Well, heck, if '-r' is already working in the WC->WC case most of the
time, why don't you investigate the bug?  It sounds like we're almost
there.  Maybe it's really trivial to make -rHEAD work correctly.

If it isn't trivial, then I'd suggest going the other route:  forbid
-r completely in the WC->WC case, and make docs very clear about it.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

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

Posted by Julian Foad <ju...@btopenworld.com>.
Ben Collins-Sussman wrote:
> kfogel@collab.net writes:
> 
>>Nice find!  Have no idea what causes this, but agree it is an
>>egregious bug...
>>
>>Julian Foad <ju...@btopenworld.com> writes:
>>
>>>svn cp -rHEAD WC-FILE NEW-WC-FILE
>>>
>>>does not contact the repository to determine "-rHEAD".  Instead it copies the version that currently exists in the WC.  The following script demonstrates it.
> 
> I think this is how we always meant/designed 'svn cp WC WC' to behave:
> it copies a chunk of WC to somewhere else in the WC, and schedules it
> all for addition with history.  IIRC, 'svn cp WC WC' is not supposed
> to take a --revision argument at *all*.

I can see how that would have been an acceptable design, but in fact the "--revision" argument is mostly supported.  It is only "-rHEAD" that fails; if I intead give "-r2" when the head revision is 2, it works.

The doc. string for svn_client_copy says that the "revision" argument is used if the source is a URL; this could be taken to imply that the revision is ignored if the patch is not a URL, but it is not explicit.

(The doc. string for svn_client_copy also says that a repository commit is performed if EITHER source or dest is a URL; surely this should be just if the destination is a URL.)


> To accomplish what you want above, we could simply tell people to use
> 'svn cp -rX URL WC', and then make 'svn cp WC WC' not accept
> --revision.   I think that's a perfectly fine resolution.

It could be.


> Or, if you want to take a harder road, 'svn cp -rX WC WC' could simply be
> converted (quietly, under the hood) to 'svn cp -rX URL WC'.  

This is what seems to be happening; just with a bug in it.  Either that or some unintended functionality is operating and should be blocked.

I don't mind whether "-r" is allowed with a local path.  Anyone want to choose?

- Julian


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

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

Posted by Ben Collins-Sussman <su...@collab.net>.
kfogel@collab.net writes:

> Nice find!  Have no idea what causes this, but agree it is an
> egregious bug...
> 
> Julian Foad <ju...@btopenworld.com> writes:
> > svn cp -rHEAD WC-FILE NEW-WC-FILE
> > 
> > does not contact the repository to determine "-rHEAD".  Instead it copies the version that currently exists in the WC.  The following script demonstrates it.

I think this is how we always meant/designed 'svn cp WC WC' to behave:
it copies a chunk of WC to somewhere else in the WC, and schedules it
all for addition with history.  IIRC, 'svn cp WC WC' is not supposed
to take a --revision argument at *all*.

To accomplish what you want above, we could simply tell people to use
'svn cp -rX URL WC', and then make 'svn cp WC WC' not accept
--revision.   I think that's a perfectly fine resolution.

Or, if you want to take a harder road, 'svn cp -rX WC WC' could simply be
converted (quietly, under the hood) to 'svn cp -rX URL WC'.  


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

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

Posted by kf...@collab.net.
Nice find!  Have no idea what causes this, but agree it is an
egregious bug...

Julian Foad <ju...@btopenworld.com> writes:
> svn cp -rHEAD WC-FILE NEW-WC-FILE
> 
> does not contact the repository to determine "-rHEAD".  Instead it copies the version that currently exists in the WC.  The following script demonstrates it.
> 
> [[[
> #!/bin/bash
> # Show bugs in "svn copy"
> 
> set -x -e
> TEST_DIR=svn-copy-test
> 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 "File a." > a
> svn add a
> svn ci -m "One line in a." a
> echo "a: line 2" >> a
> svn ci -m "Second line."
> svn up -r1 a
> 
> svn copy -rHEAD a b  ### copies the wrong version
> # file b should have two lines but only has one
> svn info b
> svn cat b
> svn cat -rHEAD a
> ]]]
> 
> I couldn't find an issue for this and I haven't filed one yet.
> 
> - Julian
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org