I have a large number of files that used to be named with a UUID, for example "58eb386e-305d-11e0-a2d5-33c8867dedc0.html". Then they all got moved to other filenames, often as part of massive wholesale moves. I'd like to go back through each file's history, find the UUID, and then append it to the file. I'd like to do this on the command line if I can.

I can't find a simple way to generate a list of the names of a single file throughout its individual history. Neither svn log nor svn log --xml print the filename in their output. If I add a -v flag, I get the filenames of everything that changed in every revision that affected the file, which isn't what I want.

What I'd like is something that more-or-less looks like this:

> svn magic-command foo.html

r312 ...
   A foo.html
   D bar.html
r256 ...
   A bar.html
   D baz.html
r234 ...
   A baz.html
   D 58eb386e-305d-11e0-a2d5-33c8867dedc0.html
r123 ...
   A 58eb386e-305d-11e0-a2d5-33c8867dedc0.html <<< BINGO!!!
   D draft.html
r96 ...
   A draft.html

Any suggestions? Thanks!

  • SVN doesn't track file renames. It's just a file being added and another being removed, their contents matching only incidentally. Some utilities are capable of adding appropriate comments/metadata though, which you might be able to exploit. If these adds/deletes are the only actions in a changeset, you're also able to write something yourself. – Daniel Beck Feb 4 '11 at 13:13
  • Surely that can't be true? One of the attractions of Subversion is that "copies are cheap", and they preserve the file's history. If the contents matched only incidentally, Subversion would have to be storing entire new copies of the file, which wouldn't be cheap, and you wouldn't be able to see a file's history beyond a rename. Subversion must somewhere have a chain through all the revisions of a file, regardless of the file's name. I just want to see the filename of the file at each link of that chain. – Matthew Exon Feb 4 '11 at 13:28
  • Relevant: markphip.blogspot.com/2006/12/… – Ryan Bolger Feb 4 '11 at 15:02
  • Google Code does it, its the only time I've been aware of it, e.g. code.google.com/p/corsix-th/source/list?path=/trunk/CorsixTH/… – tobylane Feb 4 '11 at 21:06

You can use svn info -r revision-number file-path for each relevant revision number and file path. It's a bit cumbersome, but seems to work.

  • 1
    Beautiful, I used svn log rtw_2008.mdwn | grep -o -E '^r[0-9]+' | xargs -L 1 -irev svn info -rev rtw_2008.mdwn | grep '^Path:' and got exactly what I wanted. Thanks! – Matthew Exon Feb 5 '11 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.