Functions/Test-HgBranch.ps1


function Test-HgBranch
{
    <#
    .SYNOPSIS
    Checks if a branch exists.
     
    .DESCRIPTION
    Returns true if BranchName exists. False otherwise.
     
    ALIASES
      thgb
     
    .EXAMPLE
    Test-HgBranch BranchName
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$true,Position=0)]
        [string]
        # The name of the branch.
        $Name,
        
        [Parameter()]
        [string]
        # The path to the repository whose branches to get. Defaults to the current directory.
        $RepoRoot = (Resolve-Path .)
    )    
    
    $branch = Get-HgBranch -RepoRoot $RepoRoot -Closed | 
                Where-Object { $_.Name -ceq $Name }
                
    if( $branch )
    {
        return $true
    }
    else
    {
        return $false
    }
}

Set-Alias -Name 'thgb' -Value 'Test-HgBranch'