Functions/Add-HgItem.ps1
function Add-HgItem { <# .SYNOPSIS Adds a file or directory to a Mercurial repository. .DESCRIPTION Adds a file or directory to the repository under which it exists. ALIASES ahgi, hgadd .EXAMPLE Add-HgItem -Path .\Repository\File\to\add.txt Adds File\to\add.txt to the repository in Repository. #> [CmdletBinding(SupportsShouldProcess=$true)] param( [Parameter(Mandatory=$true)] [string[]] # The path to the file to add. $Path ) $Path | ForEach-Object { $repoRoot = Resolve-HgRoot $_ if( -not $repoRoot ) { return } Push-Location -Path $repoRoot try { $rPath = Resolve-HgPath -Path $_ if( $pscmdlet.ShouldProcess( $rPath, "add to repository $repoRoot" ) ) { hg add $rPath if( -not $LastExitCode ) { Get-HgUncommittedChangeset -Path $rPath } } } finally { Pop-Location } } } Set-Alias -Name 'Add-HgFile' -Value 'Add-HgItem' Set-Alias -Name 'hgadd' -Value 'Add-HgItem' Set-Alias -Name 'ahgi' -Value 'Add-HgItem' |