I am trying to go though this tutorial that says:
Enable SSH compression for Mercurial
Edit the Mercurial global configuration file (~/.hgrc).
Add the following line to the UI section:
ssh = ssh -C
But there is no that file in my system. HG of course is installed.
It is not there by default. You don't need it to exist — it just can exist to customize how you use Mercurial. You just need to create a .hgrc file in your home directory and it should work.
Heres a great intro post:
http://hgtip.com/tips/beginner/2009-09-30-configuring-mercurial
Snagged from the manpages at https://www.selenic.com/mercurial/hgrc.5.html.
Files
Mercurial reads configuration data from several files, if they exist.
These files do not exist by default and you will have to create the
appropriate configuration files yourself:
Local configuration is put into the per-repository /.hg/hgrc
file.
Global configuration like the username setting is typically put into:
%USERPROFILE%\mercurial.ini
$HOME/.hgrc
The names of these files depend on the system on which Mercurial is
installed. *.rc files from a single directory are read in alphabetical
order, later ones overriding earlier ones. Where multiple paths are
given below, settings from earlier paths override later ones.
On Unix, the following files are consulted:
/.hg/hgrc (per-repository)
$HOME/.hgrc (per-user)
/etc/mercurial/hgrc (per-installation)
/etc/mercurial/hgrc.d/*.rc (per-installation)
/etc/mercurial/hgrc (per-system)
/etc/mercurial/hgrc.d/*.rc (per-system)
/default.d/*.rc (defaults)
On Windows, the following files are consulted:
/.hg/hgrc (per-repository)
%USERPROFILE%.hgrc (per-user)
%USERPROFILE%\Mercurial.ini (per-user)
%HOME%.hgrc (per-user)
%HOME%\Mercurial.ini (per-user)
HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial (per-installation)
\hgrc.d*.rc (per-installation)
\Mercurial.ini (per-installation)
/default.d/*.rc (defaults)
For up-to-date versions of mercurial, you should use the XDG compatible location. Unless you explicitly set XDG_CONFIG_HOME the settings should go into the file:
~/.config/hg/hgrc
Less clutter in your home directory and ~/.config/hg/ can also be used for files like a common hgignore
Related
I have installed Mercurial from the Ubuntu package repository. However I don't know how to enable extensions (q* commands). How should I do that? The help shows that
enabled extensions:
style (no help text available)
I want to enable mq and hgk.
Enable extensions in hgrc.
extensions
Mercurial has an extension mechanism for adding new features. To
enable an extension, create an entry for it in this section.
If you know that the extension is already in Python's search path, you
can give the name of the module, followed by =, with nothing after the
=.
Otherwise, give a name that you choose, followed by =, followed by the
path to the .py file (including the file name extension) that
defines the extension.
...
Example for ~/.hgrc:
[extensions]
# (the mq extension will get loaded from Mercurial's path)
mq =
# (this extension will get loaded from the file specified)
myfeature = ~/.hgext/myfeature.py
http://www.selenic.com/mercurial/hgrc.5.html#extensions
You can also enable an extension without editing the hgrc, if you want to do it one off. [Source]
hg --config extensions.histedit= --help
The documentation of both extensions shows how to enable them : MQ, Hgk.
The usual way to enable an extension is to add a line to your .hgrc (or Mercurial.ini on some Windows system). It is explained in the hgrc documentation.
In your following case, add this to your configuration file :
[extensions]
mq =
hgk=
You can put it in your global configuration file or the repository one, depending if you want to have the extensions activated in every repository or just a specific one.
The output of hg help extensions starts with
Using additional features
Mercurial has the ability to add new features through the use of
extensions. Extensions may add new commands, add options to existing
commands, change the default behavior of commands, or implement hooks.
Extensions are not loaded by default for a variety of reasons: they can
increase startup overhead; they may be meant for advanced usage only; they
may provide potentially dangerous abilities (such as letting you destroy
or modify history); they might not be ready for prime time; or they may
alter some usual behaviors of stock Mercurial. It is thus up to the user
to activate extensions as needed.
To enable the "foo" extension, either shipped with Mercurial or in the
Python search path, create an entry for it in your configuration file,
like this:
[extensions]
foo =
You may also specify the full path to an extension:
[extensions]
myfeature = ~/.hgext/myfeature.py
So just add
[extensions]
mq =
to enable the MQ extension.
Is there any way to centrally manage mercurial settings for all users of a repository? Are there additional [existing] tools, add-ons, extensions, etc for this?
My use case
We have a repository that includes a few Excel, Word etc files that constantly cause trouble with merging.
With [merge-patterns] entries a la **.doc = internal:fail I can specify the intended behaviour, but I have to set this up for each and every user.
I want this to propagate automatically to anyone who clones the repository.
Environment
We use Kiln 2.6 hosted on our own Windows Server and TortoiseHg 2.2 on our Windows clients.
As far as I know, this possibility doesn't exists in Mercurial and I'm not aware of any extension which let you clone the .hgrc along with the other files.
However, you can do some things to "ease" the process of setup for each user.
Provide a template hgrc in the repository
You can add a "template" .hgrc in the repository. When a user clone the repo, the only thing he as to do is move the template to the right place.
Change the system wide hgrc
If you have some kind of Configuration management system for your clients, you can set the system wide configuration file for each of your users. There's various way of doing it. From the documentation:
(Windows) <install-dir>\Mercurial.ini or
(Windows) <install-dir>\hgrc.d\*.rc or
(Windows) HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial
Per-installation/system configuration files, for the system on which
Mercurial is running. Options in these files apply to all Mercurial
commands executed by any user in any directory. Registry keys contain
PATH-like strings, every part of which must reference a Mercurial.ini
file or be a directory where *.rc files will be read. Mercurial checks
each of these locations in the specified order until one or more
configuration files are detected. If the pywin32 extensions are not
installed, Mercurial will only look for site-wide configuration in
C:\Mercurial\Mercurial.ini.
But obviously this depends on the way your clients are set up, so you will have to find the solution yourself. For example you can:
Set these files on the computer installation
Provide an executable which configure this that every user must run
Configure your in-house configuration management system to set up this on the next computer start
Change the roaming user profile if they have one.
You can use the projrc extension to push a project configuration file to others. It requires that the clients enable the extension first and that they fully trusts the server.
By default on Windows XP Mercurial stores the .hgrc file in (well, in my case) c:\Documents and Settings\srooks\. How can I change that location, and have it look for .hgrc file in, for example, c:\Configuration_Files ?
Can it be done at all?
Set up the HGRCPATH environment variable with the path to the configuration file.
You can move file to c:\Configuration_Files and create link to it in "Documents And Settings" folder. See mklink command.
Let's say I have a tarball of all my vim config - everything normally inside ~/.vim (plugins, autoload, colours, all that stuff), and a vimrc file. I extract this to a directory somewhere. So in the directory where I am ($PWD), there is a "vim" folder and a "vimrc" file. (note: this directory will be read-only, so vim shouldn't try to write into it).
What command-line arguments or environment variables can I give to vim to ensure that all my plugins, syntax, etc is loaded as well as the vimrc, in the same order as they normally would if they were located in ~/.vim and ~/.vimrc
As a bonus, I'd like to ignore the host computer's ~/.vimrc and ~/.vim if possible (but this is not mandatory).
If you're wondering why I don't just chuck the files in ~/.vimrc and ~/,vim, I'm trying to package up my own vim configuration and take it with me. I don't want to clobber the vim config of the computer I'm using, I just want to start a vim session with my config.
I have a portable .vim folder exactly as you described, this is how I have set it up:
Put your portable .vimrc file inside your .vim folder.
Add the following lines to the start of your portable .vim/.vimrc:
" set default 'runtimepath' (without ~/.vim folders)
let &runtimepath = printf('%s/vimfiles,%s,%s/vimfiles/after', $VIM, $VIMRUNTIME, $VIM)
" what is the name of the directory containing this file?
let s:portable = expand('<sfile>:p:h')
" add the directory to 'runtimepath'
let &runtimepath = printf('%s,%s,%s/after', s:portable, &runtimepath, s:portable)
Start vim by using: vim -u /path/to/portable/vim/.vimrc.
On Unix & Linux systems (and maybe Windows) Vim uses the $HOME environment variable to locate the .vimrc file and .vim directory. So you can cd into the directory where you have your custom versions and start vim or gvim like this:
HOME=. vim files....
This "vimrc File and Vim Runtime Directories" screencast might be useful, as well as the vim documentation for 'runtimepath', which states the following:
This is a list of directories which will be searched for runtime files:
filetype.vim filetypes by file name |new-filetype|
scripts.vim filetypes by file contents |new-filetype-scripts|
autoload/ automatically loaded scripts |autoload-functions|
colors/ color scheme files |:colorscheme|
compiler/ compiler files |:compiler|
doc/ documentation |write-local-help|
ftplugin/ filetype plugins |write-filetype-plugin|
indent/ indent scripts |indent-expression|
keymap/ key mapping files |mbyte-keymap|
lang/ menu translations |:menutrans|
menu.vim GUI menus |menu.vim|
plugin/ plugin scripts |write-plugin|
print/ files for printing |postscript-print-encoding|
spell/ spell checking files |spell|
syntax/ syntax files |mysyntaxfile|
tutor/ files for vimtutor |tutor|
And any other file searched for with the |:runtime| command.
The defaults for most systems are setup to search five locations:
1. In your home directory, for your personal preferences.
2. In a system-wide Vim directory, for preferences from the system
administrator.
3. In $VIMRUNTIME, for files distributed with Vim.
*after-directory*
4. In the "after" directory in the system-wide Vim directory. This is
for the system administrator to overrule or add to the distributed
defaults (rarely needed)
5. In the "after" directory in your home directory. This is for
personal preferences to overrule or add to the distributed defaults
or system-wide settings (rarely needed).
My solution isn't quite the same but could be adapted pretty easily.
I have my Vim setup on my workstation and it's shared through regular Windows file sharing. I have this batch file that I can launch from any other computer in the building (and there's an install of Vim on another network share since most workstations don't even have Vim installed). I just run this batch file and am in my happy place.
set MYWORK=\\my_pc\work
set RCBASE=%MYWORK%\personal\utilities\tom.
start \\server\software\vim\vim73\gvim.exe -u %RCBASE%vimrc -U %RCBASE%gvimrc
So basically the adaptation would put the batch file, shell script, or otherwise into the archive you're unpacking and launch the system vim with your local files.
I'd like to keep two ~/.hgrc files: ~/.hgrc and ~/.hgrc.local – one with "standard" settings (eg, username), the other with machine-specific settings (eg, setting a graphical merge tool).
How can I do this with hg?
For example, this is how I do it with Vim:
# ~/.vimrc
syntax enable
source ~/.vimrc.local
Then:
# ~/.vimrc.local
let work_code = 'code/work/.*'
if expand('%:p:h') =~ work_code ... fi
There's a not-often used %include directive in mercurial 1.3 and later:
From man hgrc:
A line of the form %include file will include file into the current
configuration file. The inclusion is recursive, which means that
included files can include other files. Filenames are relative to the
configuration file in which the %include directive is found.
so go with:
%include ~/.hgrc.local
and you should be good to go.
I solve this problem for all my "dot files" in a similar way. On login my shell checks a list of files (hgrc, vimrc, ....) and checks if any of them is older than ${that_name}.global or ${that_name}.local. If it is - cat ${that_name}.{global,local} > ${that_name}. Simple and works great so far. While there's a "better" way (using %include) sometimes processing the config files manually has advantages - for example it will work with mercurial pre-1.3.
Mercurial checks for a number of configuration files with a specific priority. This way you can have global, user-specific and repository-specific settings.
Mercurial version >= 1.4 has a hg help config command which describes this in a nice overview:
$ hg help config
Configuration Files
Mercurial reads configuration data from several files, if they exist. Below we list the most specific file first.
On Windows, these configuration files are read:
- "<repo>\.hg\hgrc"
- "%USERPROFILE%\.hgrc"
- "%USERPROFILE%\Mercurial.ini"
- "%HOME%\.hgrc"
- "%HOME%\Mercurial.ini"
- "C:\Mercurial\Mercurial.ini"
- "HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial"
- "<install-dir>\Mercurial.ini"
On Unix, these files are read:
- "<repo>/.hg/hgrc"
- "$HOME/.hgrc"
- "/etc/mercurial/hgrc"
- "/etc/mercurial/hgrc.d/*.rc"
- "<install-root>/etc/mercurial/hgrc"
- "<install-root>/etc/mercurial/hgrc.d/*.rc"
The configuration files for Mercurial use a simple ini-file format. A configuration file consists of sections, led by a "[section]" header and followed by
"name = value" entries:
[ui]
username = Firstname Lastname <firstname.lastname#example.net>
verbose = True
This above entries will be referred to as "ui.username" and "ui.verbose", respectively. Please see the hgrc man page for a full description of the possible
configuration values:
- on Unix-like systems: "man hgrc"
- online: http://www.selenic.com/mercurial/hgrc.5.html
You can list your current settings with hg showconfig.
Mercurial will look in several different locations for hgrc files and will load them if present. For system-wide configuration the standard (on UNIX) would be to use /etc/mercurial/hgrc.
See the files section of the hgrc man page for more information.