I have a repository that needs some [hostfingerprints] key to be working.
They told me to add an --insecure flag so it doesn't ask me for the key, but it didn't work.
hg clone --insecure pathToRepository PathForTheFolderToClone
I tried instead to give the property i should have in a hgrc file, when the repository is cloned:
[hostfingerprints]
hg.website.com = 88:88:88.....
But how do you use this property?. It tells me it has bad syntax:
*`hg clone --config hostfingerprints.hg.website.com = 88:88:88:88:88...88:88 pathToRepository PathForTheFolderToClone`*
Here is the error:
*abort: malformed --config option: 'hostfingerprints.hg.website.com' (use --config section.name=value)*
How do i write it, then?
And why the --insecure flag doesn't work in the first place?
Set the hostfingerprint in your global config file, then do a normal clone. --insecure will no longer be needed.
From the hgrc docs:
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)
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)
\Mercurial.ini (per-installation)
\hgrc.d*.rc (per-installation)
HKEY_LOCAL_MACHINE\SOFTWARE\Mercurial (per-installation)
hostfingerprints looks like:
[hostfingerprints]
hg.intevation.org = fa:1f:d9:48:f1:e7:74:30:38:8d:d8:58:b6:94:b8:58:28:7d:8b:d0
Related
I added the convert extension (with no path) to my /home/user/.hgrc file, but it is not working:
$ hg convert source_r56 source_r56_fixed --filemap exclude.filemap
hg: unknown command 'convert'
'convert' is provided by the following extension:
convert import revisions from foreign VCS repositories into Mercurial
use "hg help extensions" for information on enabling extensions
I ran "hg help extensions" and realized that none of the enabled extensions in the file are showing as enabled.
I tried setting it in the source_r56/.hg/hgrc as well to no avail.
Update:
$ cat ~/.hgrc
[ui]
username = jetimms <jetimms#jetimms>
verbose = True
[extentions]
convert =
progress =
rebase =
[alias]
ssh = ssh -C
$ cat ./.hg/hgrc
[paths]
default = /home/jetimms/source
[extentions]
convert =
$
(BTW: source_r56 was cloned from a repository called "source".)
Perhaps to better answer the question about whether I am having the same problems with other extensions, I have included part of the results from "hg help extensions" regarding disabled extensions. Here I only note the ones listed above in the the ~/.hgrc. As noted in the comments, I have not used any other extensions.
$ hg help extensions
Using additional features
...
disabled extensions:
...
convert import revisions from foreign VCS repositories into Mercurial
...
progress show progress bars for some actions
...
rebase command to move sets of revisions to a different ancestor
$
You mispelled the word extensions in your .hgrc. Change [extentions] to [extensions] and you're set.
I use Mercurial Queues to work with patches.
There was no .hgignore initially.
I'm not sure if I first created an MQ patch and then created my .hgignore or the other way round.
(By "creating a patch" I mean hg qnew patch_name -m "...")
Anyway, I made some changes to .hgignore after I created the MQ patch.
When I did hg qrefresh; hg export qtip I got the changed contents of .hgignore also in my patch.
So, tried adding an .hgignore entry to .hgignore itself. But that didn't work. The changes persisted.
So, I tried hg forget .hgignore and this made a bigger mess. It nows shows that I deleted .hgignore in my patch. Like so:
--- a/.hgignore
+++ /dev/null
- all
- the lines of .hgignore
- the lines of .hgignore
How do I resolve this problem?
I just want .hgignore to be part of my local repo and help in not tracking some files.
.hgignore is designed to be tracked by Mercurial (doc). The standard way to ignore files in local clone only is to use ui.ignore setting:
# .hg/hgrc
[ui]
ignore = /path/to/repo/.hg/hgignore
If you have multiple local ignore files then you can write
[ui]
ignore.first = /path/to/repo/.hg/firstignore
ignore.second = /path/to/repo/.hg/secondignore
Additional global ignore files can be configured in this way:
[ui]
ignore.first = /path/to/repo/.hg/firstignore
ignore.second = /path/to/repo/.hg/secondignore
ignore.third = ~/thirdignore
All settings live in hgrc file. More details here:
hgrc file location: doc
ui.ignore setting reference: doc
about .hgignore files: doc
original recipe: Tips And Tricks
I would like parent directories of projects to include an hgrc file that a repo in that folder inherits from, e.g.
~/work/
~/work/hgrc
~/work/project1/
~/work/project2/
~/personal/hgrc
~/personal/project1
~/personal/project2
~/personal/project3
Any project in work should inherit from work/hgrc, and any in personal should inherit from personal/hgrc. I was thinking of adding a script to ~/.hgrc that on clone would search for any hgrc files in parent directories and %include them if they exist, but this has the uglyness that if I add an hgrc below it after I clone it it won't be included. Only a 5% of the time consideration, but still...
How about putting:
%include ../hgrc
inside each repo's .hg/hgrc? You could even do that automatically but putting this in your systemwide /etc/mercurial/hgrc:
[hooks]
post-clone = echo '%include ../hgrc' >> .hg/hgrc
I've not tested that hook. :)
Following #Ry4an's suggestion, here is an example that works for me. I add this to my ~/.hgrc file so it works everywhere.
[hooks]
# This hook adds "%include ../.hgrc" to .hg/hgrc if the .hgrc file exists in
# the top level. This allows one to store a set of paths for example.
# See
update = if [ -e .hgrc ] && touch .hg/hgrc \
&& ! grep -q '%include \.\./\.hgrc' .hg/hgrc; then \
echo '%include ../.hgrc' >> .hg/hgrc; \
fi
This hook adds the line %include ../.hgrc to the .hg/hgrc file iff the file .hgrc exists in the top level of the repo. Note that by using the update hook, we bypass the issue of the with post-clone clone hook of having to try to figure out the directory name of the target clone from environmental variables.
I'm looking for a way to set .hgrc configuration items without actually editing the text file. I'm trying to standardize the setup of the hgrc across multiple developers and I would like a command like
hg --config ui.username=foo
but which also saves that config change into the hgrc file.
It seems like this should be something that should be supported directly in the vanilla hg command, but I can't find it anywhere.
Someone -- either you or Mercurial -- will have to edit the configuration file if you want the config change to be saved :-)
And if you can call Mercurial with
hg --config ui.username=foo
then you should also be able to do
echo '[ui]' >> ~/.hgrc
echo 'username = foo' >> ~/.hgrc
which will save the config change, not matter how the ~/.hgrc file happens to look like (it is okay to have multiple [ui] sections).
Mercurial 3.0 and later has the hg config --edit command that opens an editor with the user config file. Still not quite what you're asking for, but at least this makes it easier to edit the file interactively.
This form:
hg --config ui.username=foo
Doesn't save anything. It sets the value for just the one run.
Also you can use /etc/mercurial/hgrc for system wide settings if that helps anything.
There is an extension that helps with this, https://bitbucket.org/alu/hgconfig/wiki/Home
After installing that hgext, you can do things like this.
% hg showconfig paths
paths.default=ssh://hg#bitbucket.org/alu/hgconfig
% hg config paths.upstream $(hg showconfig paths.default)
% hg config paths.default $(hg showconfig paths.default | sed 's|/alu/|/nassrat/|')
% hg showconfig paths
paths.default=ssh://hg#bitbucket.org/nassrat/hgconfig
paths.upstream=ssh://hg#bitbucket.org/alu/hgconfig
The only gotcha is this overrides the builtin config command, you can either tweak the code to change the command name, or live with it. Fortunately, it probably would not matter if your use case is simply to set and get specific configs.
In git, there is a command 'git bundle' which bundles a git repository into 1 big file.
Is there the equivalent command for 'hg'?
Hg supports the same command. Here's the help for it:
U:\>hg help bundle
hg bundle [-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]
create a changegroup file
Generate a compressed changegroup file collecting changesets not known to
be in another repository.
If you omit the destination repository, then hg assumes the destination
will have all the nodes you specify with --base parameters. To create a
bundle containing all changesets, use -a/--all (or --base null).
You can change compression method with the -t/--type option. The available
compression methods are: none, bzip2, and gzip (by default, bundles are
compressed using bzip2).
The bundle file can then be transferred using conventional means and
applied to another repository with the unbundle or pull command. This is
useful when direct push and pull are not available or when exporting an
entire repository is undesirable.
Applying bundles preserves all changeset contents including permissions,
copy/rename information, and revision history.
options:
-f --force run even when the destination is unrelated
-r --rev a changeset intended to be added to the destination
-b --branch a specific branch you would like to bundle
--base a base changeset assumed to be available at the destination
-a --all bundle all changesets in the repository
-t --type bundle compression type to use (default: bzip2)
-e --ssh specify ssh command to use
--remotecmd specify hg command to run on the remote side
The command for the reverse operation is hg unbundle.