Mercurial
Misc
hg
config file
- Windows: C:\Users\<User>\mercurial.ini
- Linux: ~/.hgrc
Username/Mail
If you are using the commandline, make sure to add to your config file:
[ui] username = John Doe <john@example.com>
aliases
mercurial command line log as one line per commit
Windows: add:
[alias] logline = log --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n"
Linux: add: (the only difference to Windows is " vs '
[alias] logline = log --template '{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n'
Weird formatting of status output
If you get something which looks like bad readable links if yo do
hg status
then you probably don't want that. I do not understand the reason for it and I am not sure my "solution" is the correct way to do it. But it works:
[alias] status = status --template status
ssh
Normally you will want to use the default OS ssh. So add the following to the config file:
[ui] ssh = ssh -C
The "-C" seems to enable compression. Not sure yet, but I keep it for now.
IF you can normally ssh to the other machine with
ssh v-rooster
then now you should be able to do a
hg -v push ssh://v-rooster/work/repo1/
or pull or clone or whatever you want to do.
You can give a name and/or port like this:
hg -v push ssh://user@v-rooster:port/work/repo1/
but it would make more sense to configure your port to connect correctly. Example under Windows 10, modify your C:\Users\<user>\.ssh\config
Host v-rooster HostName 1.2.3.4 User meaMario Port 22 IdentityFile C:\Users\<user>\.ssh\id_rsa-no-pw
paths
If you don't want to write the server and path all the time, add the following to the config file:
[paths] default = ssh://v-deb-dev2/work/src/ v-deb-dev1 = ssh://v-deb-dev1/work/src/ v-deb-dev2 = ssh://v-deb-dev2/work/src/ v-deb-dev3 = ssh://v-deb-dev3/work/src/
You guessed it, 'default' is the entry which is used, when you don't give a remote target. It is NOT necessary to have it as normal path AND default, but I like it that way.
If you want to see these with hg:
hg paths
If you clone a repository, your default is of course the source of the clone.
copy/move
use
hg cp source target hg mv source target hg mv oldFile NewFile hg mv project directory
empty work directory
Normally you have all the history in the .hg directory and than a checked out version directly in the repositories root directory.
If you want it to be empty, for example because it is just like a server, no need need for a working directory with checkout:
hg update null
Only the .hg directory will remain.
TortoiseHG
Why does hg not work?
After you installed TortoiseHG, add the path to the install directory of TortoiseHG to the PATH variable. (Start/Settings/System/About/System Info/Advanced system settings/Environment Variables...)
Questions
Get a managed file back which I deleted
I deleted a file and just want Mercurial to get it again:
hg revert <file>
Manage hgrc with Mercurial
Everything in .hg dies NOT have a history in Mercurial. Depending on your circumstances, you want the history of hgrc or even be able to copy/paste another hgrc to your current installation without a hassle. You can do it:
- in the main directory of your Mercurial repository create a directory called ".hg-configs-managed".
- move your current .hg/hgrc to .hg-configs-managed/hgrc-MY-CORPORATION-PC01
- create a link .hg/hgrc which points to .hg-configs-managed/hgrc-MY-CORPORATION-PC01
- put .hg-configs-managed/hgrc-MY-CORPORATION-PC01 into Mercurial ("hg add...")
- repeat this for every installation, so you'll get a lot of files in .hg-configs-managed but only one in hgrc
Create the link with Linux
cd .hg ln -s ../.hg-configs-managed/hgrc-MY-CORPORATION-PC01 hgrc
Create the link with Windows 10
cd .hg mklink /H hgrc ..\.hg-configs-managed\hgrc-MY-CORPORATION-PC01