Is it possible to check in a portion of mercurial hgrc file into the repo? Specifically, the [path] section

StackOverflow https://stackoverflow.com/questions/20117349

  •  03-08-2022
  •  | 
  •  

Question

After doing a little bit of research on google and stack, it seems that it is not possible to check in a hgrc file into the repo, for various security reasons that make a lot of sense.

However, I have an interesting setup and I'm wondering if someone knows a way to make this easier.

Specifically, we run a plethora of ecommerce stores, of which the templates are built off a base repo, and each store also has it's own repo (inherited from base).

We also have a number of dev environments, and so to make this easier we use the [path] directive in hgrc quite heavily.

Here is an example of our setup:

Say we have the following template repositories for stores: electronic_store, clothing_store, toy_store, as well as a base template called base

We also have the following environments: paris, london and live

Thus, in each store's hgrc, we have the following:

;inside hgrc for electronic_store
[path]
default = kiln://instances/live/electronic_store
paris = kiln://instances/paris/electronic_store
london = kiln://instances/london/electronic_store
live = kiln://instances/live/electronic_store
base = kiln://instances/live/base

;inside hgrc for clothing_store
[path]
default = kiln://instances/live/clothing_store
paris = kiln://instances/paris/clothing_store
london = kiln://instances/london/clothing_store
live = kiln://instances/live/clothing_store
base = kiln://instances/live/base

This makes it easy from any environment to do a hg pull base, hg push/pull paris, hg push/pull live etc

However, we often close environments and open new ones up, and then it gets quite tedious to update the hgrc for all repositories not only in each storefront (which we would expect to do anyway), but also in each environment. Since the hgrc is not tracked, there is no way to have these changes synced with a simple pull/push as we would expect.

We also cannot add these to our global .hgrc files, because while the path names are the same, they push/pull to their own respective repositories (ie hg push paris on electronic_store is a different repo than hg push paris on clothing_store)

Is there any way to make the [path] portion of the hgrc trackable in the repo? Or, failing that, based on the setup we currently have, are there any other recommendations for making it easier to manage the repositories as I have described?

Thanks in advance.

Was it helpful?

Solution

As Ry4an says here in StackOverflow there's a not-often used %include directive. The trick could be:

In ./.hg/hgrc the usual config plus a line including a hgrc file from the working directory:

[paths]
%include ../hgrc.tracked.paths 

In ./hgrc.tracked.paths the paths versioned by Mercurial:

[paths]
default = kiln://instances/live/clothing_store
paris = kiln://instances/paris/clothing_store
london = kiln://instances/london/clothing_store
...

So just hg add hgrc.tracked.paths will start versioning and sharing the file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top