Functions/Remove-HgBookmark.ps1

function Remove-HgBookmark
{
    <#
    .SYNOPSIS
    Removes a bookmark from Mercurial.
 
    .DESCRIPTION
    Removes a bookmark from Mercurial.
 
    .EXAMPLE
    Remove-HgBookmark -Name 'FooBar'
 
    Demonstrates how to remove a bookmark from the repository in the current directory.
 
    .EXAMPLE
    Remove-HgBookmark -Name 'FooBar' -Path 'C:\Projects\PsHg'
 
    Demonstrates how to remove a bookmark from a specific repository.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$true)]
        [string]
        # The name of the bookmark to delete.
        $Name,

        [Parameter()]
        [string]
        # The repository to operate on. Defaults to the current directory.
        $RepoRoot = (Get-Location).Path
    )

    Set-StrictMode -Version 'Latest'

    # Verify that the root passed in is actually an Hg repo
    $RepoRoot = Resolve-HgRoot -Path $RepoRoot
    if( -not $RepoRoot )
    {
        return
    }

    if( (Test-HgBookmark -Name $Name -RepoRoot $RepoRoot) )
    {
        hg bookmark -d $Name -R $RepoRoot 2> $null
    }
}