Inspired by the Posh-Git project (http://github.com/dahlbyk/posh-git), Posh-Hg provides a set of PowerShell scripts which provide Mercurial/PowerShell integration
The prompt within Hg repositories can show the current branch and the state of files (additions, modifications, deletions) within.
Provides tab completion for common commands when using hg.
E.g. hg up<tab>
--> hg update
See profile.example.ps1
as to how you can integrate the tab completion and/or hg prompt into your own profile.
Prompt formatting, among other things, can be customized using the $PoshHgSettings
variable.
-
Verify you have PowerShell 2.0 or better with $PSVersionTable.PSVersion
-
Verify execution of scripts is allowed with
Get-ExecutionPolicy
(should beRemoteSigned
orUnrestricted
). If scripts are not enabled, run PowerShell as Administrator and callSet-ExecutionPolicy RemoteSigned -Confirm
. -
Verify that
hg
can be run from PowerShell. If the command is not found, you will need to add a hg alias or add%ProgramFiles%\TortoiseHg
to your PATH environment variable. -
Clone the posh-hg repository to your local machine.
-
From the posh-hg repository directory, run
.\install.ps1
. -
Enjoy!
PowerShell is not very good at handling errors from HG, so this extension will override hg with a PowerShell function that handles errors. Now, you can run commands like this:
hg pull ; hg merge feature/branch ; hg commit -m "Merge with feature" ; hg push
and if one step fails (for instance the merge) then PowerShell will not execute the following steps.
PowerShell generates its prompt by executing a prompt
function, if one exists. posh-hg defines such a function in profile.example.ps1
that outputs the current working directory followed by an abbreviated hg status
:
C:\Users\JSkinner [default]>
By default, the status summary has the following format:
[{HEAD-name} +A ~B -C ?D !E ^F <G:H>]
{HEAD-name}
is the current branch, or the SHA of a detached HEAD- Cyan means the branch matches its remote
- Red means the branch is behind its remote
- ABCDEFGH represent the working directory
+
= Added files~
= Modified files-
= Removed files?
= Untracked files!
= Missing files^
= Renamed files<G:H>
= Current revision information matching the output ofhg log -r . --template '{rev}:{node|short}'
Additionally, Posh-Hg can show any tags and bookmarks in the prompt as well as MQ patches if the MQ extension is enabled (disabled by default)
hg pu $branch
- pull and update to branch. If branch is omitted (hg pu
) then update to latest in current branchhg pr
- pull and rebase (requires rebase extension)hg pm $branch
- pull and merge with branchhg prp
- pull, rebase and pushhg c
- clean and purge working directoryhg closebranch $branch $comment
- close a branch with closing comment without updating to that branchhg closemerge $branch $comment
- runclosebranch
and then merge with that branch
- Jeremy Skinner, http://www.jeremyskinner.co.uk/
- Keith Dahlby, http://solutionizing.net/
- Mark Embling, http://www.markembling.info/