Difference between revisions of "Mercurial Tools"
Jonathan Yap (talk | contribs) (Added Mercurial Initialization File, made corresponding changes to the instructions, moved the 2 options to a higher wiki heading) |
Jonathan Yap (talk | contribs) m (Bolded Mercurial Initialization File) |
||
Line 14: | Line 14: | ||
== Mercurial Initialization File == | == Mercurial Initialization File == | ||
The Mercurial Initialization File referred to in the instructions below depends on your operating system. The path to it is | The '''Mercurial Initialization File''' referred to in the instructions below depends on your operating system. The path to it is | ||
*For Windows: <code>%USERPROFILE%\Mercurial.ini</code> | *For Windows: <code>%USERPROFILE%\Mercurial.ini</code> | ||
*For Mac and Linux: <code>$HOME/.hgrc</code> | *For Mac and Linux: <code>$HOME/.hgrc</code> | ||
Line 24: | Line 24: | ||
All changes pulled to a Linden Lab repository will have to pass the checks enforced by the command above. This is enforced when the changes are pulled by the hook provided by <tt>coding_policy.py</tt>. | All changes pulled to a Linden Lab repository will have to pass the checks enforced by the command above. This is enforced when the changes are pulled by the hook provided by <tt>coding_policy.py</tt>. | ||
To make that check automatic when you are doing local commits, add the following to your Mercurial Initialization File (changing ''/path/to'' to the location where you checked out the hg-tools repository): | To make that check automatic when you are doing local commits, add the following to your '''Mercurial Initialization File''' (changing ''/path/to'' to the location where you checked out the hg-tools repository): | ||
[hooks] | [hooks] | ||
Line 39: | Line 39: | ||
== <tt>hg policy</tt> command == | == <tt>hg policy</tt> command == | ||
To install the extension, add the following to your Mercurial Initialization File (changing ''/path/to'' to the location where you checked out the hg-tools repository): | To install the extension, add the following to your '''Mercurial Initialization File''' (changing ''/path/to'' to the location where you checked out the hg-tools repository): | ||
[extensions] | [extensions] |
Revision as of 12:38, 19 August 2011
The Mercurial repository
https://bitbucket.org/lindenlab/hg-tools
contains tools for working with Linden Lab repositories.
You are strongly encouraged to check out a copy of this repository and install the coding policy script there as described below, since anything you submit must pass those checks.
Coding Policy
The coding_policy.py file provides both a Mercurial command extension hg policy and a hook that you should install to check all files when they are committed.
Mercurial Initialization File
The Mercurial Initialization File referred to in the instructions below depends on your operating system. The path to it is
- For Windows:
%USERPROFILE%\Mercurial.ini
- For Mac and Linux:
$HOME/.hgrc
You should have created this file when you installed Mercurial and established your username (and, optionally, your email address). If the file does not exist create it.
Commit Hook
All changes pulled to a Linden Lab repository will have to pass the checks enforced by the command above. This is enforced when the changes are pulled by the hook provided by coding_policy.py.
To make that check automatic when you are doing local commits, add the following to your Mercurial Initialization File (changing /path/to to the location where you checked out the hg-tools repository):
[hooks] pretxncommit.coding_policy = python:/path/to/coding_policy.py:hook
you can also check all changes you pull into your repository by adding this (also under \[hooks\]):
pretxnchangegroup.coding_policy = python:/path/to/coding_policy.py:hook
Anyone maintaining a shared repository is encouraged to install this so that you can prevent problems when you attempt to merge your shared repository back to viewer-development.
These hooks apply only to repositories that are related to (share a common ancestor with) specific Linden Lab repositories (see the repo_root variable assignment in the source). Operations on those repositories will print a message describing which policy is being applied, or one that indicates that the repository is not subject to Linden Lab policy checks.
hg policy command
To install the extension, add the following to your Mercurial Initialization File (changing /path/to to the location where you checked out the hg-tools repository):
[extensions] policy = /path/to/coding_policy.py
To check changes against Linden Lab coding policy
hg policy [-p {opensource|proprietary}] {[-f FILE] | [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]}
With no arguments, check uncommitted changes in the working directory.
A specific file (whether or not it has been added to the repository or modified) can be checked by using the -f/--file file option.
When revisions are specified via -r/--rev, check the given committed changes in the local repository.
When given a remote repository, check changes that have been committed locally that are not present in the remote repository. To check changes that would be pushed by default, specify "default-push" as the repository name.
Warning: Specifying another repository currently does not work... I am working on it, but the hook function, checking changes in your local repository prior to commit, and checking a specific file do seem to be working.
As an alternative to the above - if you need to see whether or not the changes in your repo will pass the commit hook when pulled to some other repo, preview the operation by:
The pretxnchangegroup hook will then analyze all the pulled changes. Oz Linden 04:02, 19 August 2011 (PDT) |
The checks may be against either of two policy sets: opensource or proprietary options:
- -p|--policy POLICY
- The set of policies to check: POLICY may be either 'opensource' or 'proprietary' (the default depends on the repository)
- -r|--rev REVISION
- a revision up to which you would like to check (may be specified more than once for a range)
- -f|--file FILE
- a file to check (whether or not it has been modified)