开发者

Perforce (P4): Is there such thing as a 'reverse sync', that pushes any/all changes from your local directory to the sever?

开发者 https://www.devze.com 2023-04-05 19:16 出处:网络
I know this is a strange question, but is there a p4 command that is the reverse of \'sync\'?That i开发者_JS百科s, I\'d like whatever files are in my local workspace directory to be pushed to the depo

I know this is a strange question, but is there a p4 command that is the reverse of 'sync'? That i开发者_JS百科s, I'd like whatever files are in my local workspace directory to be pushed to the depot.

I know your first thought is probably "but WHY?", and the answer is, it's complicated.


Reconciling offline work could help you. It pushes files that are added, or changed or deleted . Its a bit trickier with renamed files.

Out of curiosity. What exactly is "it's complicated"


Both 'submit' and 'shelve' can send file content from your local workspace to the depot.

In either case, you have to use 'add' or 'edit' first to mark the files to be sent to the depot. (How you do this depends on the client tool you're using.)


Here's a script, derived from the O'Reilly Perforce book

You probably want to start with

    p4 sync -k ...

which makes perforce think it has synchronized to the current head, but in fact makes no changes to the filesystem. So the below diffs will behave (to perforce) like changes to the current head.

    # a reverse 'synchronize' (sync what's on disk with what's in the depot)
    # see "practical perforce" (o'reilly) page 46
    #
    # changed files
    p4 diff -se | p4 -x- edit
    #
    # deleted files
    p4 diff -sd | p4 -x- delete
    #
    # added files
    find . -type f -o -type l | p4 -x- add -f 

I have not tested the above in isolation (it came from a longer script that has been widely used) but I believe it should work.

0

精彩评论

暂无评论...
验证码 换一张
取 消