How do I find the revision that changed a line in my code using TortoiseSvn?
Asked Answered
S

4

5

I have one line of code which seems commented. Basically the thing I want to find is the revision that changed this line in the code.

So, is it possible to see changes in code related to a specific keyword in TortoiseSvn Log?

Stamata answered 29/10, 2009 at 11:18 Comment(0)
W
9

What you want to do is do a Blame on that source file and it will show you the revisions that changed each of the lines of code.

I'm not aware of any command that would be able to give you all revisions for a given line of code...what you can do is do a show log on a single file and then look at each of the revisions that took place over time.

Weariful answered 29/10, 2009 at 11:22 Comment(5)
Is there also a way to find all revisions a certain line was modified? Blame will only give me the last revision.Casi
No, it will only show you who changed the line last. He wanted somethiing that he can point on a line and show in what revisions this line was changed (my understaning of the question).Bobsled
I'm not aware of any such command that would be able to give you all revisions for a given line of code...what you can do is do a show log on a single file and then look at each of the revisions that took place over time.Weariful
@BeowulfOF If you look at his question he asks for the revision that changed a single line of code....which to me means blame...only in his comment does he seem to clarify that he wants some sort of blame history.Weariful
Thanks guys, it will be quite useful for my case.Stamata
G
2

Mezoid's Blame sounds correct. As an aside, I'd like to share a technique that commandline svn users might find useful. (It's about svn blame, but I use the "annotate" synonym, or "svn ann", because "blame" sounds a bit harsh!)

OK, so you have a line you're interested in, and it has a distinctive string on it "distinctiveString". You want to read the commit message when the line was first introduced, but it may have been edited a few times. So, you go ahead and do this:

# svn ann that.file | grep distinctiveString
2345     yada yada distinctiveString blah blah

A look at your TRAC web interface for svn shows that r2345 simply changed the indentation of the line, it wasn't the revision at which the line was introduced. So next you use the -R flag (or -r, do svn help ann to make sure) to specify the revision one less than the revision you found in the previous step:

# svn ann -R 2344 that.file|grep distinctiveString
2211  yada yada distinctiveString blah blah

Rinse and repeat until you find the original.

You can omit the TRAC lookup at each step by simply repeating until you don't see the line any more, and taking the result of the penultimate iteration.

OK, it's a bit laborious, but if you really want to know who introduced that line it will do the job. It can save you time if the original commit message explains the intent of an obscure piece of code that otherwise looks like it could be removed.

Greene answered 29/10, 2009 at 12:1 Comment(1)
I like it. I'll have to try that some time.Weariful
B
1

You can right-click on a file in your repo and select TortoiseSVN->Show Log to get the revisions this file was affected by. On a line by line basis, there is no way I know of.

Bobsled answered 29/10, 2009 at 11:34 Comment(0)
I
0

I was looking for the same feature and i end up here and i quit looking any further.

But here is a technique i am using and it may help anyone else:

  1. Identify the line of interest. Last call it: line 123.
  2. Use to Tortoise to "show log" of the file.
  3. Consider the full list in the log.
  4. If you have no idea when it could have happened, use the "quick sort mindset", i mean, go to the revision in middle of the list, right click and "compare with working copy".
  5. If the line 123 exists (same content, but probably a different line number), then you should now consider only the bottom half of the list, else you should now consider only the top half of the list. Go back to step 4.

It is easier to do than to explain. Since this text is target for developers, I understand there is no need to add more details :)

Indissoluble answered 21/9, 2018 at 13:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.