import sys, os, string, re, urllib2 if string.find(os.path.abspath(sys.argv[0]), os.sep+'Twisted') != -1: sys.path.insert(0, os.path.normpath(os.path.join(os.path.abspath(sys.argv[0] ), os.pardir, os.pardir, os.pardir))) from twisted.python import usage class Options(usage.Options): updates = ('README', 'twisted/copyright.py', 'admin/twisted.spec', 'ChangeLog') optParameters = [ ["type", "t", "alpha", "Type of release -- alpha, RC or final"], ["qotr", "q", None, "Quote of the release"], ] optFlags = [ ["head", "h", "Start from HEAD"], ["manual-changelog", "c", "Enter changelog entry in editor"], ["dry-run", "n", "Do nothing"], ] def opt_update(self, file): self.updates = self.updates+(file,) def getrevision(): text = urllib2.urlopen('http://cvs.twistedmatrix.com/cvs/README') while 1: line = text.readline() if not line: break if line.startswith("
CVS Tags:"): text.readline() tag = parsetag(text.readline()) if tag: break text.close() return tag def parsetag(tag): tag = tag[tag.index('=')+1:] tag = tag[tag.index('=')+1:tag.rindex('"')] if not tag.startswith('release-'): return major, minor, patch = tag[tag.index('-')+1:].split('_') try: patch = int(patch) except ValueError: m = re.match('(\d+)(.+?)(\d+)', patch) patch = m.groups() else: patch = str(patch), 'final', 1 return tag, (major, minor, patch) def strtag(major, minor, patch): spatch = ''.join(patch) if patch[1]=='final': if patch[2]=='1': spatch = patch[0] else: spatch = str(int(patch[0])+1) return '.'.join([major, minor, spatch]) def calcnext(version, type): major, minor, patch = version order=['alpha', 'rc', 'final'] then, now = order.index(patch[1]), order.index(type) if now>then: patch = patch[0], type, '1' elif now