Skip to content

Instantly share code, notes, and snippets.

@vmiheer
Last active July 22, 2016 07:28
Show Gist options
  • Save vmiheer/fb8793cfba741081dd303b16b1bab9a8 to your computer and use it in GitHub Desktop.
Save vmiheer/fb8793cfba741081dd303b16b1bab9a8 to your computer and use it in GitHub Desktop.
better p4 sync
function Sync-Perforce($Path)
{
Write-Host $Path
$arguement = "$($Path)/...";
p4 sync $arguement 1>$null 2>&1;
if ($LASTEXITCODE -ne 0) {
$output = & p4 sync $arguement 2>&1;
if ($output.CategoryInfo.TargetName -eq "Request too large (over 750000); see 'p4 help maxresults'.") {
Write-Debug "Request too large! Retrying Subdirs";
$SubDirs = &p4 dirs -C "$($Path)/*"
foreach ($i in $SubDirs) {
Sync-Perforce $i;
}
} else {
Write-Error $output.CategoryInfo.TargetName;
Write-Error "Unknown sync error!";
throw "Sync error!";
}
}
if ((Get-PSCallStack).Length -eq 2) {
p4 resolve -am //...;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment