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

CRITICAL DEFECT: Commit of back-merge to old version fails after file replacement

From: Michael Schneider <m_schnei_at_gmx.de>
Date: 2006-04-24 23:44:10 CEST

Hi all!

I might have found a rather bad bug in subversion. In some situations it
is not possible to restore an old version of a directory. Normally one
does the following:

    1. Checkout fresh Trunk/HEAD and cd into the WC
    2. Do an inverse merge in the form of "svn merge -r HEAD:42 ."
    3. Commit changes

But in the following scenario, the third step fails badly, even leaving
the WC in a state unable to be reverted or updated (updating seems to
corrupt the WC).

    [Current Rev: 1]
    1. In the WC delete (svn del) a file x
    2. Commit changes and update
    [Current Rev: 2]
    3. Create and add (svn add) a file with same name x
    4. Commit changes and update
    [Current Rev: 3]
    5. Restore Rev 1 in WC: "svn merge 3:1 ."
    [svn status: [R]eplaced file x]
    6. Commit changes !!!FAILURE!!!

Now, trying to revert the WC seems first to succeed, but doing a "svn
status" shows no changes.. An "svn update" does also not work anymore,
but even changes the state of the WC.

I have tried out the scenario on two different machines (both
Cygwin/Windows), with different versions of subversion: 1.3.0 and 1.2.3,
finding the same result. To show you the problems I give you a commented
typescript of a real session, beginning with creating a new repository
and a newly imported directory.

Greetings,
Michael

=================== T Y P E S C R I P T ======================

### Here is my system and the version of subversion:

bash-3.00$ uname -a
CYGWIN_NT-5.1 huangshang 1.5.19(0.150/4/2) 2006-01-20 13:28 i686 Cygwin

bash-3.00$ svn --version
svn, version 1.2.3 (r15833)
    compiled Sep 13 2005, 22:45:22

### First I start by creating a fresh repos and directory
### with a file called "x", which I import into the new repos.
### After that I checkout the new directory and step into the WC.
### Notice that I use the environment variable "$SVN"
### for referencing the repos root.

bash-3.00$ export SVN=file:///tmp/svn

bash-3.00$ svnadmin create /tmp/svn

bash-3.00$ mkdir /tmp/prj-orig
bash-3.00$ cd /tmp/prj-orig
bash-3.00$ echo "old file" >x
bash-3.00$ svn import -m'* new project' . $SVN/prj
Adding x

Committed revision 1.

bash-3.00$ svn co $SVN/prj /tmp/prj
A /tmp/prj/x
Checked out revision 1.
bash-3.00$ cd /tmp/prj

### Now I delete x and commit changes:

bash-3.00$ svn st -vu
                 1 1 m_schnei x
                 1 1 m_schnei .
Status against revision: 1

bash-3.00$ svn del x
D x
bash-3.00$ svn ci -m '* deleted old x'
Deleting x

Committed revision 2.

bash-3.00$ svn up
At revision 2.

### Next, I create a _new_ file called "x" again,
### and commit changes:

bash-3.00$ svn st -vu
                 2 2 m_schnei .
Status against revision: 2

bash-3.00$ echo "new file" >x
bash-3.00$ svn add x
A x

bash-3.00$ svn ci -m'* added new x'
Adding x
Transmitting file data .
Committed revision 3.

bash-3.00$ svn up
At revision 3.

### Ok, let's restore the WC to revision 1:

bash-3.00$ svn st -uv
                 3 3 m_schnei x
                 3 3 m_schnei .
Status against revision: 3

bash-3.00$ svn merge -r HEAD:1 .
D x
A x

bash-3.00$ svn st -v
                 3 3 m_schnei .
R + - 1 m_schnei x

bash-3.00$ svn st -vu
svn: Working copy path 'x' does not exist in repository

### Hm, perhaps already the first warning sign:
### An error on "svn status" with update information.
### Without option "-u", the file x is correctly marked
### as being [R]eplaced. We can double check this:

bash-3.00$ cat x
old file

bash-3.00$ svn diff -r 1 x
bash-3.00$

### Great, no diffs to the old version of x.
### Now I try to commit changes:

bash-3.00$ svn ci -m '* try to restore directory to rev 1'
Replacing x
svn: Commit failed (details follow):
svn: Out of date: '/prj/x' in transaction '3-1'

### And BANG!!!
### Hopefully we can at least revert the directory to BASE?

bash-3.00$ svn revert -R .
Reverted 'x'

bash-3.00$ svn st -v
                 3 3 m_schnei .
    + - 1 m_schnei x

bash-3.00$ svn st -vu
svn: Working copy path 'x' does not exist in repository

### Well, no real news! No good news!
### What about a rescuing update?

bash-3.00$ svn up
svn: Working copy path 'x' does not exist in repository

### Oh dear...
### And now see what we have done:

bash-3.00$ svn st -v
! 3 3 m_schnei .
    + - 1 m_schnei x

### The system is about deleting my WC!
### It's time to surrender!!!

================ E N D O F T Y P E S C R I P T ===========

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Apr 25 12:21:29 2006

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.