Permalink
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...
1 parent 1220e52 commit 490829619ad85f25310fe0d16cc7e11588ac3a58 @petemill petemill committed Aug 13, 2012
Showing with 18 additions and 3 deletions.
  1. +5 −0 HgPrompt.ps1
  2. +10 −3 HgUtils.ps1
  3. +3 −0 Settings.ps1
View
@@ -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
@@ -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
@@ -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

0 comments on commit 4908296

Please sign in to comment.