#3641 closed enhancement (fixed)
Add a way to revert ticket changes
Reported by: | 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: |
Description
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)
Change History (7)
by , 18 years ago
Attachment: | revert_trac_change.py added |
---|
comment:1 by , 18 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:3 by , 18 years ago
Milestone: | → 1.0 |
---|---|
Owner: | changed from | to
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 , 17 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 , 15 years ago
Milestone: | 1.0 → 0.12 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
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 , 15 years ago
Owner: | changed from | to
---|
revert_trac_change.py: Sample implementation of reverting the last change for a given ticket in a given Trac installation.