简体   繁体   中英

Mercurial alias doesn't output to editor

I often end up needing to see the difference between my current commit + changes and the previous one. I do this by hg diff --rev .^

Since I do this a lot, I made an alias for it, which I called pdiff . Howver, when I run this, if the differences takes more space than the terminal, I can't navigate using vim bindings, it puts all the output in terminal.

Is there a way to get it to act the same as typing out the full command?

You have (for Mercurial 3, I suppose for earlier versions - too) wrong syntax for revset "N-th parent of". From hg help revsets

 "x^n" The nth parent of x, n == 0, 1, or 2. 

If you have to use OS-level features, you have to read about shell aliases

An alias can start with an exclamation point (!) to make it a shell alias. A shell alias is executed with the shell and will let you run arbitrary commands.

and your pdiff will be something like

pdiff = !$HG diff -r .^$1 | less

and used as pdiff (0|1|2) for getting changes from second|first parent of working dir or working dir directly

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM