Skip to content

Instantly share code, notes, and snippets.

@grenade
Created September 16, 2015 08:21
Show Gist options
  • Select an option

  • Save grenade/13dc02c5a2b63ef305c2 to your computer and use it in GitHub Desktop.

Select an option

Save grenade/13dc02c5a2b63ef305c2 to your computer and use it in GitHub Desktop.
function Install-BundleClone {
param (
[string] $url = 'https://hg.mozilla.org/hgcustom/version-control-tools/raw-file/default/hgext/bundleclone/__init__.py',
[string] $path = 'C:\mozilla-build\hg',
[string] $filename = 'bundleclone.py',
[string] $hgrc = 'C:\Users\cltbld\.hgrc'
)
if (Test-Path $path) {
$target = ('{0}\{1}' -f $path, $filename)
if (Test-Path $target) {
Remove-Item -path $target -force
}
Write-Log -message ('installing latest bundleclone to: {0}' -f $target) -severity 'INFO'
(New-Object Net.WebClient).DownloadFile($url, $target)
Enable-BundleClone
}
}
function Enable-BundleClone {
param (
[string] $hgrc = 'C:\Users\cltbld\.hgrc',
[string] $path = 'C:/mozilla-build/hg/bundleclone.py'
)
if (Test-Path $hgrc) {
Write-Log -message "enabling bundleclone" -severity 'INFO'
(Get-Content $hgrc) | Foreach-Object { $_ -replace "#bundleclone(\s*)?=.*$", "bundleclone=$path" } | Set-Content $hgrc
}
}
function Disable-BundleClone {
param (
[string] $hgrc = 'C:\Users\cltbld\.hgrc'
)
if (Test-Path $hgrc) {
Write-Log -message "disabling bundleclone" -severity 'INFO'
(Get-Content $hgrc) | Foreach-Object { $_ -replace "^bundleclone(\s*)?=", "#bundleclone=" } | Set-Content $hgrc
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment