Mercurial workflow question (how to handle Config files)
Asked Answered
R

6

7

I have a long standing problem: at work we're using mercurial as a DSCM, but we can't figure out how to keep our config files in sync.

The problem is that we want to keep track of config files and want to be able to exchange the config file contents among developers, but every developer wants to have his connectionStrings section independent of others'.

Is it possible to somehow keep config files tracked but to omit the connection strings section when pulling and pushing?

We tried adding config files to .hgignore but when someone adds something important to config file we have to share it by email.

Thank you.

Ripsaw answered 4/9, 2009 at 12:34 Comment(0)
P
6

If you can't deal with it with the inclusion of custom settings, just have a base config file in the repo.

Then have each developer put it's own customization on top (with mq). If the customization isn't too intrusive the merge will always go well.

There is another way, where you repeatedly merge your customization, but then when pushing you have to remember not to push the merge branch (tX is mainline, c1 is the customization)

t1-t2-t3-t4-...-tN
  \    \      \   \
   c1---c2-----c3--c4

The dev needs and push changes who only have tX as parents, cX should never escape the repo.

Palazzo answered 4/9, 2009 at 12:59 Comment(0)
B
4

I don't know the details of your config files, but if you can include other files, then create a config_local file to hold the developer-specific settings. Add that file to .hgignore. Common settings go into the main config file, which then includes the config_local file.

As Ken says, if inclusion isn't an option, then preprocessing during the build step may be the way to go.

Benzel answered 4/9, 2009 at 12:48 Comment(0)
U
3

You can use Mercurial Queues to do it. So what you would do is have the "real" config(s) under hg (with their real names), and developers can maintain their customizations using patches which sit on top and are maintained with mq.

Then when developers need to update the real config, they pop their patch which holds all of their customizations off the stack, make the change to the config and commit+push it.

Presuming all other developers haven't overridden those particular changes in their own queues, they will receive them the next time they pull+update.

Utmost answered 4/9, 2009 at 18:50 Comment(0)
J
1

The non-DVCS way to handle it is to set up your build process to read the connection strings from separate config file and then preprocess it during the build process (in java you could use ant or maven to filter from a properties file, I don't know about MS-land).

Juryman answered 4/9, 2009 at 12:42 Comment(0)
W
1

Put your connection strings in a different file. e.g. in web.config:

<connectionStrings configSource="connections.config" />

Then you have a connections.config file with the connection strings, which you can exclude from the repository thereby letting each developer modify to their heart's content.

If you want a 'reference' version of the connections.config file just add another file connections.example.config that is under source control, and use that as your template version.

Wooden answered 11/2, 2011 at 23:11 Comment(0)
E
0

It's a bit of a bastardization, but you could use the KeywordExtension to automatically expand tokens. In your config file put something like this:

db.host = $DBHOST$
db.host = $DBUSER$
db.host = $DBPASS$

and then in their ~/.hgrc files user's would have something like this:

[extensions]
hgext.keyword=
[keyword]
# expand keywords in all python files in working dir
**.conf =
[keywordmaps]
DBHOST = dev.server.internal
DBUSER = myname
DBPASS = mypass

Production, of course, would have its own .hgrc.

The scheme would cost everyone a little bit of set up time once, but after that it should be automatic. Defaults could be in the system-wise /etc/mercurial/hgrc file in case the user didn't want to set their own private connection strings.

Emptyheaded answered 4/9, 2009 at 19:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.