Skip to content

Instantly share code, notes, and snippets.

@bamboo
Created March 1, 2012 18:06
Show Gist options
  • Save bamboo/1951742 to your computer and use it in GitHub Desktop.
Save bamboo/1951742 to your computer and use it in GitHub Desktop.
copy all local hg changes to another folder
import System.IO
import Boo.Lang.PatternMatching
targetFolder = argv[0]
changes = ((statusLine[:1], statusLine[2:]) for statusLine in /\n/.Split(shell("hg", "st")) if len(statusLine) > 0)
for status, file in changes:
targetFile = Path.Combine(targetFolder, file)
match status:
case "M" | "?":
Directory.CreateDirectory(Path.GetDirectoryName(targetFile))
File.Copy(file, targetFile, true)
case "R" | "!":
File.Delete(targetFile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment