Edgewall Software

Opened 16 years ago

Closed 12 years ago

Last modified 12 years ago

#3641 closed enhancement (fixed)

Add a way to revert ticket changes

Reported by: Adrian Holovaty <holovaty@…> Owned by: Remy Blank
Priority: low Milestone: 0.12
Component: ticket system Version: 0.9.6
Severity: minor Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:


It'd be super-convenient if Trac offered a way to revert a particular change to a ticket.

For example, at the Django Trac site, we just got a ton of spam. (Yes, we have the spam plugins installed, but they didn't catch this particular spammer.) Each spam changed the priority/component/severity/milestone of a random ticket. So now I have to go through each ticket and manually change those attributes to what they were previously. Then I have to delete all of the comments themselves (because they contained spam links).

Trac appears to keep track of old values and new values to tickets, for each change, so it should be possible to automate the "undoing" of a given ticket change.

It'd be nicest if there were a "revert" link next to each ticket, but, personally, I'd be just as happy with a command-line script that takes the ticket number and automatically reverts the latest ticket change for that ticket:

trac-admin revertcomment 243

Attachments (1)

revert_trac_change.py (1.7 KB ) - added by Adrian Holovaty <holovaty@…> 16 years ago.
revert_trac_change.py: Sample implementation of reverting the last change for a given ticket in a given Trac installation.

Download all attachments as: .zip

Change History (7)

by Adrian Holovaty <holovaty@…>, 16 years ago

Attachment: revert_trac_change.py added

revert_trac_change.py: Sample implementation of reverting the last change for a given ticket in a given Trac installation.

comment:1 by Adrian Holovaty <holovaty@…>, 16 years ago

I've attached a sample, hackish implementation that takes care of the problem for me. I have no idea how this would fit into the Trac architecture (as I'm not familiar with it), but you're free to do with it what you wish! Also see the gotchas at the top of the attachment's docstring.

comment:2 by anonymous, 16 years ago

You can also use the th:TicketDeletePlugin WebAdmin plugin to do this.

comment:3 by Christian Boos, 15 years ago

Milestone: 1.0
Owner: changed from Jonas Borgström to Christian Boos

This functionality should be in core for 1.0

Even better, by extension it should be possible to undo the last change on any resource, see GenericTrac.

comment:4 by Paul McNett <p@…>, 15 years ago

Just to add to the mix of tools already available to revert ticket changes, I wrote one a few days ago that I think does a nice job of providing fast interactive change reverting via the command line (e.g. you need to be the trac admin and feed the tool the path to your Trac instance.)

    Usage: trac_revert_ticket_changes.py [-n] PATH [ticket1 [ticket2 [...]]]

    # Review all changes in the past 5 days (default is 1 day):
    trac_revert_ticket_changes.py dabodemo -n 5
    # Review all changes for specific tickets:
    trac_revert_ticket_changes.py dabodemo 1002 1003

For each ticket, changes are presented one at a time in most-recent-first order. Interactively choose to revert each one. If you say 'no', no further changes are presented for that ticket.

I hope it is useful for someone. Get it here: http://paulmcnett.com/pkm_software/trac_revert_ticket_changes.py

comment:5 by Remy Blank, 12 years ago

Milestone: 1.00.12
Resolution: fixed
Status: newclosed

A new method Ticket.delete_change() has been added in [9270] (together with unit tests) to allow deleting comments and whole tickets while preserving (or at least attempting to preserve) the consistency of field changes.

An optional UI component has also been implemented that adds "Delete" buttons next to the "Reply" buttons in the ticket page. The button in the description deletes whole tickets, and the buttons in the change history delete single comments. The component is in tracopt and therefore disabled by default.

Deletions require a confirmation, and the confirmation page shows the ticket box or the selected comment, therefore hopefully avoiding unintended deletions.

comment:6 by Remy Blank, 12 years ago

Owner: changed from Christian Boos to Remy Blank

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.