Merging files between codelines

To create a new codeline (referred to as branchingClosed(noun) A set of related files that exist at a specific location in the Helix Core depot as a result of being copied to that location, as opposed to being added to that location. A group of related files is often referred to as a codeline. (verb) To create a codeline by copying another codeline with the 'p4 integrate', 'p4 copy', or 'p4 populate' command.) or propagate a bug fix or new feature from one codeline to another, you integrate the required files to the target codeline. To integrate files, you open them for integration, specifying source and target, then submit the changelist containing the open files.

P4V performs three types of integration:

  • Branching, which creates a new codeline or branch.

    For more information, see Creating Branches.

  • Merging, which propagates change from one existing codeline to another and prompts you to resolve any conflicts between the codelines
  • Copying, which is reserved for propagating a straightforward duplicate of the files in one codeline to another.

    For more information about copying, see Merging Down and Copying Up between Streams.

If you are merging changes into an existing codeline, you are required to resolve the files to ensure that you do not overwrite other users' changes and to preserve the file’s revision history. Typical steps for propagating changes from one codeline to another are as follows:

  1. Open files for merge.
  2. Submit the changelist.

    If there are conflicts, P4V notifies you and schedules the files for resolve.

  3. Resolve the files, deciding how changed files are to be submitted.
  4. Submit the changelist containing the resolved files.

When you open files for merge, you can specify the mapping of source to target using either a file specification or a branch mapping.

  • File specification: you specify the source and target files when you open files for merging.
  • Branch mapping: you select a branch mapping when you open files for merging. Branch mappings enable you to predefine source and target codelines. For details about branch mappings, see the Helix Core Command-Line (P4) Guide.
Important

Merging Down and Copying Up between Streams is the recommended workflow for propagating changes between streams.

Open files for merge

To open files for merging:

  1. Select the source files and folders, then right-click and choose Merge/Integrate​.

    The Merge/Integrate dialog is displayed.

  2. For Merge method, choose Specify source and target files.

    The source files that you selected in step 1 are listed in the Source files/folders field.

  3. Specify the target files and folders by typing or browsing to the destination.
  4. To specify additional merge options, click the Options disclosure triangle.

    The Options panel appears.

    Specify integration options as follows:

    Resolve and Submit Options: These options enable you to specify whether files are submitted manually or automatically, and to configure how conflicts are resolved.

    Filter Options: Filtering enables you to choose a subset of the revisions that are queued for merging. For more information, see Searching and Filtering.

    Advanced Options: These options enable you to refine the results of the merge as follows:

    • Do not copy newly branched target files to workspace (-v): Create a branch in the depot without retrieving the corresponding files from the depot to your workspace.
    • Enable baseless merges (-i): Perform the integration even if source and target share no common ancestor, using the most-recently-added revision of the source file as the base.
    • Try to integrate changes when source deleted and re-added (-Di): If the target file has been deleted and the source file changed, this option re-branches the source file on top of the target file. If the source file has been deleted and the target file has changed, this option deletes the target file. By default, outstanding edits cannot be integrated with a deleted file.
    • Force integration on all revisions, disregarding integration history (-f): Integrate all revisions of source and target files, including revisions that have already been integrated. Typically used with a specified revision range.
    • Do not get latest revision of selected files (-h): Use the workspace revision of the target file. By default, the head revision of the target file is automatically retrieved into the workspace before integrating.
    • Disregard indirect integration history (-1): Restrict selection of the base file revision to direct (parent-to-child or child-to-parent) integration history.
    • Propagate source filetypes to target files (-t): Assign the target file the same file type as the source file (when integrating to existing target files).
    • Schedule 'branch resolves' (-Rb): Schedules a branch resolve, instead of branching new target files automatically.
    • Schedule 'delete resolves' (-Rd): Schedules a delete resolve, instead of deleting target files automatically.
    • Skip 'cherry-picked' selected revisions (-Rs): Skips cherry-picked revisions that have already been integrated. This option can improve merge results, but can also require multiple resolves per file.
    • Check for opened files and warn prior to merging: Detect whether any of the selected files are open for other actions.

      Note

      P4V uses different P4 commands to apply these integrate flags, depending on the integration method:

      • Stream-to stream method: p4 merge
      • Branch mapping and files and folders methods: p4 integrate

      For more information about these P4 commands and flags, see the Helix Core Command-Line (P4) Reference.

  5. To perform the merge, click Merge.

    The specified files are opened for merge using any options you configured.

  6. Resolve and submit the files.

Click Set Defaults to open the Merge-Integrate preferences page, where you can set default behaviors for the Merge/Integrate dialog.