Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to turn off hg status -S

Tags:

mercurial

I want my default hg status to recirse into subrepos. This is easy enough to do in .hgrc:

[alias]
status = status -S

But I want to have another alias, say hg status-no-subrepo, that does not.

[alias]
status-no-subrepo = status

Unfortunately, this does not work, because status-no-subrepo --expands-to--> status --expands-to--> status -S. I imagine there is something to stop the recursion at that point.

Any ideas?


By the way, this seems to be a violation of one of Glew's Rules: any command line option that can be turned on should be possible to turn off. Possibly -S == -S:1, -S:0 to turn off.

like image 807
Krazy Glew Avatar asked Jan 20 '26 12:01

Krazy Glew


2 Answers

Simple, have your original alias under a different name

[alias]
sstat = status -S

Not the answer you were looking for, I know, but it's easy. It also means that you don't get confused if you move to a system without your alias installed (you'll get a proper error to remind you), and others don't get confused when they do things in your account.

I cant tell you how many times I've helped someone out just to get annoyed that they've aliased ls to ls -l or rm to rm -i.

In general I see overriding common commands with personalised versions as ill-conceived.

like image 176
Paul S Avatar answered Jan 22 '26 03:01

Paul S


You need to disable the status alias when running status-no-subrepo.

[alias]
status = status -S
status-no-subrepo = !$HG --config alias.status=status status $@

I don't use subrepos, but I tested similar functionality with my glog alias.

glog = !$HG log --graph --branch $($HG branch) $@
glog-all-branches = !$HG --config alias.glog=glog glog $@

The ! tells Mercurial this is a shell command, not a Mercurial sub-command. When running a shell command, Mercurial sets $HG to the path to the running hg executable. Arguments after the alias are not passed into shell commands by default, so $@ adds them back. This allows you to run commands like hg status-no-subrepo --no-status to show changes without subrepos and hide the status prefix.

like image 37
robert Avatar answered Jan 22 '26 01:01

robert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!