How to list all the files changed by a perforce change list

前端 未结 5 1650
陌清茗
陌清茗 2020-12-14 15:21

I have a specific change list, and from the command line I want to list all files that were a part of that change list. How do I do this?

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-14 16:10

    user114245 gave the best answer, but only in a comment. I'm adding as an answer to give it more visibility, and to improve a little.

    For change 12345, this is the closest you can get with just a p4 command

    p4 files @=12345
    

    which gives only this output

    //depot/file1#3 - delete change 3 (text)
    //depot/file2#3 - edit change 3 (text)
    //depot/file5#1 - add change 3 (text)
    

    If you want to remove the extraneous info about each file, you'll need to process that output through more tools on the command line. Assuming a standard unixy environment, you can use a single sed command like so

    p4 files @=12345 | sed s/#.*//
    

    to get the desired result

    //depot/file1
    //depot/file2
    //depot/file5
    

    The currently accepted answer by Mike is this

    p4 describe 12345
    

    which gives all of this extra detail in the output

    Change 12345 by day@client1 on 2013/06/21 00:25:28
    
        Some example changes
    
    Affected files ...
    
    ... //depot/file1#3 delete
    ... //depot/file2#3 edit
    ... //depot/file5#1 add
    
    Differences ...
    
    ==== //depot/file2#3 (text) ====
    
    1c1
    < This is file 2
    ---
    > This is file 2 - edited
    

    That was improved on by Doug's answer which uses grep and awk to filter out the noise and just leave the files changed, but the command is quite long

    p4 describe -s 12345 | grep '^\.\.\.' | awk '{print $2}'
    

    I think the solution given here is neater.

提交回复
热议问题