5 # Changed blah and foo to do this or that. Re #10 and #12, and qa #12.
10 from datetime import datetime
12 from trac.env import open_environment
13 from trac.ticket.notification import TicketNotifyEmail
14 from trac.ticket import Ticket
15 from trac.ticket.web_ui import TicketModule
16 from trac.util.datefmt import utc
17 from trac.versioncontrol.api import NoSuchChangeset
21 describe = sys.argv[3]
22 describe_tags = sys.argv[4]
31 if ticket['phase'] == 'Final Fixing':
32 ticket['phase'] = 'Final QA'
34 ticket['phase'] = 'Initial QA'
36 ticket['status'] = 'new'
38 commands = { 're': refs, 'refs': refs, 'qa': qa }
39 commandPattern = re.compile(r'(?P<action>[A-Za-z]*).?(?P<ticket>#[0-9]+(?:(?:[, &]*|[ ]?and[ ]?)#[0-9]+)*)')
40 ticketPattern = re.compile(r'#([0-9]*)')
41 authorPattern = re.compile(r'<(.+)@')
44 env = open_environment(project)
45 for command, ticketList in commandPattern.findall(message):
46 if commands.has_key(command.lower()):
47 for ticketId in ticketPattern.findall(ticketList):
48 tickets.setdefault(ticketId, []).append(commands[command.lower()])
50 for ticketId, commands in tickets.iteritems():
53 ticket = Ticket(env, int(ticketId), db)
54 for command in commands:
57 # determine sequence number...
59 tm = TicketModule(env)
60 for change in tm.grouped_changelog_entries(ticket, db):
61 if change['permanent']:
64 username = authorPattern.findall(author)[0]
65 now = datetime.now(utc)
66 message = "(On %s [changeset:%s %s]) %s" % (refname, rev, describe_tags, message)
67 ticket['branch'] = refname
68 ticket.save_changes(username, message, now, db, cnum+1)
71 tn = TicketNotifyEmail(env)
72 tn.notify(ticket, newticket=0, modtime=now)