I'll admit it, I
know and love mercurial, and I haven't got a clue how to use git. Sure I can learn,
but why bother since
there is a mercurial adapter called hg-git? The only fly in the ointment is installing hg-git on windows. The installer is annoying, so I wrote a powershell script to handle it for me.
The installation script, which is self contained in powershell, does the hard work of installation and complains if you're missing dependencies. You can download it here, or see the original version inline below:
# Install hg-git, on a windows machine.
# This script makes lots of assumptions - you're welcome to fix it to be less
# restricitive.
###############################################################################
#Helper Functions START
###############################################################################
function DownloadFile ($file)
{
$uri = new-Object System.Uri $file ;
$localPath = "$($pwd.Path)\$($uri.Segments[-1])";
(new-object System.Net.WebClient).DownloadFile($uri,$localPath);
$localPath
}
#Helper Functions END
###############################################################################
# Assert Python is installed.
###############################################################################
$pythonPath = "c:\python27"
if (!(Test-Path $pythonPath))
{
$msg = "Python Is not installed checked at [$pythonPath]";
throw $msg;
}
# Install easy_install if needed.
###############################################################################
$easyInstallPath = "$pythonPath\scripts\easy_install.exe"
if ((Test-Path $easyInstallPath))
{
Write-Host("++ ez_setup already installed");
}
else
{
$localFile = DownloadFile("http://peak.telecommunity.com/dist/ez_setup.py")
. $localFile
}
#Installer is going to need VS9.0
# Use it, or VS11, if that's installed.
###############################################################################
if (!(gci env: | ? {$_.Name -eq "VS90COMNTOOLS"}))
{
# If VS 11 is installed, we can use that instead, python just needs to be told.
if ((gci env: | ? {$_.Name -eq "VS110COMNTOOLS"}))
{
Write-Host "++ Setting environment to contain VS Common Tools Installed"
$env:VS90COMNTOOLS = $env:VS110COMNTOOLS;
}
}
if (!(gci env: | ? {$_.Name -eq "VS90COMNTOOLS"}))
{
$msg = "VS Common Tools are not installed - install VS express";
throw $msg;
}
else
{
Write-Host "++ VS Common Tools Installed"
}
# Run easy-install hg_git, with path will involve compilation.
###############################################################################
Invoke-Expression "$easyInstallPath hg-git"
# Make sure mercurialIni exists.
###############################################################################
$mercurialIniPath = "~\Mercurial.ini"
if (!(Test-Path $mercurialIniPath ))
{
$msg = "Mercurial.ini not found at [$mercurialIniPath]";
throw $msg;
}
# if Mercurial.ini exists, test if it contains the plugin.
# if not tell user to install the plugin.
###############################################################################
$hggitInstallLine = "hggit = c:/python27/lib/site-packages/hg_git-0.3.4-py2.7.egg/hggit";
if (select-string $hggitInstallLine -Path $mercurialIniPath)
{
Write-Host "++ WooHoo - hg git installed, you can now use hg clone git+https://"
}
else
{
Invoke-Expression $mercurialIniPath
Write-Host "Please add $hggitInstallLine to $mercurialIniPath";
}
No comments:
Post a Comment