Search code examples
version-controlperforceperforce-integrate

P4V edit first revision of integrated files before submitting


I would like to copy some new code files created for a client-specific project back into our main code-base using integrate. However, I would also like to strip out some client-specific functionality from the code for the first revision of the main line. So far I can't tell if there is a way for me to both integrate and edit code in a single step, without first submitting the unedited code and then immediately checking it out for edit again. I would especially like to do this within the confines of P4V, but would consider command line approaches as well. Your insight is appreciated.


Solution

  • You can certainly integrate and edit in a single changelist. There are pros and cons to this approach: some people appreciate, as you pointed out, that the code that is submitted back to the main codebase contains the desired edits immediately, without requiring a separate revision to be submitted, while others prefer the clarity of being able to see the edits explicitly in their own changelist.

    Regardless, the overall procedure for this is as follows:

    1. Integrate the files back into main, and resolve the merges
    2. Open the files in main for edit
    3. Make the appropriate edits, compile, test, etc.
    4. Submit your changes

    By reopening the file for edit prior to the submit, you convert a simple "branch" integration into a "add-from" integration, where the file is marked as both branched from another file and edited.

    Often, when considering alternate approaches like this, I like to have a small test server where I can experiment with different sequences of commands, to see what the history will look like.

    In this particular case, here's a quick example of integrating a new project file back into main, and editing it during the integration, and showing the result. It's all in the command-line, to make it a bit clearer

    C:\Users\Bryan\perforce\client>p4 integrate project/b main/b
    //depot/main/b#1 - branch/sync from //depot/project/b#1
    
    C:\Users\Bryan\perforce\client>p4 opened
    //depot/main/b#1 - branch default change (text)
    
    C:\Users\Bryan\perforce\client>p4 edit main/b
    //depot/main/b#1 - reopened for add
    
    C:\Users\Bryan\perforce\client>p4 opened
    //depot/main/b#1 - add default change (text)
    
    C:\Users\Bryan\perforce\client>vim main/b
    
    C:\Users\Bryan\perforce\client>p4 resolved
    c:\Users\Bryan\perforce\client\main\b - branch from //depot/project/b#1
    
    C:\Users\Bryan\perforce\client>p4 submit -d merge
    Submitting change 4.
    Locking 1 files ...
    add //depot/main/b#1
    Change 4 submitted.
    
    C:\Users\Bryan\perforce\client>p4 filelog //depot/main/b
    //depot/main/b
    ... #1 change 4 add on 2014/12/10 by Bryan@Dell660 (text) 'merge'
    ... ... branch from //depot/project/b#1
    
    C:\Users\Bryan\perforce\client>p4 diff2 //depot/project/b //depot/main/b
    ==== //depot/project/b#1 (text) - //depot/main/b#1 (text) ==== content
    1c1
    < This is b in project
    ---
    > This is b, which came from project but was edited into main.