SVN - Does a merge preserve the author so that blame will be correct?
Asked Answered
C

6

5

In my team, some we help each other with the merges. I.e. my code is merged back to trunk by someone else. It seems like the author info not is fully preserved during a merge. When I do annotate (blame) the merger is shown as the author.

Have the merger done something wrong or isn’t the original author preserved in a merge?

Complete answered 26/10, 2010 at 12:37 Comment(0)
S
11

If your server does merge tracking and your client tools are version 1.5 or later, this will work:

svn blame --use-merge-history TARGET
Segmentation answered 27/10, 2010 at 12:40 Comment(1)
Or svn blame -g TARGET (shorter)Presidium
H
1

A merge looks like someone checkout out trunk, made a load of changes all at once and then committed back in. Whoever did the final commit after the merge will show as the author. If you are getting people to help with the merge, make sure they do it under the username of the person you wish it to be attributed to.

Having said all that, if someone makes a mistake in the merge then you want the name of the person who 'helped' with the merge if they were the one doing it, surely?

Hendrix answered 26/10, 2010 at 12:46 Comment(1)
The --username option to svn commit can be used for committing as another user.Presidium
P
1

The only information on the SVN server is the author of the commit. That's what blame/annotate will use.

So no, the author isn't preserved during this kind of merge. It would require LOTS more information than SVN handles.

Plutocrat answered 26/10, 2010 at 12:48 Comment(0)
H
1

In my opinion the approach that the merge is not done by the orignal author is wrong...but this is a different story.

In Subverison every commit is associated with an author. A merge can only be done in a working copy which belongs to a particular author. In my opinion the information in SVN is correct, cause the guy who merged the code is "responsible" for the merge...so the relationship to his name is correct.

Hazelhazelnut answered 26/10, 2010 at 15:40 Comment(1)
I believe that there are valid scenarios for this approach. Like, we have several apprentices in our company and they work in different feature branches of the same app. I surely do not want them to do unattended merges to applications that will eventually go live. I want to review their changes first and then finally do the merge. I still take the responsibility for merging as I am the project owner anyway. Plus you will find my name in the SVN history as the merge commiter. But still, I may want to know which line was made who without my own name getting in the way.Lurleen
D
0

I'm not 100% sure, but I think the answer would be: Yes and No... annotate AFAIK will only show you the author that made the most recent change to that line of code. This, in your case, would be the person who did the merge. If you need to go further, you need to blame on the version before the merge.

Dusa answered 26/10, 2010 at 12:47 Comment(0)
N
0

A merge might change the svn:mergeinfo property. In this case, the authors of the original commits for any given merge can be discovered indirectly.

But this is merely a bandaid - if you want real author tracking through merges, you might need to switch to a tool tool designed for distributed development: something like git, hg, or even darcs.

Nagey answered 26/10, 2010 at 12:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.