Mercurial error: Failed to import extension hgext.gpg - mercurial

I trying to enable gpg extension that comes with Mercurial to sign my change sets.
I am using the following two lines to enable the extension in the hgrc file:
[extensions]
hgext.gpg= FILEPATH
After I have added these lines to the hgrc file, I am getting the following error:
***Failed to import extension hgext.gpg from ...location...: Non-ASCII character '\xf3' in file ...location... on line 1,
but no encoding declared; see http://www.python.org/dev/peps/pep-0263.html for details
Can someone help me?

OK, I read GPG Extension Wiki
This extension is currently being distributed along with Mercurial
and Configuration section also
Configure your .hgrc to enable the extension by adding following lines:
[extensions]
hgext.gpg=
(see difference with yours)

Related

How to write Hg mercurial commit message with space tab and korean?

I'm using Hg mercurial 2.8.2.
My problem is about commit message when I commit using command line.
Like "hg ci -m 'my test 가나다'" , mercurial rejects commit (space tab and Korean).
How can I solve this problem? Do I have to re-install with another version?
If I have to revise specific config file, please let me know where it is.
(ps, My platform is 'Win7 - 64bit')
Thanks.
You need to set HGENCODING system environment variable to utf-8
To do that open Windows Control Panel -> System -> Advanced System Settings -> Environment Variables
Add New variable and enter following values:
Variable name HGENCODING
Variable value utf-8
Additional links about encoding issue:
Mercurial Encoding Strategy
Mercurial Character Encoding on Windows

TortoiseHg: ‘hg’ is not recognized as an internal or external command, operable program or batch file

I'm unable to find the command line tools in Mercurial-TortoiseHg version 2.7.2. I checked for hg.exe file and it is present at C:\Program Files\TortoiseHg path but whenever I try running the command it fails and throws the error :
‘hg’ is not recognized as an internal or external command, operable program or batch file.
I have also added it to the windows PATH= ; C:\Program Files\TortoiseHg.
Not sure what else to look for. Please help.
Notes:
As mentioned in "Mercurial not working after TortoiseHg update", TortoiseHg v2.X.X no longer uses the hg command, but rather thg.
That means your PATH might not be updated properly to reference hg.exe of TortoiseHg.
to update your PATH, make sure not add any extra space:
set PATH=%PATH%;C:\Program Files\TortoiseHg
(no space between ';' and 'C:\...')
As mentioned by the OP Sowmya Guru, if you modify the user environment variable, a restart (or at least a new DOS windows) is necessary.
Posting my answer related to vanilla Mercurial install (not 'TortoiseHg') as it was the first page in search results, my solution was to use the 'Mercurial-3.4 (64-bit msi)' installer instead of the 'Mercurial-3.4 (64-bit exe)' from this page.

How to enable Mercurial extensions (such as mq)?

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.

hgrc progress extension not loading

The docs say all I need to do is add this:
[extensions]
progress = # shows progress bar for certain tasks
but when I try to clone this repo it doesn't let me because the extension can't be found. It says it's packaged with 1.5 and later and I'm running 1.9.2:
> hg --version
Mercurial Distributed SCM (version 1.9.2)
(see https://www.mercurial-scm.org for more information)
Any ideas on why it's not loading?
The problem is coming from the "comment" you added on the line. According to the documentation :
Lines beginning with # or ; are ignored and may be used to provide
comments.
You can't put a comment like this where you did. Just replace your config with :
[extensions]
# shows progress bar for certain tasks
progress=
And everything will be fine.
Secondly, as I understand you have activated the extension on the server side ? This extension must be activated on the client side.

Load multiple .hgrc files - ie, some with machine-specific settings?

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.