Moving a method from one file to another while keeping its history
I recently moved a method from one class / file into another so that I could reuse it. Now if I blame through subversion I am responsible for all lines of code, which makes sense since I created a new file.
Is there any way to get subversion to recognize where that method came from so开发者_JS百科 that the history is kept intact?
If you moved the function from one existing file to another existing file, I think the short answer is, "It can't be done". If you moved the function from an existing file to a new file, i.e. you created the new file just to hold this function (maybe adding other things, but starting with this function), then you could copy the file, delete the function from the original, and delete everything but the function from the copy. Then both the original and the copy would preserve the history.
No - history is per file. Subversion just knows it's a file full of text; it does not parse the text to understand what it is.
If you really really want to keep history intact, you could use svn cp
to create a copy that is then edited separately.
But, I've never done that, and don't think I ever will. The only reason that I would do something like that would be for a file that is completely split into pieces, not for a method that moves from one file to another.
Instead, I'd use a meaningful checking comment: something like "foo created by extracting bar from baz"
By history -- you mean "per line" history, like from "svn blame"?
Add a comment:
/** Moved from {@link OldClass}. */
and make sure both classes (new and old) are checked in in the same revision. If someone really cares they can read the comment and "svn blame" the old class.
精彩评论