Commits

Kevin Berridge committed 366f6ff

updates posh-hg

  • Participants
  • Parent commits 275c05e

Comments (0)

Files changed (10)

File Microsoft.PowerShell_profile.ps1

 # Modules
-import-module Posh-Hg
+import-module posh-hg
 import-module 'C:\Projects\psake'
 
 set-alias time measure-command
     [string]$path='.', 
     [string]$filter=$null
   )
-  dir -r -path $path -filter $filter | select-string $pattern
+  $excludes = '*.exe', '*.dll', '*.pdb', '*.resx', '*.doc', 
+    '*.pdf', '*.map', '*.bmp', '*.png', '*.jpg', '*.psd',
+    '*.db', '*.jar', '*.zip', '*.fla', '*.gif', '*.sqlite',
+    '*.cache', '*.resources'
+  dir -r -path $path -filter $filter -exclude $excludes |
+    select-string $pattern
 }
 
 function ff([string] $filter) { dir -r -filter $filter }
   hg sl -u $user -d (get-date -format d)
 }
 
+function hgpl {
+  $out = hg pull -u
+  $out
+
+  $matches = $null
+  foreach ($line in $out) {
+    if($line -match "added (\d+) changesets") { break }
+  }
+
+  if ($matches) {
+    hg sl -l $matches[1]
+  }
+}
+
 function cleanvs([switch]$whatif) {
   if ($whatif) {
     ls . -include bin,obj PBS.Libraries -recurse | where{$_ -notmatch '.hg'} | remove-item -recurse -whatif
   Write-Host($cwd) -nonewline -foregroundcolor yellow
 
   # Mercurial Prompt
-  $Global:HgStatus = Get-HgStatus
-  Write-HgStatus $HgStatus
+  Write-VcsStatus
 
   Write-Host
   return "> "
 }
 
-if(-not (Test-Path Function:\DefaultTabExpansion)) {
-    Rename-Item Function:\TabExpansion DefaultTabExpansion
-}
-
-# Set up tab expansion and include hg expansion
-function TabExpansion($line, $lastWord) {
-    $lastBlock = [regex]::Split($line, '[|;]')[-1]
-    
-    switch -regex ($lastBlock) {
-        # mercurial and tortoisehg tab expansion
-        '(hg|thg) (.*)' { HgTabExpansion($lastBlock) }
-        # Fall back on existing tab expansion
-        default { DefaultTabExpansion $line $lastWord }
-    }
-}
-
 # function which serves your psake that understands parameters
 function psglass {
   param (
     [alias("r")]
     [string]$run=$null,
     [alias("c")]
-    [string]$configuration=$null
+    [string]$configuration=$null,
+    [alias("v")]
+    [string]$version=$null
   )
 
   if ($pbenv) { $properties.environment = $pbenv }
   if ($specs) { $parameters.specs = $specs }
   if ($run) { $parameters.run = $run }  
   if ($configuration) { $properties.BuildConfiguration = $configuration }
+  if ($version) { $properties.Version = $version }
 
   $psakeParams = @{ taskList = $taskList; docs = $docs; parameters = $parameters; properties = $properties }
 

File Modules/posh-hg/HgPrompt.ps1

 # For backwards compatibility
 $global:HgPromptSettings = $global:PoshHgSettings
 
-function Write-HgStatus($status = (get-hgStatus)) {
+function Write-HgStatus($status = (get-hgStatus $global:PoshHgSettings.GetFileStatus $global:PoshHgSettings.GetBookmarkStatus)) {
     if ($status) {
         $s = $global:PoshHgSettings
        
           $branchFg = $s.Branch2ForegroundColor
           $branchBg = $s.Branch2BackgroundColor
         }
+
+        if ($status.MultipleHeads) {
+          $branchFg = $s.Branch3ForegroundColor
+          $branchBg = $s.Branch3BackgroundColor
+        }
        
         Write-Host $s.BeforeText -NoNewline -BackgroundColor $s.BeforeBackgroundColor -ForegroundColor $s.BeforeForegroundColor
         Write-Host $status.Branch -NoNewline -BackgroundColor $branchBg -ForegroundColor $branchFg
         
         if($status.Added) {
-          Write-Host " +$($status.Added)" -NoNewline -BackgroundColor $s.WorkingBackgroundColor -ForegroundColor $s.WorkingForegroundColor
+          Write-Host "$($s.AddedStatusPrefix)$($status.Added)" -NoNewline -BackgroundColor $s.AddedBackgroundColor -ForegroundColor $s.AddedForegroundColor
         }
         if($status.Modified) {
-          Write-Host " ~$($status.Modified)" -NoNewline -BackgroundColor $s.WorkingBackgroundColor -ForegroundColor $s.WorkingForegroundColor
+          Write-Host "$($s.ModifiedStatusPrefix)$($status.Modified)" -NoNewline -BackgroundColor $s.ModifiedBackgroundColor -ForegroundColor $s.ModifiedForegroundColor
         }
         if($status.Deleted) {
-          Write-Host " -$($status.Deleted)" -NoNewline -BackgroundColor $s.WorkingBackgroundColor -ForegroundColor $s.WorkingForegroundColor
+          Write-Host "$($s.DeletedStatusPrefix)$($status.Deleted)" -NoNewline -BackgroundColor $s.DeletedBackgroundColor -ForegroundColor $s.DeletedForegroundColor
         }
         
         if ($status.Untracked) {
-          Write-Host " ?$($status.Untracked)" -NoNewline -BackgroundColor $s.WorkingBackgroundColor -ForegroundColor $s.WorkingForegroundColor
+          Write-Host "$($s.UntrackedStatusPrefix)$($status.Untracked)" -NoNewline -BackgroundColor $s.UntrackedBackgroundColor -ForegroundColor $s.UntrackedForegroundColor
         }
         
         if($status.Missing) {
-           Write-Host " !$($status.Missing)" -NoNewline -BackgroundColor $s.WorkingBackgroundColor -ForegroundColor $s.WorkingForegroundColor
+           Write-Host "$($s.MissingStatusPrefix)$($status.Missing)" -NoNewline -BackgroundColor $s.MissingBackgroundColor -ForegroundColor $s.MissingForegroundColor
         }
 
         if($status.Renamed) {
-           Write-Host " ^$($status.Renamed)" -NoNewline -BackgroundColor $s.WorkingBackgroundColor -ForegroundColor $s.WorkingForegroundColor
+           Write-Host "$($s.RenamedStatusPrefix)$($status.Renamed)" -NoNewline -BackgroundColor $s.RenamedBackgroundColor -ForegroundColor $s.RenamedForegroundColor
         }
 
-        if($s.ShowTags -and $status.Tags.Length) {
+        if($s.ShowTags -and ($status.Tags.Length -or $status.ActiveBookmark.Length)) {
           write-host $s.BeforeTagText -NoNewLine
-          
+            
+          if($status.ActiveBookmark.Length) {
+              write-host $status.ActiveBookmark -NoNewLine -ForegroundColor $s.BranchForegroundColor -BackgroundColor $s.TagBackgroundColor 
+              if($status.Tags.Length) {
+                write-host " " -NoNewLine -ForegroundColor $s.TagSeparatorColor -BackgroundColor $s.TagBackgroundColor
+              }
+          }
+         
           $tagCounter=0
           $status.Tags | % {
-              write-host $_ -NoNewLine -ForegroundColor $s.TagForegroundColor -BackgroundColor $s.TagBackgroundColor 
+            $color = $s.TagForegroundColor
+                
+              write-host $_ -NoNewLine -ForegroundColor $color -BackgroundColor $s.TagBackgroundColor 
+          
               if($tagCounter -lt ($status.Tags.Length -1)) {
                 write-host ", " -NoNewLine -ForegroundColor $s.TagSeparatorColor -BackgroundColor $s.TagBackgroundColor
               }
         
        Write-Host $s.AfterText -NoNewline -BackgroundColor $s.AfterBackgroundColor -ForegroundColor $s.AfterForegroundColor
     }
-}
+}
+
+# Should match https://github.com/dahlbyk/posh-git/blob/master/GitPrompt.ps1
+if((Get-Variable -Scope Global -Name VcsPromptStatuses -ErrorAction SilentlyContinue) -eq $null) {
+    $Global:VcsPromptStatuses = @()
+}
+function Global:Write-VcsStatus { $Global:VcsPromptStatuses | foreach { & $_ } }
+
+# Add scriptblock that will execute for Write-VcsStatus
+$Global:VcsPromptStatuses += {
+    Write-HgStatus
+}

File Modules/posh-hg/HgTabExpansion.ps1

 function HgTabExpansion($lastBlock) {
   switch -regex ($lastBlock) { 
     
-    #handles hgtk help <cmd>
-    #handles hgtk <cmd>
-    'thg (help )?(\S*)$' {
-      thgCommands($matches[2]);
-    }
+   #handles hgtk help <cmd>
+   #handles hgtk <cmd>
+   'thg (help )?(\S*)$' {
+     thgCommands($matches[2]);
+   }
     
-    #handles hg update <branch name>
-    #handles hg merge <branch name>
-    'hg (up|update|merge|co|checkout) (\S*)$' {
-      hgLocalBranches($matches[2])
-    }
+   #handles hg update <branch name>
+   #handles hg merge <branch name>
+   'hg (up|update|merge|co|checkout) (\S*)$' {
+      findBranchOrBookmarkOrTags($matches[2])
+   }
+       
+   #Handles hg pull -B <bookmark>   
+   'hg pull (-\S* )*-(B) (\S*)$' {
+     hgRemoteBookmarks($matches[3])
+     hgLocalBookmarks($matches[3])
+   }
+    
+   #Handles hg push -B <bookmark>   
+   'hg push (-\S* )*-(B) (\S*)$' {
+     hgLocalBookmarks($matches[3])
+   }
+   
+   #Handles hg bookmark <bookmark>
+   'hg (book|bookmark) (\S*)$' {
+      hgLocalBookmarks($matches[2])
+   }
     
     #Handles hg push <path>
     #Handles hg pull <path>
 }
 
 function hgFiles($filter, $pattern) {
-   hg status | 
+   hg status $(hg root) | 
     foreach { 
       if($_ -match "($pattern){1} (.*)") { 
         $matches[2] 
   $script:hgCommands = $hgCommands
 }
 
+function findBranchOrBookmarkOrTags($filter){
+    hgLocalBranches($filter)
+	hgLocalTags($filter)
+    hgLocalBookmarks($filter)
+}
+
 function hgLocalBranches($filter) {
-  hg branches | foreach {
+  hg branches -a | foreach {
+    if($_ -match "(\S+) .*") {
+      if($filter -and $matches[1].StartsWith($filter)) {
+        $matches[1]
+      }
+      elseif(-not $filter) {
+        $matches[1]
+      }
+    }
+  }
+}
+
+function hgLocalTags($filter) {
+  hg tags | foreach {
+    if($_ -match "(\S+) .*") {
+      if($filter -and $matches[1].StartsWith($filter)) {
+        $matches[1]
+      }
+      elseif(-not $filter) {
+        $matches[1]
+      }
+    }
+  }
+}
+
+function bookmarkName($bookmark) {
+    $split = $bookmark.Split(" ");
+        
+    if($bookmark.StartsWith("*")) {
+        $split[1]
+    }
+    else{
+        $split[0]
+    }
+}
+
+function hgLocalBookmarks($filter) {
+  hg bookmarks --quiet | foreach {
+    if($_ -match "(\S+) .*") {
+      $bookmark = bookmarkName($matches[0])  
+      if($filter -and $bookmark.StartsWith($filter)) {
+        $bookmark
+      }
+      elseif(-not $filter) {
+        $bookmark
+      }
+    }
+  }
+}
+
+function hgRemoteBookmarks($filter) {
+  hg incoming -B | foreach {
     if($_ -match "(\S+) .*") {
       if($filter -and $matches[1].StartsWith($filter)) {
         $matches[1]
   }
   
   $cmdList | sort 
+}
+
+if (Get-Command "Register-TabExpansion" -errorAction SilentlyContinue)
+{
+    Register-TabExpansion "hg.exe" -Type Command {
+        param($Context, [ref]$TabExpansionHasOutput, [ref]$QuoteSpaces)  # 1:
+
+        $line = $Context.Line
+        $lastBlock = [regex]::Split($line, '[|;]')[-1].TrimStart()
+        $TabExpansionHasOutput.Value = $true
+        HgTabExpansion $lastBlock
+    }
+    return
+}
+
+if (Test-Path Function:\TabExpansion) {
+    Rename-Item Function:\TabExpansion TabExpansionBackup
+}
+
+
+# Set up tab expansion and include hg expansion
+function TabExpansion($line, $lastWord) {
+   $lastBlock = [regex]::Split($line, '[|;]')[-1]
+
+   switch -regex ($lastBlock) {
+        "^$(Get-AliasPattern hg) (.*)" { HgTabExpansion $lastBlock }
+        "^$(Get-AliasPattern tgh) (.*)" { HgTabExpansion $lastBlock }
+
+        # Fall back on existing tab expansion
+        default { if (Test-Path Function:\TabExpansionBackup) { TabExpansionBackup $line $lastWord } }
+   }
 }

File Modules/posh-hg/HgUtils.ps1

 function isHgDirectory() {
+  if(test-path ".git") {
+    return $false; #short circuit if git repo
+  }
+  
   if(test-path ".hg") {
     return $true;
   }
   
-  if(test-path ".git") {
-    return $false; #short circuit if git repo
-  }
+  
   
   # Test within parent dirs
   $checkIn = (Get-Item .).parent
     return $false
 }
 
-function Get-HgStatus {
+function Get-HgStatus($getFileStatus=$true, $getBookmarkStatus=$true) {
   if(isHgDirectory) {
     $untracked = 0
     $added = 0
     $tags = @()
     $commit = ""
     $behind = $false
+    $multipleHeads = $false
+		
+	if ($getFileStatus -eq $false) {
+		hg parent | foreach {
+		switch -regex ($_) {
+			'tag:\s*(.*)' { $tags = $matches[1].Replace("(empty repository)", "").Split(" ", [StringSplitOptions]::RemoveEmptyEntries) }
+			'changeset:\s*(\S*)' { $commit = $matches[1]}
+			}
+		}
+		$branch = hg branch
+		$behind = $true
+		$headCount = 0
+		hg heads $branch | foreach {
+			switch -regex ($_) {
+				'changeset:\s*(\S*)' 
+				{ 
+					if ($commit -eq $matches[1]) { $behind=$false }
+					$headCount++
+					if ($headCount -gt 1) { $multipleHeads=$true }
+				}
+			}
+		}
+	}
+	else
+	{
+		   hg summary | foreach {   
+		  switch -regex ($_) {
+			'parent: (\S*) ?(.*)' { $commit = $matches[1]; $tags = $matches[2].Replace("(empty repository)", "").Split(" ", [StringSplitOptions]::RemoveEmptyEntries) } 
+			'branch: ([\S ]*)' { $branch = $matches[1] }
+			'update: (\d+)' { $behind = $true }
+			'pmerge: (\d+) pending' { $behind = $true }
+			'commit: (.*)' {
+			  $matches[1].Split(",") | foreach {
+				switch -regex ($_.Trim()) {
+				  '(\d+) modified' { $modified = $matches[1] }
+				  '(\d+) added' { $added = $matches[1] }
+				  '(\d+) removed' { $deleted = $matches[1] }
+				  '(\d+) deleted' { $missing = $matches[1] }
+				  '(\d+) unknown' { $untracked = $matches[1] }
+				  '(\d+) renamed' { $renamed = $matches[1] }
+				}
+			  } 
+			} 
+		  } 
+		}
+	}
     
-    hg summary | foreach {   
-      switch -regex ($_) {
-        'parent: (\S*) ?(.*)' { $commit = $matches[1]; $tags = $matches[2].Replace("(empty repository)", "").Split(" ", [StringSplitOptions]::RemoveEmptyEntries) } 
-        'branch: (\S*)' { $branch = $matches[1] }
-        'update: (\d+)' { $behind = $true }
-        'pmerge: (\d+) pending' { $behind = $true }
-        'commit: (.*)' {
-          $matches[1].Split(",") | foreach {
-            switch -regex ($_.Trim()) {
-              '(\d+) modified' { $modified = $matches[1] }
-              '(\d+) added' { $added = $matches[1] }
-              '(\d+) removed' { $deleted = $matches[1] }
-              '(\d+) deleted' { $missing = $matches[1] }
-              '(\d+) unknown' { $untracked = $matches[1] }
-              '(\d+) renamed' { $renamed = $matches[1] }
-            }
-          } 
-        } 
-      } 
-    }
     
+	if ($getBookmarkStatus)
+	{
+		$active = ""
+		hg bookmarks | ?{$_}  | foreach {
+			if($_.Trim().StartsWith("*")) {
+			   $split = $_.Split(" ");
+			   $active= $split[2]
+			}
+		}
+	}
     return @{"Untracked" = $untracked;
                "Added" = $added;
                "Modified" = $modified;
                "Tags" = $tags;
                "Commit" = $commit;
                "Behind" = $behind;
+               "MultipleHeads" = $multipleHeads;
+               "ActiveBookmark" = $active;
                "Branch" = $branch}
    }
 }

File Modules/posh-hg/README.md

+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
+----------
+
+0. Verify you have PowerShell 2.0 or better with $PSVersionTable.PSVersion
+
+1. 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`.
+
+2. 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.
+
+3. Clone the posh-hg repository to your local machine.
+
+4. From the posh-hg repository directory, run `.\install.ps1`.
+
+5. Enjoy!
+
+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]
+
+* `{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
+* ABCDEF represent the working directory
+ * `+` = Added files
+ * `~` = Modified files
+ * `-` = Removed files
+ * `?` = Untracked files
+ * `!` = Missing files
+ * `^` = Renamed files
+
+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)
+
+### Based on work by:
+
+ - Jeremy Skinner, http://www.jeremyskinner.co.uk/
+ - Keith Dahlby, http://solutionizing.net/
+ - Mark Embling, http://www.markembling.info/

File Modules/posh-hg/README.txt

-Inspired by the Posh-Git project (http://github.com/dahlbyk/posh-git)
-
-Posh-hg provides a custom prompt and tab expansion when using Mercurial from within a Windows Powershell command line.
-
-For more details, see this post on Jeremy's blog:
-http://www.jeremyskinner.co.uk/2010/04/21/using-mercurial-with-windows-powershell/
-
-To install posh-hg, download the latest source from GitHub or CodePlex:
-http://github.com/JeremySkinner/posh-hg/zipball/master
-http://PoshHg.codeplex.com
-
-...and add the following code to your Powershell profile (usually C:\Users\Username\Documents\WindowsPowershell\Profile.ps1)
-
-. path\to\posh-hg\profile.example.ps1
-
-Alternatiely, you can copy the contents of the profile.example.ps1 file in to your profile.ps1

File Modules/posh-hg/Settings.ps1

 $global:PoshHgSettings = New-Object PSObject -Property @{
+    #Retreival settings
+    GetFileStatus             = $true
+    GetBookmarkStatus         = $true
+	
     #Before prompt
     BeforeText                = ' ['
     BeforeForegroundColor     = [ConsoleColor]::Yellow
     # Current branch when not updated
     Branch2ForegroundColor   = [ConsoleColor]::Red
     Branch2BackgroundColor   = $host.UI.RawUI.BackgroundColor
+    # Current branch when there are multiple heads
+    Branch3ForegroundColor	 = [ConsoleColor]::Magenta
+    Branch3BackgroundColor   = $host.UI.RawUI.BackgroundColor
     
     # Working directory status
-    WorkingForegroundColor    = [ConsoleColor]::Yellow
-    WorkingBackgroundColor    = $Host.UI.RawUI.BackgroundColor
+    AddedForegroundColor      = [ConsoleColor]::Green
+    AddedBackgroundColor      = $Host.UI.RawUI.BackgroundColor
+	ModifiedForegroundColor   = [ConsoleColor]::Blue
+    ModifiedBackgroundColor   = $Host.UI.RawUI.BackgroundColor
+	DeletedForegroundColor    = [ConsoleColor]::Red
+    DeletedBackgroundColor    = $Host.UI.RawUI.BackgroundColor
+	UntrackedForegroundColor  = [ConsoleColor]::Magenta
+    UntrackedBackgroundColor  = $Host.UI.RawUI.BackgroundColor
+	MissingForegroundColor    = [ConsoleColor]::Cyan
+    MissingBackgroundColor    = $Host.UI.RawUI.BackgroundColor
+	RenamedForegroundColor    = [ConsoleColor]::Yellow
+    RenamedBackgroundColor    = $Host.UI.RawUI.BackgroundColor
     
     #Tag list
     ShowTags                  = $true
     AppliedPatchBackgroundColor   = $Host.UI.RawUI.BackgroundColor
     PatchSeparator                = ' � '
     PatchSeparatorColor           = [ConsoleColor]::White    
+    
+    # Status Count Prefixes for prompt
+    AddedStatusPrefix             = ' +'
+    ModifiedStatusPrefix          = ' ~'
+    DeletedStatusPrefix           = ' -'
+    UntrackedStatusPrefix         = ' ?'
+    MissingStatusPrefix           = ' !'
+    RenamedStatusPrefix           = ' ^'
 }

File Modules/posh-hg/install.ps1

+param([switch]$WhatIf = $false)
+
+if($PSVersionTable.PSVersion.Major -lt 2) {
+    Write-Warning "posh-hg requires PowerShell 2.0 or better; you have version $($Host.Version)."
+    return
+}
+
+if(!(Get-Command hg -ErrorAction SilentlyContinue)) {
+    Write-Warning 'Could not find hg command. Please create an hg alias or add its location to PATH.'
+    return
+}
+
+$installDir = Split-Path $MyInvocation.MyCommand.Path -Parent
+if(!(Test-Path $PROFILE)) {
+    Write-Host "Creating PowerShell profile...`n$PROFILE"
+    New-Item $PROFILE -Force -Type File -ErrorAction Stop -WhatIf:$WhatIf > $null
+}
+
+# Adapted from http://www.west-wind.com/Weblog/posts/197245.aspx
+function Get-FileEncoding($Path) {
+    $bytes = [byte[]](Get-Content $Path -Encoding byte -ReadCount 4 -TotalCount 4)
+
+    if(!$bytes) { return 'utf8' }
+
+    switch -regex ('{0:x2}{1:x2}{2:x2}{3:x2}' -f $bytes[0],$bytes[1],$bytes[2],$bytes[3]) {
+        '^efbbbf'   { return 'utf8' }
+        '^2b2f76'   { return 'utf7' }
+        '^fffe'     { return 'unicode' }
+        '^feff'     { return 'bigendianunicode' }
+        '^0000feff' { return 'utf32' }
+        default     { return 'ascii' }
+    }
+}
+
+$profileLine = ". '$installDir\profile.example.ps1'"
+if(Select-String -Path $PROFILE -Pattern $profileLine -Quiet -SimpleMatch) {
+    Write-Host "It seems posh-hg is already installed..."
+    return
+}
+
+Write-Host "Adding posh-hg to profile..."
+@"
+
+# Load posh-hg example profile
+$profileLine
+
+"@ | Out-File $PROFILE -Append -WhatIf:$WhatIf -Encoding (Get-FileEncoding $PROFILE)
+
+Write-Host 'posh-hg sucessfully installed!'
+Write-Host 'Please reload your profile for the changes to take effect:'
+Write-Host '    . $PROFILE'

File Modules/posh-hg/posh-hg.psm1

 Pop-Location
 
 Export-ModuleMember -Function @(
-  'Write-HgStatus',
   'Get-HgStatus',
-  'HgTabExpansion',
+  'TabExpansion',
   'Get-MqPatches',
   'PopulateHgCommands'
  )

File Modules/posh-hg/profile.example.ps1

 # Set up a simple prompt, adding the hg prompt parts inside hg repos
 function prompt {
     Write-Host($pwd) -nonewline
-        
-    # Mercurial Prompt
-    $Global:HgStatus = Get-HgStatus
-    Write-HgStatus $HgStatus
+
+    Write-VcsStatus
       
     return "> "
 }
 
-if(-not (Test-Path Function:\DefaultTabExpansion)) {
-    Rename-Item Function:\TabExpansion DefaultTabExpansion
-}
-
-# Set up tab expansion and include hg expansion
-function TabExpansion($line, $lastWord) {
-    $lastBlock = [regex]::Split($line, '[|;]')[-1]
-    
-    switch -regex ($lastBlock) {
-        # mercurial and tortoisehg tab expansion
-        '(hg|thg) (.*)' { HgTabExpansion($lastBlock) }
-        # Fall back on existing tab expansion
-        default { DefaultTabExpansion $line $lastWord }
-    }
-}
-
-
 Pop-Location