Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Detect when the current branch has multiple heads and indicate by cha…

…nging the colour of the branch name. Helpful when knowing when a merge is neccessary.
  • Loading branch information...
commit 490829619ad85f25310fe0d16cc7e11588ac3a58 1 parent 1220e52
@petemill petemill authored
Showing with 18 additions and 3 deletions.
  1. +5 −0 HgPrompt.ps1
  2. +10 −3 HgUtils.ps1
  3. +3 −0  Settings.ps1
View
5 HgPrompt.ps1
@@ -12,6 +12,11 @@ function Write-HgStatus($status = (get-hgStatus $global:PoshHgSettings.GetFileSt
$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
View
13 HgUtils.ps1
@@ -34,8 +34,8 @@ function Get-HgStatus($getFileStatus=$true, $getBookmarkStatus=$true) {
$tags = @()
$commit = ""
$behind = $false
-
-
+ $multipleHeads = $false
+
if ($getFileStatus -eq $false) {
hg parent | foreach {
switch -regex ($_) {
@@ -45,9 +45,15 @@ function Get-HgStatus($getFileStatus=$true, $getBookmarkStatus=$true) {
}
$branch = hg branch
$behind = $true
+ $headCount = 0
hg heads $branch | foreach {
switch -regex ($_) {
- 'changeset:\s*(\S*)' { if ($commit -eq $matches[1]) { $behind=$false } }
+ 'changeset:\s*(\S*)'
+ {
+ if ($commit -eq $matches[1]) { $behind=$false }
+ $headCount++
+ if ($headCount -gt 1) { $multipleHeads=$true }
+ }
}
}
}
@@ -95,6 +101,7 @@ function Get-HgStatus($getFileStatus=$true, $getBookmarkStatus=$true) {
"Tags" = $tags;
"Commit" = $commit;
"Behind" = $behind;
+ "MultipleHeads" = $multipleHeads;
"ActiveBookmark" = $active;
"Branch" = $branch}
}
View
3  Settings.ps1
@@ -19,6 +19,9 @@ $global:PoshHgSettings = New-Object PSObject -Property @{
# 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
AddedForegroundColor = [ConsoleColor]::Green
Please sign in to comment.
Something went wrong with that request. Please try again.