Differences between revisions 11 and 12
Revision 11 as of 2011-04-02 20:27:33
Size: 1561
Editor: GregWard
Comment: restore correct category
Revision 12 as of 2012-01-13 08:54:25
Size: 8217
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
Line 11: Line 10:
This extension makes Mercurial look for and parse ''`.hg/projrc`'' for additional configuration settings. The file is transferred unconditionally on clone and on pull (but never on push) from a list of servers that '''must '''be configured by the user. For security reasons the user '''must '''also select which ''`projrc`'' configuration settings will be transfered (i.e. no settings are transferred from no servers by default).
Line 12: Line 12:
This extension makes Mercurial parse ''`.hg/projrc`'' for additional configuration settings. The file is transferred unconditionally on clone and on pull (but never on push). This is useful for centralized setups where you want to distribute configuration settings to all repositories with a minimum amount of setup. In particular, it can be used to implement the second part of the SubrepoRemappingPlan.
Line 14: Line 14:
This can be used to implement the second part of the SubrepoRemappingPlan. === Load Order ===
The settings in the ''`.hg/projrc`'' file are meant to be used as additional ''system settings'', which means that the extension tries hard to load them in this order:

 1. System configuration files (''`/etc/mercurial/hgrc`'', ''`C:\mercurial\mercurial.ini`'' and friends)
 1. Project specific configuration (''`.hg/projrc`'')
 1. User configuration files (''`$HOME/.hgrc`'', ''`%HOME%\.hgrc`'', and ''`%HOME%\mercurial.ini`'')
 1. Repository specific configuration (''`.hg/hgrc`'')

This is so that users can disable extensions loaded in the ''`.hg/projrc`'' file.
Line 23: Line 31:
Enabling the extension will make mercurial look for and parse any ''`projrc`'' file found on a repository ''`.hg`'' folder. However, it will not make mercurial transfer that file when cloning or update it when pulling from a server that has a ''`projrc`'' file.
Line 24: Line 33:
=== Load Order === For security reasons the user must explicitly whitelist the repositories from which it wants to get the ''`projrc`'' file, and it must also select which configuration keys it must get from the remote ''`projrc`'' files. This is necessary to avoid a malicious user to create a ''`projrc`'' file that enables hooks or extensions that may execute arbitrary code on the user's local machine.
Line 26: Line 35:
The settings in the ''`.hg/projrc`'' file are meant to be used as additional ''system settings'', which means that the extension tries hard to load them in this order: this file when is not enough to get the .your ''`.hgrc`'' to enable the extension by adding following lines:
Line 28: Line 37:
 1. System configuration files (''`/etc/mercurial/hgrc`'', ''`C:\mercurial\mercurial.ini`'' and friends)
 2. Project specific configuration (''`.hg/projrc`'')
 3. User configuration files (''`$HOME/.hgrc`'', ''`%HOME%\.hgrc`'', and ''`%HOME%\mercurial.ini`'')
 4. Repository specific configuration (''`.hg/hgrc`'')
in order to actually enable the extension you must configure it to select the servers and the configuration keys that must be received from those servers. This is done by adding a "''`[projrc]`''" section to one of your local hgrc files, and in that section configuring the following configuration keys: ''`servers`'', ''`confirm`'', ''`include`'' and ''`exclude`''.
Line 33: Line 39:
This is so that users can disable extensions loaded in the ''`.hg/projrc`'' file. For example:

