Functions/New-HgRepository.ps1


function New-HgRepository
{
    <#
    .SYNOPSIS
    Creates a new Mercurial repository.
     
    .DESCRIPTION
    Uses Mercurial's init command to create a new repository.
     
    ALIASES
      nhg, hginit
     
    .EXAMPLE
    Initalize-HgRepository -RepoRoot .\Path\to\New\Repository
     
    Creates a new Mercurial repository at `.\Path\to\New\Repository`.
    #>

    [CmdletBinding(SupportsShouldProcess=$true)]
    param(
        [Parameter(Mandatory=$true)]
        [string]
        # The path to the new repository.
        $RepoRoot
    )
    
    if( $pscmdlet.ShouldProcess( $RepoRoot, 'create repository' ) )
    {
        hg init $RepoRoot
        if( $LastExitCode )
        {
            Write-Error "Failed to create repository at '$RepoRoot'."
        }
    }
}

Set-Alias -Name 'Initialize-HgRepository' -Value 'New-HgRepository'
Set-Alias -Name 'nhg' -Value 'New-HgRepository'
Set-Alias -Name 'hginit' -Value 'New-HgRepository'