Search code examples
version-controlperforcep4v

Perforce: How can I get files "as of" a date or revision from before a branch action?


Consider the following revisions of a file:

branch                   -1---2---
                        /               
                       /                
main   100--101-102--103---104---

I am currently in my branch and the file is synced to revision 2. I know that p4 has kept the history of the file, because I used merge and not copy, and indeed the history shows revisions previous to 103 (inclusive) when I look at the history of the file and check the option "Follow branch actions".

I would like to roll it back to revision 103 or before. Is this possible?

Answers for p4v preferred, but I'll take command line statements if that's the only way to do it.


Solution

  • The copy command is the best way of doing this:

    p4 copy main#103 branch
    

    Another option would be to use integ -f:

    p4 integ -f main#103 branch
    p4 resolve -at
    

    One benefit of copy is that if you're doing this across a bunch of files (e.g. main/...@2018/01/01 to get all of main as of Jan 1) and some of them are already identical to the rev you're copying from because they haven't changed in that time, copy will leave them alone, which makes the result less noisy.