Modify

Opened 3 years ago

Last modified 9 months 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: rjollos Owned by: rjollos
Priority: normal Component: TracBacksPlugin
Severity: normal Keywords:
Cc: ChrisNelson 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 (4)

comment:1 Changed 3 years ago by rjollos

  • Owner changed from mchua to rjollos

Reassigning to new maintainer.

comment:2 Changed 9 months ago by ChrisNelson

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 9 months ago by ChrisNelson

  • Cc ChrisNelson added

comment:4 Changed 9 months ago by ChrisNelson

What do you think of this patch?:

  • 0.11/tracbacks/tracbacks.py

    a b class TracBacksPlugin(Component): 
    7373        tickets_referenced = pattern.findall(comment) 
    7474        # convert from strings to ints and discard duplicates 
    7575        tickets_referenced = set(int(t) for t in tickets_referenced) 
     76        # remove possible self-reference 
     77        tickets_referenced.discard(ticket.id) 
    7678 
    7779        # 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 
    8081            for ticket_to_tracback in tickets_referenced: 
    8182                try: 
    8283                    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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from rjollos. Next status will be 'new'.
The owner will be changed from rjollos to anonymous. Next status will be 'assigned'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.