Functions/New-HgBookmark.ps1
function New-HgBookmark { <# .SYNOPSIS Adds a bookmark to a repository. .DESCRIPTION By default, the bookmark will be added to the current revision. You can add it to a specific revision with the `Revision` parameter. .EXAMPLE New-HgBookmark 'NewHgBookmark' Demonstrates how to add a new bookmark. .EXAMPLE New-HgBookmark 'NewHgBookmark' -Revision '49' Demonstrates how to add a bookmark to an explicit revision. You can use a branch name, tag name, revision number, or node ID. .EXAMPLE New-HgBookmark 'NewHgBookmark' -Force Demonstrates how to move an existing bookmark. #> [CmdletBinding(SupportsShouldProcess=$true)] param( [Parameter(Mandatory=$true)] [string] # The name of the bookmark. $Name, [Parameter()] [string] # The revision to bookmark. Defaults to the current revision. $Revision, [Switch] # Forces the bookmark to be moved to a new revision. $Force, [Parameter()] [string] # The path to the repository where the bookmark is created. Defaults to the current directory. $RepoRoot = (Get-Location) ) Set-StrictMode -Version 'Latest' $RepoRoot = Resolve-HgRoot -Path $RepoRoot if( -not $RepoRoot ) { return } $revisionArg = '' if( $Revision ) { $revisionArg = '-r{0}' -f $Revision } $forceArg = '' if( $Force ) { $forceArg = '-f' } Write-Verbose ('Bookmarking changeset ''{0}'' ''{1}'' in {2}.' -f $Revision,$Name,$RepoRoot) hg bookmark $forceArg $revisionArg $Name -R $RepoRoot | Write-Verbose $bookmark = Get-HgBookmark -Name $Name -RepoRoot $RepoRoot if( -not $bookmark ) { Write-Error ('Failed to create bookmark ''{0}'' in repository ''{1}''.' -f $Name,$RepoRoot) return } return $bookmark } |