Recovering a Deleted File from Subversion

Enviado por: Joel Sin Categoría No Comments »

This post is a copy of the original post found here.

Locating the File

To start, you will need a working copy, otherwise known as a checkout, of the project. That’s covered here. You can see the history of changes to a directory by cding into that directory and running svn log, but unfortunately that won’t tell you anything about deleted files, so you need to use the --verbose switch:

svn log --verbose

That will probably give you far more information than you really care for, so it’s useful to pipe the output to grep. Assuming that we’re trying to track down a file named Esquilax.php, it should be simple enough to use grep to search for Esquilax.php in the output from svn log.

In this situation, it can be well worth using grep‘s -A and -B options, which give a bit of leading and trailing context to the output from the search. Five lines or so is often enough to find the revision in which the file was deleted, but you may need to experiment.

If you’re fairly confident that the last thing you did with that file was delete it, which seems likely, a further useful tip is to use the -m or --max-count option. This option can be used to tell grep to stop searching after finding the first match (which will be the most recent commit involving your file). That should help filter out yet more noise. Here’s the amended command:

svn log --verbose | grep -m1 -A5 -B5 Esquilax.php

The output will look similar to the following:

Added validation to input from the search form
————————————————————————
r987 | simonh | 2009-06-19 10:17:17 +0100 (Fri, 19 Jun 2009) | 1 line
Changed paths:
D /path/to/application/Esquilax.php

Remove Esquilax.php, which we are no longer using
————————————————————————
r955 | barts | 2009-06-17 15:37:25 +0100 (Wed, 17 Jun 2009) | 1 line
Changed paths:

Somewhere in the middle of that output we can see the all-important line:

D /path/to/application/Esquilax.php

This shows our file being deleted. Just below it is my commit message, and above it the number of the revision in which the file was deleted, in this case r987.

Recovering the File

Once we have the relevant revision number, recovering the file becomes nice and easy. Still working with our checkout, perhaps the simplest approach is to cd into the directory in which the file last lived and perform a reverse-merge against the offending revision:

[simonh@vps03 ~]$ cd /path/to/application/code
[simonh@vps03 application]$ svn merge -r 987:986 .
--- Reverse-merging r987 into '.':
A    Esquilax.php
[simonh@vps03 application]$ svn status
A  +    Esquilax.php

What we’ve done there is say “undo the changes to this directory that were made between revision 986 and 987, and give me a copy of the results”. It’s not unfeasible that you’ll find other changes crop up, which you may have to revert manually. If anything, that’s an argument for trying to make commits atomic, as discussed here.

Any changes that do occur as a result of this merge are uncommitted and thus fully reversible. If you do choose to commit the recovered file back to the repository, that’s done just like any other commit. Happily, the file retains its history of changes, including those that were made prior to the deletion.

Pastel de Queso

Enviado por: Joel Sin Categoría 2 Comments »

PASTEL DE QUESO

cheese cakeIngredientes: (para 3 pasteles)

- 4 barras de 8 onzas de queso crema Philadelphia
- 36 onzas de crema agria (sour cream)
- 4 huevos
- 1 taza de azúcar (8 onzas)
- 1 cucharada de vainilla (o al gusto)
- 3 platos preparados para pastel de queso (ya se venden listos, o en su defecto, se pueden preparer moliendo galleta ricanela o graham cookie) Read the rest of this entry »

De regreso en L.A.

Enviado por: Joel Sin Categoría No Comments »

Hola,

ZacatecasYa volví de mis vacaciones. Fueron 2 semanas nada más (jejeje). Les cuento que me la pase super bien. Me di gusto a comer de todas las cosas que me gustan de mi tierra o que preparan en mi casa. Entre esta lista están menudo, birria, pollo asado estilo sinaloa, huachinango zarandeado, dulces de camote y de calabaza, gorditas estilo zacatecano, tortas ahogadas en Guadalajara y carne en su jugo del restaurant Carnes Garibaldi, tambien en Guadalajara. Read the rest of this entry »

Vacaciones 2008

Enviado por: Joel Sin Categoría No Comments »

Bueno, pues ya pasó un año desde mis últimas vacaciones y de nuevo me voy a mi tierra: Juchipila. Estaré por alla dos semanas. Se que se pasarán muy rápido, siempre me pasa lo mismo, se van como agua entre los dedos. Read the rest of this entry »

Vuelve a la vida

Enviado por: Joel Sin Categoría No Comments »

ERDMe volví a acordar que tengo blog. Ya casi se cumple un año que lo abrí y solo al principio me dio por escribir, y fue casi exclusivamente sobre cosas que me llamaban la atención en los noticieros. Trataré de escribir un poco más sobre las cosas que me interesan y las cosas que me ocurren. Aunque probablemente nadie lea mis escritos, no me importa, el escribirlos me ayudará a sentirme mejor. Read the rest of this entry »

Colombianismos

Enviado por: Joel Sin Categoría 3 Comments »

ColombiaAmigos , estoy compilando el colo-diccionario, donde se incluyen palabras tipicas de Colombia. Si sabes alguna otra enviala..

1. mompirri: amigo del alma
2. berraquera: condición de excelencia
3. fresco: frase que incita a tranquilizarse, a calmarse Read the rest of this entry »

Ya era hora

Enviado por: Joel Sin Categoría No Comments »

El puto obispoMe enteré viendo el noticiero de López Dóriga que los diputados han hecho ajustes a las leyes con el fin de que en el futuro sean castigados con más severidad los curas pedófilos. Vaya!! Por fin se les ocurrió algo sensato. Read the rest of this entry »

Pinche Bancomer

Enviado por: Joel Sin Categoría 12 Comments »

Bancomer ReprobadaA como me saco coraje el pu.. banco Bancomer. Según eso tengo acceso a mi cuenta por internet, pero no puedo accesarla!, me da un maldito error: EL USUARIO TIENE UN ESTATUS DIFERENTE DE PENDIENTE DE ACTIVACION -CNE0048- CNE0048 Read the rest of this entry »

Ya volvi!

Enviado por: Joel Sin Categoría 1 Comment »

Ya estuvo! Las 3 semanas se fueron como agua entre los dedos. Luego escribo algo.

Ya casi me voy!!!

Enviado por: Joel Sin Categoría No Comments »

Conti en dia de fiesta.Al fondo mi casaHoy es miércoles ya. Terminando esta semana me voy de vacaciones!!! ji ji ji ji …Tres semanas… Las voy a pasar en mi rancho, Contitlán. Van a ser tres semanas de pura weba, de desvelarse hasta que me de mi gana, levantarse tarde, irse a almorzar birria al mercado de Juchipila, ir a pachangueársela en las fiestas del pueblo.. en fin, pura vida, como dicen los costarricences. Read the rest of this entry »