Search code examples
synchronizationperforcerevisions

perforce - sync multiple files at specific revisions quickly


Is there a way to synch multiple files at specific revisions quickly.

For example specify a list of files and revisions as follows: foo#1 bar#4 baz#3

I could sync these in a foreach loop in he shell individually - but this would be slow for large lists. So is there a quick/batch way of doing this?

I do know about using labels - but in this case we must assume no label existed for this set of files and revisions - the only source we have is the list as shown above.


Solution

  • You can use a file as an argument with the -x global option flag, as Bryan mentioned in his comment.

    EXAMPLE - sync
    
    -- Notice the file contents of 'syncfile.txt' with three filenames, at specific revisions.
    
    $ cat syncfile.txt
    foo#1
    bar#4
    baz#3
    
    -- The client workspace currently has all the head revisions.
    
    $ p4 have //depot/test/...
    //depot/test/bar#5 - /home/admin/depot/test/bar
    //depot/test/baz#4 - /home/admin/depot/test/baz
    //depot/test/foo#5 - /home/admin/depot/test/foo
    
    -- Now the file is passed as an argument with the 'sync' command, and the updates display
    
    $ p4 -x syncfile.txt sync
    //depot/test/foo#1 - updating /home/admin/depot/test/foo
    //depot/test/bar#4 - updating /home/admin/depot/test/bar
    //depot/test/baz#3 - updating /home/admin/depot/test/baz
    
    -- Running the 'have' command again to verify that indeed the specific revisions were synced.
    
    $ p4 have //depot/test/...
    //depot/test/bar#4 - /home/admin/depot/test/bar
    //depot/test/baz#3 - /home/admin/depot/test/baz
    //depot/test/foo#1 - /home/admin/depot/test/foo
    
    EXAMPLE - ADD
    
    -- Notice the file contents of 'addfiles.txt' with three filenames.
    
    $ cat addfiles.txt
    who
    me
    you
    
    -- The file is passed as an argument with the 'add' command, and the files listed are added.
    
    $ p4 -x addfiles.txt add
    //depot/test/who#1 - opened for add
    //depot/test/me#1 - opened for add
    //depot/test/you#1 - opened for add
    

    Here are examples of how to use the '-x' flag in documentation:

    http://answers.perforce.com/articles/KB_Article/The-x-Flag

    http://answers.perforce.com/articles/KB_Article/Adding-a-Directory-Tree

    http://answers.perforce.com/articles/KB_Article/Integ-Using-the-x-Global-Option

    http://www.perforce.com/perforce/doc.current/manuals/cmdref/global.options.html