Link to QuickStart for setting the username
|Deletions are marked like this.||Additions are marked like this.|
|Line 6:||Line 6:|
=== Configuring the username ===
If hg says '''No username found, using 'user@hostname instead'''' when you make a commit, then you need to configure your username. Please see QuickStart for help on this.
Which revision have I checked out?
Use the [:Parent:parent] command ([:TutorialClone] shows an example call).
What can I configure in Mercurial
See in MercurialIni.
Configuring the username
If hg says No username found, using 'user@hostname instead' when you make a commit, then you need to configure your username. Please see QuickStart for help on this.
I get an error while cloning a remote repository via ssh
If your remote repository is cloned thusly
hg clone ssh://USER@REMOTE/path/to/repo
And, you find that after successful ssh authentication you get the error message remote: abort: repository path/to/repo not found! , then you need to know the following:
Mercurial's remote [:Repository:repository] syntax differs from syntax of other well known programs such as rsync, cvs - both of which use a : character to delimit USER@REMOTE from the path component (/path/to/repo).
The path to the remote repository is relative to $HOME of USER. i.e., it is ~USER/path/to/repo .
Remember to use hg -v clone ssh://USER@REMOTE/path/to/repo and observe the remote command being executed via the ssh channel
On the other hand, if the error message is remote: bash: line 1: hg: command not found, the problem is that the environment used by ssh does not have hg in its PATH. There are two ways to deal with this problem:
In your ~/.hgrc file, set a remotecmd value in the [ui] section giving the exact path to hg.
On the server, create a ~/.ssh/environment file that defines an appropriate PATH, and add PermitUserEnvironment yes to /etc/sshd_config.
I get an "ssl required" error message when trying to push changes
If you're on a network you trust you can add
[web] push_ssl = false
in your <repository-name>/.hg/hgrc file. (Taken from HgWebDirStepByStep)
There's a reason for requiring SSL, however. If you do not trust the network you are using do not change this.
I did an hg pull and my working directory is empty!
There are two parts to Mercurial: the [:Repository:repository] and the [:WorkingDirectory:working directory]. hg pull [:Pull:pulls] all new changes from a remote repository into the local one but doesn't alter the working directory.
This keeps you from upsetting your work in progress, which may not be ready to merge with the new changes you've pulled and also allows you to manage [:Merge:merging] more easily (see below about best practices).
To update your working directory, run hg update. If you're sure you want to [:Update:update] your working directory on a pull, you can also use hg pull -u. This will refuse to merge or overwrite local changes.
I want to retrieve an old version of my project, what do I do?
You want hg update -C <version>, which will clobber your current version with the requested version.
You don't want hg revert <version>, which reverts changes in your working directory back to that version, but keeps the current parents for the next checkin. This command exists for undoing changes in current versions, not for working on old versions.
hg status shows changed files but hg diff doesn't!
hg status reports when file contents or flags have changed relative to either [:Parent:parent]. hg diff only reports changed contents relative to the first parent. You can see flag information with the --git option to hg diff and deltas relative to the other parent with -r.
hg export or log -p shows a strange diff for my merge!
The [:Diff:diff] shown by hg diff, hg export and hg log is always against the first [:Parent:parent] for consistency. Also, the files listed are only the files that have changed relative to both parents.
(Are diffs of merges really always against the first parent? Doesn't hg export have a --switch-parent option? It would also be good if the docs would give the rational for hg diff and hg log not having that option (assuming they don't--the man page only mentions it for export).)
I did an hg revert and my working directory still has changes in it!
You've probably done an hg merge (see ["Merge"]), which means your [:WorkingDirectory:working directory] now has two [:Parent:parents] according to hg parents. A subsequent hg revert --all -r . will revert all files in the working directory back to the first (primary) parent, but it will still leave you with two parents (see [:Revert]).
To completely undo the uncommitted merge and discard all [:LocalModifications:local modifications], you will need to issue a hg update -C -r . (note the "dot" at the end of the command).
See also [:TutorialMerge].
I want a clean, empty working directory
The easiest thing to do is run hg clone -U which will create a fresh [:Clone:clone] without checking out a working copy.
If the repository already has a working copy, you can remove it running hg update null.
Note: you might want to copy hgrc file from your old [:Repository:repository].
I committed a change containing nuclear launch codes, how do I delete it permanently?
If you've just [:Commit:committed] it, and you haven't done any other commits or [:Pull:pulls] since, you may be able to use rollback (see ["Rollback"]) to undo the last commit transaction:
$ hg rollback rolling back last transaction
If you've made other changes but you haven't yet published it to the world, you can do something like the following:
$ hg clone -r <untainted-revision> tainted-repo untainted-repo
The strip command in the [:MqExtension:mq extension] may also be useful here for doing operations in place.
This will get you a new repo without the tainted change or the ones that follow it. You can import the further changes with hg export and hg import or by using the TransplantExtension. See TrimmingHistory for possible future approaches.
If you've already pushed your changes to a public [:Repository:repository] that people have [:Clone:cloned] from, the genie is out of the bottle. Good luck cleaning up your mess.
“Judge Tries to Unring Bell Hanging Around Neck of Horse Already Out of Barn Being Carried on Ship That Has Sailed.” - William G. Childs
For more details, see EditingHistory.
I tried to check in an empty directory and it failed!
Mercurial doesn't track directories, it only tracks files. Which works for just about everything, except directories with no files in them. As empty directories aren't terribly useful and it makes the system much simpler, we don't intend to fix this any time soon. A couple workarounds:
- add a file, like "this-dir-intentionally-left-blank"
- create the directory with your Makefiles or other build processes
I want to get an email when a commit happens!
Use the NotifyExtension
I'd like to put only some few files of a large directory tree (home dir for instance) under Mercurial's control, and it is taking forever to diff or commit
Just do a
printf "syntax: glob\n*\n" > .hgignore
or, if you are using 0.7 or below,
printf ".*\n" > .hgignore
This will make [:.hgignore:hg ignore] all files except those explicitly added.
Why is the modification time of files not restored on checkout?
If you use automatic build tools like make or distutils, some built files might not be updated if you checkout an older revision of a file. Additionally a newer [:ChangeSet:changeset] might have an older [:Commit:commit] timestamp due to [:Pull:pulling] from someone else or importing [:Patch:patches] somebody has done some time ago, so checking out a newer changeset would have to make the files older in this case.
If you need predictable timestamps you can use hg archive, which can do something like a checkout in a separate directory. Because this directory is newly created, there is nothing like switching to a different changeset afterwards, therefore the above mentioned problems don't apply here.
Any way to 'hg push' and have an automatic 'hg update' on the remote server?
[hooks] changegroup = hg update >&2
This goes in .hg/hgrc on the remote [:Repository:repository]. Output has to be redirected to stderr (or /dev/null), because stdout is used for the data stream.
How can I store my HTTP login once and for all ?
You can specify the usename and password in the URL like:
Then add a new entry in the paths section of your hgrc file.
How can I do a "hg log" of a remote repository?
You can't. Mercurial accepts only local [:Repository:repositories] for the -R option (see hg help -v log).
> hg log -R http://www.selenic.com/repo/hello abort: repository 'http://www.selenic.com/repo/hello' is not local
The correct way to do this is [:Clone:cloning] the remote repository to your computer and then doing a hg log locally.
This is a very deliberate explicit design decision made by project leader Matt Mackall (mpm). See also http://www.selenic.com/mercurial/bts/issue1025 for the reasoning behind that.
How can I find out if there are new changesets in a remote repository?
To get the [:ChangeSetID:changeset id] of the [:Tip:tipmost] [:ChangeSet:changeset] of a remote [:Repository:repository] you can do:
> hg id -i -r tip http://www.selenic.com/repo/hello 82e55d328c8c
When it changes, you have new changesets in the remote repository.
What can I do with a head I don't want anymore?
The clone command is returning the wrong version in my workspace!
[:Clone] checks out the tip of the default (aka unnamed) branch (see NamedBranches). Ergo, you probably want to keep your main branch unnamed.
Any way to track ownership and permissions?
If you're using Mercurial for config file management, you might want to track file properties (ownership and permissions) too. Mercurial only tracks the executable bit of each file.
Here is an example of how to save the properties along with the files (works on Linux if you've the acl package installed):
# cd /etc && getfacl -R . >/tmp/acl.$$ && mv /tmp/acl.$$ .acl # hg commit
This is far from perfect, but you get the idea. For a more sophisticated solution, check out etckeeper.
I get a "no space left" or "disk quota exceeded" on push
I get a "no space left" or "disk quota exceeded" on push, but there is plenty of space or/and I have no quota limit on the device where the remote hg repository is.
The problem comes probably from the fact that mercurial uses /tmp (or one of the directory define by environment variables $TMPDIR, $TEMP or $TMP) to uncompress the bundle received on the wire. The decompression may then reach device limits.
You can of course set $TMPDIR to another location on remote in the default shell configuration file, but it will be potentially used by other processes than mercurial. Another solution is to set a hook in a global [:hgrc:.hgrc] on remote. See the description of how to set a [:Hook#tmpdirhook:hook for changing tmp directory] on remote when pushing.