I'm using both mercurial and git for different projects and like them both. What I find a bit annoying about mercurial is that "hg status" shows paths relative to the repository root, not to the current directory(unlike git). Can this behaviour be tweaked somehow?
The usual workaround is to run:
hg status $(hg root)
For older versions of Mercurial, prior to 1.7, you could use this hack, adding to your repository's ".hg/hgrc" file:
[alias]
sst = status /path/to/root
That needs the alias extension enabled, so you may have to add "alias=" to your ~/.hgrc file.
Starting with Mercurial 1.7, the alias extension learned about the "!" escape to use shell commands, so you can now have a global alias that does this:
[alias]
sst = !hg status $(hg root)
Don't use st = !hg status $(hg root)
, since that creates an infinite loop, running hg status over and over. It looks like a bug in the alias parsing - if you want to alias hg status
to show the path from the root, then the following incantation works in the global $HOME/.hgrc:
[alias]
__mystatus = status
st = !hg __mystatus $(hg root)
To see workspace status relative to the current directory you can always use "." (a single dot) as the argument of "hg status", i.e.:
% hg root # root of the workspace
/work/foo
% pwd # current directory is <root>/src
/work/foo/src
% hg status # no argument, see all files
M etc/foo.conf # all files are shown with paths
M src/foosetup.c # relative to workspace root
%
The difference when you explicitly ask for the current working directory is that the relative filename paths use that as their starting point:
% hg status . # see only files under current path
M foosetup.c
%