Git Product home page Git Product logo

posh-hg's Introduction

posh-hg

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

Prompt for Hg repositories

The prompt within Hg repositories can show the current branch and the state of files (additions, modifications, deletions) within.

Tab completion

Provides tab completion for common commands when using hg. E.g. hg up<tab> --> hg update

Usage

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.

Installing

  1. Verify you have PowerShell 2.0 or better with $PSVersionTable.PSVersion

  2. Verify execution of scripts is allowed with Get-ExecutionPolicy (should be RemoteSigned or Unrestricted). If scripts are not enabled, run PowerShell as Administrator and call Set-ExecutionPolicy RemoteSigned -Confirm.

  3. 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.

  4. Clone the posh-hg repository to your local machine.

  5. From the posh-hg repository directory, run .\install.ps1.

  6. Enjoy!

Changes to hg command

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.

The Prompt

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 of hg 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)

Additional HG aliases

  • hg pu $branch - pull and update to branch. If branch is omitted (hg pu) then update to latest in current branch
  • hg pr - pull and rebase (requires rebase extension)
  • hg pm $branch - pull and merge with branch
  • hg prp - pull, rebase and push
  • hg c - clean and purge working directory
  • hg closebranch $branch $comment - close a branch with closing comment without updating to that branch
  • hg closemerge $branch $comment - run closebranch and then merge with that branch

Based on work by:

posh-hg's People

Contributors

bmsullivan avatar dahlbyk avatar dfjacobs avatar ekroon avatar eugeneduvenage avatar jasverix avatar jbogard avatar jeremyskinner avatar jordanmorris avatar jpoehls avatar jrsconfitto avatar matthewrfindley avatar maxslimmer avatar nathanpalmer avatar petemill avatar pheeria avatar rstuven avatar vcaraulean avatar woodyza avatar

Watchers

 avatar

Forkers

ksawerykarwacki

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.