{{{
[projrc]
servers = http://mycentralserver/*, localhost
include = *
confirm = False
}}}
For more examples see the "Configuration Examples" section below.''''

 * servers:

The "''`projrc.servers`''" setting lets you control from which servers the projrc file must be pulled. This setting is a comma separated list of glob patterns matching the server names of the servers that the projrc file must be pulled from.

Unless the "''`projrc.servers`''" key is set, the projrc file will not be pulled from any server.

To pull the ''`projrc`'' file from all servers, you can set the "''`projrc.servers`''" key to "''`*`''" (without the quotes).

To pull the ''`projrc`'' file from any repo hosted on server "http://example.com", set the "''`projrc.servers`''" key to "http://example.com/*" (without the quotes).

Note that the server pattern match considers forward and backward slashes as different characters.

The patterns in the server list are "expanded" using the local mercurial "''`pahts`''" configuration. That is, before matching them against the pull or clone source, they will be compared to the repository "paths" that are defined on the "''`[pahts]`''" section of the local ''`hgrc`'' files (such as ''`default`'' , ''`default-push`'', or any other such path). If they match the pull source will be matched against the corresponding path, not against the actual path name.

The path name expansion is useful if you want to allow the transfer of ''`projrc`'' files from clones of clones. Simply add "''`default`''" to your server list and the extension will always update the projrc file when pulling from the default repository source. Note that you will not get the projrc file when cloning. Instead you'll get it when you first pull into the clone. This is a known issue.

There is an additional "special server" that you can add to your server list, which is "''`localhost`''". If you add localhost to the server list, you will always get the projrc file when cloning or pulling from any local repo (where a "local repo" is one that is on the local machine, whether it is accessed directly through the file system or through http, https or ssh access to the localhost)

 * include:

The "''`projrc.include`''" configuration key lets you control which sections and which keys must be accepted from the remote projrc files. The "''`projrc.include`''" key is a comma separated list of glob patterns that match the section or key names that must be included. Keys names must be specified with their section name followed by a '.' followed by the key name (e.g. "''`diff.git`''").

To allow all sections and all keys you can set the "''`projrc.include`''" key to "''`*`''" (without the quotes).

Using globs it would be possible to receive all the authorization keys for the bitbucket.com server, for example, by adding "''`auth.bitbucket.com.*`''" to the projrc.include configuration key.

 * exclude:

The "''`projrc.exclude`''" setting is similar to the "''`projrc.include`''" setting but it has the opposity effect. It sets an "exclude list" of settings that must not be transferred from the common projrc files.

The exclude list has the same syntax as the include list. If an exclusion list is set but the inclusion list is empty or not set all non excluded keys will be included.

If both an include and an exclude lists are set, and a key matches both the include and the exclude list, priority is given to the most explicit key match, in the following order:

 * full key, exact matches are considered the most explicit (e.g. "''`ui.merge`''");
 * pattern (glob) matches are considered next (e.g. "''`auth.bitbucket.com.*`''"), with the longest matching pattern being the most explicit;
 * section level matches (e.g. "''`ui`''");
 * global ("''`*`''") matches.

If a key matches both an include and an exclude (glob) pattern of the same length, the key is ''included'' (i.e. inclusion takes precedence over exclusion).

 * confirm:

This configuration setting controls whether the user must confirm the transfer of new projr settings.

Valid values are:

 * ''`True`'' or ''`always`'' : Always ask for confirmation (this is the default).
 * ''`first`'' : Ask for confirmation when the projrc file is transferred for the first time (e.g. on clone).
 * ''`False`'' or ''`never`'': Never ask for confirmation (accept all projrc changes).

Note that if this key is not set, the user will have to confirm all changes (i.e. ''`always`'' is the default setting)

Set this key to "''`False`''" if you want to automatically accept all changes to the project configuration.

Set this key to "''`first`''" if you want to only ask for confirmation when you clone a repo that has a projrc file, or when you pull for the first time from a repo to which a projrc file has been is added.

Note that if you do not confirm the transfer of the new ''`projrc`'' file you will be prompted again when you next pull from the same source (i.e. the extension does not remember your previous answer to the confirmation prompt).
Line 36: Line 109:

projrc

This extension is not distributed with Mercurial.

Author: MartinGeisler

Download site: http://bitbucket.org/aragost/projrc

Overview

This extension makes Mercurial look for and parse .hg/projrc for additional configuration settings. The file is transferred unconditionally on clone and on pull (but never on push) from a list of servers that must be configured by the user. For security reasons the user must also select which projrc configuration settings will be transfered (i.e. no settings are transferred from no servers by default).

This is useful for centralized setups where you want to distribute configuration settings to all repositories with a minimum amount of setup. In particular, it can be used to implement the second part of the SubrepoRemappingPlan.

Load Order

The settings in the .hg/projrc file are meant to be used as additional system settings, which means that the extension tries hard to load them in this order:

  1. System configuration files (/etc/mercurial/hgrc, C:\mercurial\mercurial.ini and friends)

  2. Project specific configuration (.hg/projrc)

  3. User configuration files ($HOME/.hgrc, %HOME%\.hgrc, and %HOME%\mercurial.ini)

  4. Repository specific configuration (.hg/hgrc)

This is so that users can disable extensions loaded in the .hg/projrc file.

Configuration

Configure your .hgrc to enable the extension by adding following lines:

[extensions]
projrc = path/to/projrc/projrc.py

Enabling the extension will make mercurial look for and parse any projrc file found on a repository .hg folder. However, it will not make mercurial transfer that file when cloning or update it when pulling from a server that has a projrc file.

For security reasons the user must explicitly whitelist the repositories from which it wants to get the projrc file, and it must also select which configuration keys it must get from the remote projrc files. This is necessary to avoid a malicious user to create a projrc file that enables hooks or extensions that may execute arbitrary code on the user's local machine.

this file when is not enough to get the .your .hgrc to enable the extension by adding following lines:

in order to actually enable the extension you must configure it to select the servers and the configuration keys that must be received from those servers. This is done by adding a "[projrc]" section to one of your local hgrc files, and in that section configuring the following configuration keys: servers, confirm, include and exclude.

For example:

[projrc]
servers = http://mycentralserver/*, localhost
include = *
confirm = False

For more examples see the "Configuration Examples" section below.'

  • servers:

The "projrc.servers" setting lets you control from which servers the projrc file must be pulled. This setting is a comma separated list of glob patterns matching the server names of the servers that the projrc file must be pulled from.

Unless the "projrc.servers" key is set, the projrc file will not be pulled from any server.

To pull the projrc file from all servers, you can set the "projrc.servers" key to "*" (without the quotes).

To pull the projrc file from any repo hosted on server "http://example.com", set the "projrc.servers" key to "http://example.com/*" (without the quotes).

Note that the server pattern match considers forward and backward slashes as different characters.

The patterns in the server list are "expanded" using the local mercurial "pahts" configuration. That is, before matching them against the pull or clone source, they will be compared to the repository "paths" that are defined on the "[pahts]" section of the local hgrc files (such as default , default-push, or any other such path). If they match the pull source will be matched against the corresponding path, not against the actual path name.

The path name expansion is useful if you want to allow the transfer of projrc files from clones of clones. Simply add "default" to your server list and the extension will always update the projrc file when pulling from the default repository source. Note that you will not get the projrc file when cloning. Instead you'll get it when you first pull into the clone. This is a known issue.

There is an additional "special server" that you can add to your server list, which is "localhost". If you add localhost to the server list, you will always get the projrc file when cloning or pulling from any local repo (where a "local repo" is one that is on the local machine, whether it is accessed directly through the file system or through http, https or ssh access to the localhost)

  • include:

The "projrc.include" configuration key lets you control which sections and which keys must be accepted from the remote projrc files. The "projrc.include" key is a comma separated list of glob patterns that match the section or key names that must be included. Keys names must be specified with their section name followed by a '.' followed by the key name (e.g. "diff.git").

To allow all sections and all keys you can set the "projrc.include" key to "*" (without the quotes).

Using globs it would be possible to receive all the authorization keys for the bitbucket.com server, for example, by adding "auth.bitbucket.com.*" to the projrc.include configuration key.

  • exclude:

The "projrc.exclude" setting is similar to the "projrc.include" setting but it has the opposity effect. It sets an "exclude list" of settings that must not be transferred from the common projrc files.

The exclude list has the same syntax as the include list. If an exclusion list is set but the inclusion list is empty or not set all non excluded keys will be included.

If both an include and an exclude lists are set, and a key matches both the include and the exclude list, priority is given to the most explicit key match, in the following order:

  • full key, exact matches are considered the most explicit (e.g. "ui.merge");

  • pattern (glob) matches are considered next (e.g. "auth.bitbucket.com.*"), with the longest matching pattern being the most explicit;

  • section level matches (e.g. "ui");

  • global ("*") matches.

If a key matches both an include and an exclude (glob) pattern of the same length, the key is included (i.e. inclusion takes precedence over exclusion).

  • confirm:

This configuration setting controls whether the user must confirm the transfer of new projr settings.

Valid values are:

  • True or always : Always ask for confirmation (this is the default).

  • first : Ask for confirmation when the projrc file is transferred for the first time (e.g. on clone).

  • False or never: Never ask for confirmation (accept all projrc changes).

Note that if this key is not set, the user will have to confirm all changes (i.e. always is the default setting)

Set this key to "False" if you want to automatically accept all changes to the project configuration.

Set this key to "first" if you want to only ask for confirmation when you clone a repo that has a projrc file, or when you pull for the first time from a repo to which a projrc file has been is added.

Note that if you do not confirm the transfer of the new projrc file you will be prompted again when you next pull from the same source (i.e. the extension does not remember your previous answer to the confirmation prompt).

Caveats

While you can enable extensions in the .hg/projrc file, you cannot disable extensions with it. This is because Mercurial enables the extensions loaded from the normal configuration files before projrc gets a chance to loads the .hg/projrc file.


CategoryExtensionsByOthers

ProjrcExtension (last edited 2012-05-23 12:29:18 by AngelEzquerra)