Functions/New-HgTag.ps1
function New-HgTag { <# .SYNOPSIS Creates a new tag. .DESCRIPTION Can create a new local tag, a global tag, or update the revision of an existing tag. .EXAMPLE New-HgTag -Name 'BranchBaseline' Creates a new tag, `BranchBaseline`, for the revision of the current directory. .EXAMPLE New-HgTag -Name 'BranchBaseline' -Revision 'p1(first(branch(MyBranch)))' Demonstrates how to create a tag to a specific revision. .EXAMPLE New-HgTag -Name 'BranchBaseline' -Local Demonstrates how to create a local tag. .EXAMPLE New-HgTag -Name 'BranchBaseline' -Force Demonstrates how to change the revision a tag points to. #> [CmdletBinding()] [OutputType([PsHg.TagInfo])] param( [Parameter(Mandatory=$true)] [string] # The name of the tag. $Name, [string] # The revision the tag should point to. By default it will point to the revision of the repository's working directory. $Revision, [Switch] # Creates a local tag. $Local, [Switch] # Updates an existing tag to point to a new revision. $Force, [string] # The commit message to use. $Message, [string] # The path to the repository to update. By default, the current directory. $RepoRoot = (Get-Location) ) Set-StrictMode -Version 'Latest' $RepoRoot = Resolve-HgRoot -Path $RepoRoot if( -not $RepoRoot ) { return } $repoRootarg = '-R{0}' -f $RepoRoot $revisionArg = '' if( $Revision ) { $revisionArg = '-r{0}' -f $Revision } $localArg = '' if( $Local ) { $localArg = '-l' } $forceArg = '' if( $Force ) { $forceArg = '-f' } $messageArg = '' if( $Message ) { $messageArg = '-m{0}' -f $Message } Write-Verbose ('Tagging changeset ''{0}'' ''{1}'' in {2}.' -f $Revision,$Name,$RepoRoot) hg tag $forceArg $localArg $messageArg $revisionArg $Name $repoRootarg | Write-Verbose if( $LastExitCode -ne 0 ) { Write-Error ('Failed to create tag ''{0}'': Mercurial exited with code {1}.' -f $Name,$LastExitCode) return } Get-HgTag -Name $Name -RepoRoot $RepoRoot } |