Moving a method from one file to another while saving its history

I recently moved a method from one class / file to another so that it can be reused. Now, if I blame subversion, I am responsible for all lines of code, which makes sense since I created a new file.

Is there a way to get a disruptive function to recognize where this method came from so that the story is not saved?

+4
source share
4 answers

If you moved a function from one existing file to another existing file, I think the short answer is: "This is not possible." If you moved a function from an existing file to a new file, i.e. You created a new file, just to save this function (perhaps adding other things, but starting with this function), you can copy the file, delete the function from the original and delete everything except the function from the copy. Then both the original and the copy would save the story.

+6
source

No - history per file. Subversion just knows that it is a file full of text; he does not analyze the text to understand what it is.

+1
source

If you really want to keep the history intact, you can use svn cp to create a copy, which is then edited separately.

But I have never done this, and I donโ€™t think I will ever be. The only reason I will do something like this would be for a file that is completely broken into parts, and not a method that moves from one file to another.

Instead, I would use a meaningful control comment: something like "foo created by extracting a bar from baz"

+1
source

By history - do you mean the story "per line", for example, from "svn wame"?

Add a comment:

 /** Moved from {@link OldClass}. */ 

and make sure that both classes (new and old) are marked in the same revision. If someone really cares, they can read the comment and โ€œsvn blameโ€ the old class.

+1
source

Source: https://habr.com/ru/post/1346772/


All Articles