P4rollback.pl

From PDWiki

Jump to: navigation, search

Undo a submitted changelist in a single step

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.

Recent Changes RSS_Feed.gif

  • Change 6443 on 2008/09/04 by sam_stafford@samwise-silver
      Fix a bug with running rollback while there are already files in
      the default changelist. The regex I was using to clear the files
      from the "change -o" output was malformed. Seems to work now.
      Thanks go to Doreen for finding the bug, and to Matt for his
      superior regex skillz.
  • Change 6296 on 2008/03/27 by sam_stafford@samwise-silver
      Add pointer to rollback in p4rollback.pl comments, replacing the exhortation for other users to come up with their own API-based implementations.
  • Change 6255 on 2008/02/28 by sam_stafford@samwise-silver
      Fixing up the comments a bit. Had some annoying typos, and the -D options needed some clarification.
  • Change 6114 on 2007/12/17 by sam_stafford@samwise-rivendell
      Use "p4 info" to get client name instead of "p4 set". "p4 set" doesn't
      work with "set" on Windows.
  • Change 5906 on 2007/04/30 by sam_stafford@samwise-rivendell
      Some minor fixes to p4rollback.pl. Make sure that target changelist
      is empty (rather than inheriting files from the default changelist,
      which defeats the purpose of putting the work into its own numbered
      change), and eliminate some extraneous linebreaks from the output.


Personal tools