jpints14
jpints14

Reputation: 1371

How to tell what revision a folder was deleted in?

I just joined an organization, and the current repository revision number is let's say 10000. I know that at around revision 2000, a folder was in the repository. What would be the best way to determine when the last revision was that contained the folder?

I added the folder back in, and now let's say I'm at revision 10001.

If I do:

svn log -q -v folder1\folder2\missingFolder\ 

I only get that the 'missingFolder' was added in revision 10001. If I run that command from revision 10000, it just says that 'missingFolder' does not exist.

Upvotes: 2

Views: 80

Answers (2)

David W.
David W.

Reputation: 107090

Even though the two missing folders have the same name and are in the same repository directory, Subversion thinks of them as two completely separate items. If you do svn log missingFolder, you will get the information on the one you just added which isn't the same as the one you previously deleted.

Let's take this one at a time:

How to find when a file or folder was deleted

$ svn log -v

That's pretty much it, then you search for the name of the folder and the D representing when it was deleted.

The listing can be rather long, but it doesn't take all that long to run. I will pipe this through less:

$ svn log -v -q | less

Then, I can do /D *missingFolder and find the line where I see the delete. A few lines up will be the revision number where it was deleted.

$ svn log -v $REPO/folder/folder 
...
... 
[on and on}

r1234 | ....
D    folder/folder/missingFolder

deleted missingFolder
------
...
...

We can see this folder was deleted in revision 1234. This means it existed in revision 1233. That's important to remember.

You can do a svn log on the parent folder which will make the output a bit shorter.

How to correctly add back in a previously existing folder or file:

If you wan the history of this folder or file to go all the way back before it was deleted, you need to copy the item in the Subversion repository before it was deleted. Remember that this folder was deleted in revision 1234. This means it exists in revision 1233:

$ svn cp -r1233 $REPO/folder/folder/missingFolder@1233 .

This is now the same folder in your current revision that was previously deleted in revision 1233. Now, doing a log will show me the entire history of missingFolder. Unfortunately, it will show you when the file or folder was added back into the repository, but it doesn't say when the file or folder was deleted. For that information, you have to take the svn log of the parent folder.

Upvotes: 1

kostix
kostix

Reputation: 55573

To me, it looks just about correct.

But I would instead do:

svn log -q -v -r10000:2000

and grep the output for

D folder1\folder2\missingFolder

or, iff you're sure folder1\folder2 were there forever you can narrow the search down a bit and do

svn log -q -v -r10000:2000 folder1\folder2

looking for

D missingFolder

I reckon your initial approach does not quite work simply because when Subversion digs through the revision log and finds a folder got added it (correctly) assumes there's no point in digging deeper as the folder did not exist in prior commits, so the searching stops.

Note that I'm also limiting the range of revisions to scan using the -r command-line option.

Upvotes: 1

Related Questions