perforce: sync to an earlier revision

Asad Iqbal picture Asad Iqbal · Aug 21, 2012 · Viewed 40.7k times · Source

I want to test a fix and to compare the behavior before the fix vs. now; I need to sync to a the earlier version. So, if the fix was committed in revision x; how can I sync to one revision before, say x0?

Answer

Elpis picture Elpis · Jun 22, 2015

Say that you want to go back to revision 'n' from revison 'n+1' (rollback). You can take the following steps:

  1. p4 sync ...@n

    This will sync your files to the older version that you want

  2. p4 edit ...

    Open all the files for edit or do "p4 edit filename" to open only a particular file for editing.

  3. p4 sync ...@n+1

    Before submiting you need to sync files to the latest revision on the repository.

  4. p4 resolve -ay

    This will accept the changes that you have made, ie, revert all the changes done when you moved from revision 'n' to 'n-1'. So effectively, all your files have been rolled back to revision 'n' in your local repository.

  5. p4 submit ...

    Go ahead and submit the changes. This will roll back all main repository to revision 'n'. Effectively the revisions 'n' and 'n+2'(current) will be identical.

  6. p4 diff2 -q repository@n repository@n+2

    This is just to verify if have rolled back the files. This should show that you have no differing files in the two revisions.

I found the solution from this link .