P4rollback.pl

About
p4rollback.pl is a Perl script that automatically runs the Perforce commands needed to roll back a single changelist, as described in Perforce KB article 14. It accepts a single submitted changelist number as an argument, and produces a new pending changelist whose effect will be to roll back the submitted changelist.

See Rollback for a C++ API implementation.

Usage
p4rollback.pl [-d] [-Di] [-Ds] [-Dt] changenumber

The changenumber is the submitted changelist you wish to undo.

By default, the script will not roll back a given revision of a file if rolling back that revision would implicitly roll back other revisions. For example, rolling back an edit of a file that has subsequently been deleted would roll back not only the edit but the delete (re-adding the file). The -d/-Di/-Ds/-Dt flags override this behavior, with each -Dx flag overriding a specific case and -d overriding them all:

-Di/-d
With this option, rolling back a delete of a file that was subsequently re-added will open it for edit at the revision prior to the delete, requiring a resolve against the re-added revision(s).

-Ds/-d
With this option, rolling back an edit of a file that was subsequently deleted will open it for add at the revision prior to the edit, implicitly rolling back the delete.

-Dt/-d
With this option, rolling back an add of a file that was subsequently edited will open it for delete, implicitly rolling back the edits.