Skip to content

Instantly share code, notes, and snippets.

@bamboo
Created August 8, 2011 18:18
Show Gist options
  • Save bamboo/1132339 to your computer and use it in GitHub Desktop.
Save bamboo/1132339 to your computer and use it in GitHub Desktop.
stripping all revisions from a non tip head in mercurial
def hg(command):
return shell("hg", command)
def strip(rev):
return hg("strip $rev")
def heads():
return hg("heads")
def nextNonTipRevision():
matches = /changeset:\s+(\d+).+\n(tag:\s*tip\n)?/.Matches(heads())
for m as System.Text.RegularExpressions.Match in matches:
if string.IsNullOrEmpty(m.Groups[2].Value):
return m.Groups[1].Value
while not string.IsNullOrEmpty(rev = nextNonTipRevision()):
print "stripping $rev..."
print strip(rev)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment