Created
July 24, 2010 20:26
-
-
Save JeremySkinner/488944 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# powershell script for syncing a mercurial repository with a git repository. | |
# Usage: HgSync.ps1 NameOfProject git://github.com/Path/To/RemoteGitRepo.git https://Path/To/RemoteHgRepository | |
# Requires the hg-git plugin http://hg-git.github.com/ | |
$project = $args[0] | |
$gitrepo = $args[1] | |
$hgrepo = $args[2] | |
$path = "D:\hg-sync\$project" | |
function hg { | |
& "C:\Program Files (x86)\TortoiseHg\hg.exe" $args | |
} | |
write-host "Project: $project" | |
write-host "Git repo: $gitrepo" | |
write-host "Hg repo: $hgrepo" | |
write-host | |
write-host | |
if(test-path $path) { | |
write-host "Directory $path exists. Performing update..." | |
write-host | |
pushd $path | |
hg pull | |
hg update | |
write-host "Pushing to hg repo..." | |
write-host | |
hg push -b . hgrepo | |
popd | |
} | |
else { | |
write-host "Directory $path does not exist. Performing clone..." | |
write-host | |
[void](mkdir $path) | |
hg clone $gitrepo $path | |
pushd $path | |
write-host | |
write-host "Adding hg path..." | |
add-content .hg\hgrc "`nhgrepo = $hgrepo" | |
write-host "Pushing to hg repo..." | |
write-host | |
hg push -b . hgrepo | |
popd | |
} | |
write-host | |
write-host "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment