How do I get the latest Mercurial tag from within Powershell

Question:

If i run the following command from a DOS prompt:

hg parents –template {latesttag}

then I get the latest tag value returned as expected. However if I run the same command from within a powershell console I get the following error:

hg parents: option -i not recognized

I need the command to run in powershell so I can get it’s results as a variable to use. Any idea what I need to do to get the command running?

Answer:

You should just need to surround the argument to --template in quotes so that Powershell knows it’s a string:


Sometimes, however, with the way Powershell parses things you have to make doubly sure that double-quotes survive (such as passing an argument that contains spaces but should be 1 argument instead of many, like paths or a longer template):

Source:

How do I get the latest Mercurial tag from within Powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply