Is there any way of having mercurial automatically create hgrc, so that I don't have to create it every time I create a repository?
I'd like hgrc to at least contain the following:
[ui]
username = geo
Can this be done?
You can set the username in mercurial.ini or .hgrc in your Home directory and it will automatically be used for all repositories where it's not overridden by a local hgrc.
In TortoiseHg, this can be set using right-click and choosing TortoiseHg/Global Settings....
See the docs.
Related
When running Mercurial I get this error:
t3#des:gem5$ hg qnew my_p.diff
abort: no username supplied (see "hg help config")
the hg help config says:
The configuration files 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
But where is that ini file?
hg help config
These files do not exist by default and you will have to create the
appropriate configuration files yourself: global configuration like
the username setting is typically put into
"%USERPROFILE%\mercurial.ini" or "$HOME/.hgrc" and local configuration
is put into the per-repository "/.hg/hgrc" file.
Assuming your on linux, create the .hgrc file in either your home directory or in the repository dir in question,
dirunderhgcontrol/.hg/.hgrc
Add the info(ui, username, verbose...) you stated in your question to the new file and then give it a try.
I can set my usual email address in my ~/.hgrc file, but is there a way to specify that for one hg project I want to be known as a different name/email (similar to git's .git/config file in the project directory overriding the ~/.gitconfig settings)?
You can create a <repo>/.hg/hgrc file which will override settings in your ~/.hgrc.
See hg help config for more details.
For one of my repositories, it doesn't remember the name of the repository I am pulling and pushing to. I don't have this problem with any of the other repositories on my machine. Is their any way to fix this?
In the .hg folder for the repository with a problem, create or edit hgrc and add:
[paths]
default = path\to\default\push
or from TortoiseHg (1.1.6 for me), go to the Synchronize dialog and click Configure (or just go directly to repository settings and the Synchronize item) and add an alias of "default" with the correct path for your default push/pull repository.
As of version 3.0 there is no "setting" for choosing the default URL. Instead you must create an alias of "default" for the URL that you want.
To do so, from workbench, right click on the repository and select settings. Click Edit File and add a line (see below) that specifies the default path to the desired repository.
default = URL of repository
I have main mercurial repository (A) with 2 folders "depot1" and "depot2" in Windows Machine
Following configuration is done in .hg/hgrc file of A repo.
[ui]
username = praveen
[extensions]
hgext.acl=
[hooks]
changegroup.update = hg update
pretxnchangegroup.acl = python:hgext.acl.hook
[acl]
sources = serve push pull commit
Then I created 2 clones of mercurial A repository. X and Y on windows machines
X .hg/hgrc file is:
[ui]
username = clone1
Y .hg/hgrc file is:
[ui]
username = clone2
My Question:
1- Restrict all push operations from user="clone2".
2- user="clone1" will be able to perform push on only "depot1".
Please suggest me how this configuration is possible.
Thanks,
Praveen
Unfortunately, you're misunderstanding what the username in the [ui] section does. It's strictly a client-side setting that says "If a server asks me for a username for authentication here's what I want to send", so what you have in the ui.username in repos A, X, and Y will have no affect on what remote users can to to/with those repositories.
Instead, you need to use the [acl.allow] and [acl.deny] sections in the Y and X repositories' .hg/hgrc files to specify access controls for them.
The usernames that you use in those section, ('clone1' and 'clone2') in your examples need to be backed by a real authentication system too. The built-in hg-serve doesn't provide one, so you need to be using either ssh or Apache/ISS with a hgweb or hgwebdir. See the publishing repositories wiki page for a great overview.
When I commit something in Mercurial like this:
hg commit -m "username question"
I see this output:
No username found, using 'WindowsVistaAdmin#ChunkyMonkey' instead
ChunkyMonkey is my Windows machine name and obviously WindowsVistaAdmin is the user that I am signed in as on this machine.
How can I set the username to something more respectable, or, at least, more concise?
In your ~/.hgrc (*nix) or mercurial.ini (Windows) file:
[ui]
username = First Last <email#address.com>
(mercurial.ini is in C:\Documents and Settings\[username]\ for XP and lower, C:\Users\[username]\ for Vista and higher. You can also run hgtk userconfig if you have TortoiseHg installed and do it that way.)
you can specify your username on the command line directly if you want to using --config. eg
hg --config ui.username=frymaster -m "comment here" commit
in fact, you can override anything in your .hgrc with this command. just look at your .hgrc and note the format:
[section]
key=val
that translates directly to
hg --config section.key=val
Information from here:
Setting up a username
When you try to run hg commit for the
first time, it is not guaranteed to
succeed. Mercurial records your name
and address with each change that you
commit, so that you and others will
later be able to tell who made each
change. Mercurial tries to
automatically figure out a sensible
username to commit the change with. It
will attempt each of the following
methods, in order:
If you specify a -u option to the hg commit command on the command
line, followed by a username, this is
always given the highest precedence.
If you have set the HGUSER environment variable, this is checked
next.
If you create a file in your home directory called .hgrc, with a
username entry, that will be used
next. To see what the contents of this
file should look like, refer to the
section called “Creating a Mercurial
configuration file” below.
If you have set the EMAIL environment variable, this will be
used next.
Mercurial will query your system to find out your local user name and
host name, and construct a username
from these components. Since this
often results in a username that is
not very useful, it will print a
warning if it has to do this.
If all of these mechanisms fail,
Mercurial will fail, printing an error
message. In this case, it will not let
you commit until you set up a
username.
You should think of the HGUSER
environment variable and the -u option
to the hg commit command as ways to
override Mercurial's default selection
of username. For normal use, the
simplest and most robust way to set a
username for yourself is by creating a
.hgrc file; see below for details.
Here is how my windows /users/xxx/mercurial.ini looks. I don't have to enter username or passwords for anything. Looks like it might be repo specific. I have tortoiseHG installed, not sure if that makes any difference.
[ui]
username=mbroekhuis
[auth]
repo.prefix=http://myrepo
repo.username=mbroekhuis
repo.password=secret
For anyone trying to use HG workbench
settings
user global settings
Edit File
Save