p4 merge
Merge 1. To create new files from existing files, preserving their ancestry (branching). 2. To propagate changes from one set of files to another. 3. The process of combining the contents of two conflicting file revisions into a single file, typically using a merge tool, such as P4Merge. one set of files (and/or the stream spec) into another.
Syntax
p4 [g-opts] merge [-c change] [-m max] [-K -n -Ob -q -F] [--from stream] [toFileSpec[RevSpec]]
p4 [g-opts] merge [-c change] [-m max] [-K -n -Ob -q] fromFileSpec[revSpec] toFileSpec
For streams:
p4 [g-opts] merge -S stream [-As | -Af]
Description
Merging files
The p4 merge
command is a simplified form of the
p4 integrate
command. p4 merge
merges a set of changes from source to target files. The command
outputs the scheduled resolves. This command is intended for use with
streams and distributed version control, but is also usable for
traditional
Helix Core Server
branches.
- Use
p4 resolve
to resolve all changes. Then usep4 submit
to commit merged files to the depot. Unresolved files cannot be submitted. - Use
p4 shelve
to shelve merged files orp4 revert
to delete them. - Use the
p4 integrated
andp4 filelog
to display merge history.
In most cases, you can use the p4 merge
and p4 copy
commands to
propagate changes between streams (or branches).
With no arguments, the target defaults to the stream associated with the current stream client, and the source defaults to the current stream parent.
You
can specify a different source with --from
stream_name
, which is an alias for the -P
option. You can specify the stream as a directory name relative to the
current stream depot. For example, --from main
instead of
--from //Ace/main
.
Using the client workspace as a staging area, p4
merge
schedules all affected target files to be resolved
per changes in the source. Target files outside of the current client
view are not affected. Source files need not be within the client
view.
Each file in the target is mapped to a file in the source. Mapping
adjusts automatically for files that have been moved or renamed, as long
as p4 move
was used to
move or rename the files. The scope of source and target files sets must
include both old-named and new-named files for mappings to be adjusted.
Moved source files can schedule moves to be resolved in target files. You
can limit the revisions to be merged using the
revSpec
parameter.
An error message appears if the scope does not include both the old and the new files. For example, an error message appears if you run the merge on a single file that is either the move/add or move/delete of the move pair of actions.
Merging streams
With streams, use p4 merge
to keep a child
stream up to date with a more stable parent stream. This ensures that
when you promote changes back to the stable parent, you do not
inadvertently overwrite any other changes that were checked into the
parent. Files are opened in a pending changelist and scheduled for
resolve as required. To update the parent stream, resolve and submit. By
default, p4 merge
merges changes into the current
stream from its parent, or from another stream specified by the
--from
option. The source and target can also be specified
on the command line as a pair of file paths. More complex merge mappings
can be specified using branch specifications as with p4 integrate
.
Use the
-F
option to force merging against a stream’s expected flow.
You can also use this option to force the generation of a branch view
based on a virtual stream. The mapping itself refers to the underlying
real stream.
stream spec
p4 merge -S stream merges fields from the source stream spec into the target stream spec if those fields have been set to propagate
with p4 streamspec.
The target stream spec becomes opened for edit, along with stream files. Use p4 merge -S stream -As to merge the stream spec only, and p4 merge -S stream -Af to merge files only.
The p4 integrate
and p4 merge
commands select (as the base) the revision with the most edits in common
with the source and the target.
Options
|
Specifies an existing pending changelist in which the files are to be opened. |
|
Force merge operation. Perform the operation when the target
stream is not configured to accept a merge from the source. To
determine a stream’s expected flow of change, use |
|
Specifies a stream other than the parent stream to merge from.
|
-K
|
Suppress keyword expansion when updating +k type files on the client. See File type modifiers. |
|
Limits the number of files merged. This option is useful for scripts that integrate large number of files. It enables them to batch the integrations and minimize the locking-related impact to other users of the shared versioning service. |
|
Preview the merge. |
|
The |
|
Quiet mode, which suppresses normal output messages about the list of files being integrated, copied, or merged. Messages regarding errors or exceptional conditions are displayed. |
-S stream |
Merges fields from the source stream spec into the target stream spec if those fields have been set to The target stream spec becomes opened for edit, along with stream files. To merge the stream spec only, use p4 merge -S stream -As To merge files only, use p4 merge -S stream -Af |
|
See Global options. |
Usage notes
Can File Arguments Use Revision Specifier? | Can File Arguments Use Revision Range? | Minimal Access Level Required |
---|---|---|
Yes |
Yes |
|
Examples
Branches
|
Merge from the specified source branch to the specified target branch. |
Streams
|
Merge into the current stream from its parent. |
|
Merge into the current stream from the |
|
Merge changes |
Related commands
Promote changes to more stable neighbor stream |
|
Propagate changes |
|
Resolve file conflicts |