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]
29 if ticket['phase'] == 'Final Fixing':
30 ticket['phase'] = 'Final QA'
32 ticket['phase'] = 'Initial QA'
34 ticket['status'] = 'new'
36 commands = { 're': refs, 'refs': refs, 'qa': qa }
37 commandPattern = re.compile(r'(?P<action>[A-Za-z]*).?(?P<ticket>#[0-9]+(?:(?:[, &]*|[ ]?and[ ]?)#[0-9]+)*)')
38 ticketPattern = re.compile(r'#([0-9]*)')
39 authorPattern = re.compile(r'<(.+)@')
42 env = open_environment(project)
43 repos = env.get_repository()
46 changeset = repos.get_changeset(rev)
48 for command, ticketList in commandPattern.findall(changeset.message):
49 if commands.has_key(command.lower()):
50 for ticketId in ticketPattern.findall(ticketList):
51 tickets.setdefault(ticketId, []).append(commands[command.lower()])
53 for ticketId, commands in tickets.iteritems():
56 ticket = Ticket(env, int(ticketId), db)
57 for command in commands:
60 # determine sequence number...
62 tm = TicketModule(env)
63 for change in tm.grouped_changelog_entries(ticket, db):
64 if change['permanent']:
67 username = authorPattern.findall(changeset.author)[0]
68 now = datetime.now(utc)
69 message = "(On %s [changeset:%s %s]) %s" % (refname, rev, describe_tags, changeset.message)
70 ticket['branch'] = refname
71 ticket.save_changes(username, message, now, db, cnum+1)
74 tn = TicketNotifyEmail(env)
75 tn.notify(ticket, newticket=0, modtime=now)