Richard Smith
Richard Smith

Reputation: 14158

How to svn annotate / blame a deleted file?

Setup: File foo/bar in my repository got copied (with modifications) to foo/baz, and the original was deleted, in r123. This copy was performed manually, not with svn cp. Many revisions have passed since.

I now want to see where some of the lines in foo/baz came from. After tracking back to foo/bar, I try this command:

$ svn annotate foo/bar -r 122
svn: warning: W155010: The node '/path/to/checkout/foo/bar' was not found.
svn: E200009: Could not perform blame on all targets because some targets don't exist

... but it doesn't work because the file doesn't exist any more!

Question: How do I svn annotate a file that has been deleted?

Upvotes: 5

Views: 1337

Answers (2)

Richard Smith
Richard Smith

Reputation: 14158

After identifying the last revision at which the file existed, you need to use a different form of the svn annotate command and look at the history on the SVN server. First, run svn info to get the server URL for the current directory:

$ svn info
[...]
URL: https://[email protected]/svn/project/subproject/trunk
Relative URL: ^/subproject/trunk
[...]

The remote revision can be named as url/path@revision, as follows:

$ svn annotate https://[email protected]/svn/project/subproject/trunk/foo/bar@122

or

$ svn annotate ^/subproject/trunk/foo/bar@122

Edit: Thanks to Patryk Obara for pointing out that the Relative URL can be used instead.

Upvotes: 2

Patryk Obara
Patryk Obara

Reputation: 1847

Richard's answer is ok, but you don't need to know full svn url - ^ character always expands to project url:

svn annotate ^/<branch path>/<file path>@rev

e.g.

svn annotate ^/trunk/README.md@123

Upvotes: 2

Related Questions