How do I save configuration files in different branches of Mercurial?

Viewed 97

I have a problem with saving different config files in my Mercurial repository. For example, I have 2 branches - dev and testing. For each, I have my Jenkinsfile (configuration of Jenkins pipeline). It also could be any other configuration files (DB config, other systems configs) that are different between branches. Each time when I merge testing with dev I should merge the Jenkinsfile manually. How could I solve this problem? I wanna save the history of my config files and don't wanna have any problems with merging. Is there any approach to solve this routine problem?

2 Answers

This could do the trick:

When you hit the merge conflict (obviously, you will see conflict every time when merging these two branches with a config file with the same name but different content) you can perform a re-merge only for that config file while also using the --tool flag to tell the "merge machine" that we want to keep the local version of this file, by running:

hg resolve path/to/config/file --re-merge --tool ':local'

Or short version: hg res path/to/config/file --re-merge -t ':local'

Note: hg merge also has this --tool option but be careful using that because it would apply that merge-tool to every file that will be merged in that operation.

To know more about merge tools, run: hg help merge-tools

Mercurial a lot of time have concepts of custom merge tools and merge-patterns (see MergeTools.rc and MergePatterns.rc)

I.e. you can for your Jenkinsfile (even it haven't unique perrepository extension, give it) custom mergetool, which will do just hg merge --tool internal:local

Related