Opened 15 years ago
Last modified 5 years ago
#6639 new enhancement
TracBack does not need to be inserted when ticket is already referenced in a log message containing multiple ticket references
Reported by: | Ryan J Ollos | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | TracBacksPlugin |
Severity: | normal | Keywords: | |
Cc: | Chris Nelson | Trac Release: | 0.11 |
Description
If a log message references two tickets, e.g. ticket #100
and ticket #200
, then the trac-post-commit-hook
inserts the log message into ticket 100 and ticket 200. TracBacksPlugin then inserts a message into ticket 100 saying it was referenced in ticket 200, and vice-versa.
We should make TracBacksPlugin smart enough to know when a reference has already been inserted into a ticket so that we don't get duplicate log messages inserted into tickets.
Attachments (0)
Change History (5)
comment:1 Changed 15 years ago by
Owner: | changed from Mel Chua to Ryan J Ollos |
---|
comment:2 Changed 12 years ago by
This has become a high-priority item for us. I'm exploring options to solve it. Do you have any thoughts?
One idea I had was to expose a function to suspend tracbacks for an update. Either:
oldTB = setTBstate(disabled) ticket.save_changes(...) setTBstate(oldTB)
Or
tbIgnoreUpdate(ticket.save_changes())
(or something like that which took a function as an argument, disabled tracback, executed the function, then put tracback back.
comment:3 Changed 12 years ago by
Cc: | Chris Nelson added; anonymous removed |
---|
comment:4 Changed 12 years ago by
What do you think of this patch?:
-
0.11/tracbacks/tracbacks.py
a b class TracBacksPlugin(Component): 73 73 tickets_referenced = pattern.findall(comment) 74 74 # convert from strings to ints and discard duplicates 75 75 tickets_referenced = set(int(t) for t in tickets_referenced) 76 # remove possible self-reference 77 tickets_referenced.discard(ticket.id) 76 78 77 79 # put trackbacks on the tickets that we found 78 if not ticket.id in tickets_referenced \ # not part of a commit 79 and not self.is_tracback(comment): # prevent infinite recursion 80 if not self.is_tracback(comment): # prevent infinite recursion 80 81 for ticket_to_tracback in tickets_referenced: 81 82 try: 82 83 linked_ticket = Ticket(self.env, ticket_to_tracback)
The idea is that it seems quite unlikely that a user would enter a comment into ticket A like "This affects A and B" (The user would say, "This affects this ticket and B".) so we can reasonably assume such text comes from outside, such as a commit hook which will already be updating each ticket so the TB isn't needed.
comment:5 Changed 5 years ago by
Owner: | Ryan J Ollos deleted |
---|
Reassigning to new maintainer.