Search code examples
bashshellcommand-lineperforcep4v

Create a new mapping for an existing perforce workspace using command line


Is it possible to create a new mapping for an existing perforce workspace using command line? Could you provide an example?


Solution

  • Yes.

    p4 --field 'Client=MyClient' --field 'Root=/usr/foo/myclient' --field 'View=//depot/foo/... //MyClient/foo/...' --field 'View+=//depot/bar/... //MyClient/bar/...' client -o
    Client: MyClient
    
    Update: 2017/11/28 20:56:52
    
    Access: 2017/12/12 15:26:01
    
    Owner:  bobdylan
    
    Host:   highway66
    
    Description:
            Created by bobdylan.
    
    Root:   /usr/foo/myclient
    
    Options:        noallwrite noclobber nocompress unlocked nomodtime rmdir
    
    SubmitOptions:  revertunchanged
    
    LineEnd:        local
    
    View:
            //depot/foo/... //MyClient/foo/...
            //depot/bar/... //MyClient/bar/... 
    

    ```

    That simply outputs it to STDOUT. What you need is to append ... | p4 client -i. That will create a new client with that form.

    Inspired by Sam Stafford, https://stackoverflow.com/a/38969939/1540600.

    Please note the '+' sign after the second "View".