Hemisphera
Hemisphera

Reputation: 13

Mercurial: Pre and Post merge operations (per file)

We are using Mercurial as an SCM to handle the source script files of a program. Each project we manage has ~5000 files with each file containing a section with some product-specific informations about the file itself (version list, date, time etc.). This section is - due to the way it is structured - in 80% of the merges, the only section that has conflicts. They are easily resolved, but when merging around 300 files, it gets tiresome.

The problem is: I have no control over the way this section is written and I cannot change the format of the section itself, as it would make the file unusable by the program.

My question: is there a way in mercurial (hooks?), that allows me to

  1. pre-process the file with a script
  2. let mercurial do the merge
  3. if merged correctly: post-process the file with a script. otherwise: "resolve-conflicts" as usual.

Upvotes: 1

Views: 72

Answers (1)

Ry4an Brase
Ry4an Brase

Reputation: 78350

You could probably get away with it by creating a custom merge tool:

https://www.mercurial-scm.org/wiki/MergeToolConfiguration

A simple script that invokes 'diff' after removing the ever changing sections might be enough.

It sounds like those sections are the sort of nonsense that the (disrecommended) KeywordsExtension are built to handle, but I gather you don't have a lot of flexibility around them.

Upvotes: 1

Related Questions