199

I want to reverse the changes from one of my checkins. In the right-click context menu of the particular changelist, there are these two options:

  • Rollback...
  • Back Out Submitted Changelist

What is the difference between these two? In what situations should I use either one?

Dave Andersen
  • 5,120
  • 2
  • 26
  • 28
  • 3
    In this case, 'Back Out Submitted Changelist' was the right option for my situation (only wanting to revert changes from the checkin). Thanks for the great answers. – Dave Andersen May 05 '10 at 23:40

6 Answers6

223

Both of these operations restore a set of files to a previous state and are essentially faster, safer ways of undoing mistakes than using the p4 obliterate command (and you don't need admin access to use them).

In the case of "Rollback...", this could be any number of files, even an entire depot. You can tell it to rollback to a specific revision, changelist, or label. The files are restored to the state they were in at the time of creation of that revision, changelist, or label.

In the case of "Back Out Submitted Changelist #####", the restore operation is restricted to the files that were submitted in changelist #####. Those files are restored to the state they were in before you submitted that changelist, provided no changes have been made to those files since. If subsequent changes have been made to any of those files, Perforce will tell you that those files are now out of date. You will have to sync to the head revision and then resolve the differences. This way you don't inadvertently clobber any changes that you actually want to keep.

Both operations work by essentially submitting old revisions as new revisions. When you perform a "Rollback...", you are restoring the files to the state they were in at a specific point in time, regardless of what has happened to them since. When you perform a "Back out...", you are attempting to undo the changes you made at a specific point in time, while maintaining the changes that have occurred since.

raven
  • 17,276
  • 15
  • 76
  • 110
  • 18
    I **think** "Back Out Submitted Changelist #####" will **try** to keep changes that were made to the same files after the given change list. – Ian Ringrose Aug 24 '11 at 12:19
  • 1
    @Ian: Good observation. When I wrote this I was thinking along the lines of _immediately_ correcting a mistake. As is usually the case, should you realize you want to undo something _much later_, it gets more complicated. I refined my answer. – raven Aug 24 '11 at 18:52
  • @IanRingrose I just did a "backout" operation, and it looks like it *doesn't* attempt to keep the changes that were made afterwards. I had to do a sync and then resolve in order to get the changes back in which were submitted after the backout. – gdw2 Mar 22 '12 at 21:20
  • @gdw2, I think if you did a "Rollback" you would then not get the option to "resolve in order to get the changes back in which were submitted after the ..." – Ian Ringrose Mar 23 '12 at 13:01
  • 1
    Although the files are restored to the the state they were in, the metadata is not. Trying to rollback an integration from another branch won't allow you to perform that integration again because the metadata says its already integrated. – Will Brode Oct 02 '18 at 22:43
17

Reverse a changelist submission

You cannot undo a successful changelist submission, but you can reverse previously submitted changes in two ways:

Rollback restores a file or set of files back to a specified changelist, date or revision. Any changes made after that point in time are not retained. Back out removes specific changes made at a given changelist, date or revision but allows a user to keep changes made in subsequent revisions.

For details please refer to https://www.perforce.com/perforce/r13.1/manuals/p4v/Working_with_changelists.html

Sahil Singh
  • 2,396
  • 29
  • 46
Smartmarkey
  • 1,847
  • 4
  • 22
  • 24
8

Backout restores or undoes our changes. The way it does this is that, P4 undoes the changes in a changelist (default or new) on our local workspace. We then have to submit/commit this backedout changelist as we do other changeslists. The second part is important here, as it doesn't automatically backout the changelist on the server, we have to submit the backedout changelist (which makes sense after you do it, but i was initially assuming it does that automatically).

As pointed by others, Rollback has greater powers - It can restore changes to a specific date, changelist or a revision#

user841717
  • 163
  • 3
  • 6
4

Rollback... will prompt you to select a folder to rollback, ie, it will work on specific folders, and you can rollback to labels or changlists or dates. Back out works on the files in specific changelists.

akf
  • 36,245
  • 8
  • 81
  • 94
4

I explain this to users by comparing Perforce changelists to a stack (from data structures).

Backing out removes one item from anywhere in the stack.

Rolling back removes n items from the top of the stack.

gmaghera
  • 505
  • 4
  • 7
1

At its simplest, the difference is one of plurality:

  • Backout backs out of a single changelist (whether the most recent or not). i.e. it undoes a single changelist.
  • Rollback rolls back changes as much as it needs to in order to get to a previous changelist. i.e. it undoes multiple changelists.

I used to forget which one is which and end up having to look it up many times. To fix this problem, imagine rolling back as several rotations then hopefully the fact that rollback is plural will help you (and me!) remember which one is which. Backout sounds 'less plural' than rollback to me. Imagine backing out of a single parking space.

So, the mnemonic is:

  • Rollback → multiple rotations
  • Backout → back out of a single car parking space

I hope this helps!

darrenp
  • 3,995
  • 1
  • 23
  • 21