Merge of file header Changelog

Asked by Dominic Evans

I'm working on source code dating back several years, before the more advanced version control systems like bazaar were invented. As such each file has a 'Changelog' style section at the top, detailing what was modified in the last change. Legacy process dictates that we keep this up to date.

i.e.,

/**
 * Change activity:
 *
 * Reason Date Origin Description
 * --------------- ------ -------- --------------------------------------------
 * 123456 080508 tonik Send format 1.2 xml
 * 123457 080509 dnwe Emit publications on completion of work.
 * 123458 080514 peters Swap in new sort algorithm
 * =============================================
 */

However, when merging from branches, this always causes a conflict (admittedly, trivial to resolve but requires manual intervention) as both people have inserted a change line above the === line.

Is there a way of getting these to automatically merge without conflict? It doesn't really matter in which order they appear, although sorted by timestamp of original commit would be optimal.

Question information

Language:
English Edit question
Status:
Solved
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Solved by:
Andrew Bennetts
Solved:
Last query:
Last reply:
Revision history for this message
Matt Nordhoff (mnordhoff) said :
#1

This is just a workaround, but FWIW, the Bazaar project keeps the items
in its changelog in alphabetical order specifically to avoid this problem.

Revision history for this message
Dominic Evans (oldmanuk) said :
#2

I did test this by re-ordering the columns, to put date first, and then sorting alphabetically, but a merge from two branches still produced conflicts.

Revision history for this message
Vincent Ladeuil (vila) said :
#3

What the bazaar project is doing is sorting items in the NEWS file (where that kind of conflicts happens) on a criteria that makes collisions less likely: each item describes the new feature or bug fix. These items, being text, don't collide (generally).

But that doesn't work with dates. In fact, by using dates, you have even more chances of producing such conflicts because the parallel modifications occur... at the same time.

Using 'origin' (which seems to be the login) at the first sort column (and eventually date as the second) should work far better.

Revision history for this message
Best Andrew Bennetts (spiv) said :
#4

Bazaar 2.1 has introduced a 'merge_file_content' hook that you can use to solve this. See bzrlib/plugins/news_merge for an example plugin that can merge bzr's NEWS file better than the generic merge.

Revision history for this message
Dominic Evans (oldmanuk) said :
#5

Thanks Andrew Bennetts, that solved my question.