Recovering from subversion corruption or accidentally deleted folders PDF Print E-mail
Written by Paul Whipp   
Thursday, 05 January 2012 10:43

Subversion is great and very handy but it can be a real pain on the rare occassions that it goes wrong.

Lets say you have accidentally deleted a folder structure (including the .svn folders) or a .svn entry has become corrupt.

How do you get back to work?

Lets demonstrate this step by step:

create a test project to demonstrate and recover using your subversion server. I use springloops and created a project called test there.

Create some simple test content for the project:

~/tmp $ cd /tmp
/tmp $ mkdir test
/tmp $ mkdir -p test/a/b/c
/tmp $ touch test/a/f1.txt
/tmp $ touch test/a/b/f2.txt
/tmp $ touch test/a/b/c/f3.txt
/tmp $ ls -1R test
test:
a

test/a:
b
f1.txt

test/a/b:
c
f2.txt

test/a/b/c:
f3.txt

Import it into our project (substitute your own repository URL):

/tmp $ cd test
/tmp/test $ svn import https://pwc.slsapp.com/source/test-242
Adding         a
Adding         a/b
Adding         a/b/c
Adding         a/b/c/f3.txt
Adding         a/b/f2.txt
Adding         a/f1.txt

Ditch the source and create a working copy to use:

/tmp $ rm -r test
/tmp $ svn checkout https://pwc.slsapp.com/source/test-242 test
A    test/a
A    test/a/b
A    test/a/b/c
A    test/a/b/c/f3.txt
A    test/a/b/f2.txt
A    test/a/f1.txt
Checked out revision 1.

"Accidentally" remove test/a/b

/tmp $ sudo rm -r test/a/b

Without sudo here you'll get write protect warnings but you can say yes and they'll get deleted so sudo just saves a bit of typing.

Now our working copy is borked.

/tmp $ cd test
/tmp/test $ svn status
!       a/b

Update will bring it back:

/tmp/test $ svn update .
A    a/b
A    a/b/c
A    a/b/c/f3.txt
A    a/b/f2.txt
Updated to revision 1.
/tmp/test $ svn status
/tmp/test $ 

You can apply this repair anywhere within your project structure to minimise long downloads of files you already have.

If your problem is a corrupt .svn delete the relevant folder using rm as above and apply this repair.

If you have changed files you need to subsequently add back to subversion, copy them somewhere and then copy them back over the repaired files once you've carried out the repair.

Make sure you do not copy back any .svn folders if copying a structure. This is best sorted when you make your file copy:

/tmp/my_backup $ find . -name ".svn" -type d -exec sudo rm -r {} \;

If the commands above don't make sense, stop working in Windows and get yourself a decent (and free!) development environment.


Trackback(0)
Comments (1)Add Comment
0
louis vuitton epi leather wallet
written by louis vuitton suhali leather, February 18, 2012
May buy low cost replacement carriers with on the net cheap louis vuitton men bags below wholesale retail store! Some sort of louis vuitton monogram canvas wallet is completed having treatment method and may overall look accurately this also for the reason that real.

Write comment

security code
Write the displayed characters


busy
Last Updated on Thursday, 05 January 2012 10:48
 
We have 46 guests online
Paul Whipp Consulting (BN 207 530 56) is owned by and operated for The Whipp Family Trust (ABN 32 507 522 641).