Modify

Opened 8 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: Ryan J Ollos
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 (4)

comment:1 Changed 8 years ago by Ryan J Ollos

Owner: changed from Mel Chua to Ryan J Ollos

Reassigning to new maintainer.

comment:2 Changed 5 years ago by Chris Nelson

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 5 years ago by Chris Nelson

Cc: Chris Nelson added; anonymous removed

comment:4 Changed 5 years ago by Chris Nelson

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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain Ryan J Ollos.

Add Comment


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

 
Note: See TracTickets for help on using tickets.