Click or drag to resize

RepositoryCreateStream Method (Stream, Options)

Create a new stream in the repository.

Namespace:  Perforce.P4
Assembly:  p4api.net (in p4api.net.dll) Version: 2023.2.255.3501
Syntax
public Stream CreateStream(
	Stream stream,
	Options options
)

Parameters

stream
Type: Perforce.P4Stream
Stream specification for the new stream
options
Type: Perforce.P4Options
The '-i' flag is required when creating a new stream

Return Value

Type: Stream
The Stream object if new stream was created, null if creation failed
Remarks
The '-i' flag is added if not specified by the caller

p4 help stream

stream -- Create, delete, or modify a stream specification

p4 stream [-P parent] -t type name
p4 stream [-f] [-d] [-o [-v]] [-P parent] -t type name
p4 stream -i [-f]

A stream specification ('spec') names a path in a stream depot to be
treated as a stream. (See 'p4 help streamintro'.) The spec also
defines the stream's lineage, its view, and its expected flow of
change.

The 'p4 stream' command puts the stream spec into a temporary file and
invokes the editor configured by the environment variable $P4EDITOR.
When creating a stream, the type of the stream must be specified with
the '-t' flag. Saving the file creates or modifies the stream spec.

Creating a stream spec does not branch a new stream. To branch a
stream, use 'p4 copy -r -S stream', where 'stream' is the name of a
stream spec.

The stream spec contains the following fields:

Stream: The stream's path in a stream depot, of the form
//depotname/streamname. This is both the name of the stream
spec and the permanent, unique identifier of the stream.

Update: The date this stream spec was last changed.

Access: The date of the last command used with this spec.

Owner: The stream's owner. A stream can be owned by a user, or
owned by a group. Can be changed.

Name: An alternate name of the stream, for use in display outputs.
Defaults to the 'streamname' portion of the stream path.
Can be changed.

Parent: The parent of this stream. Can be 'none' if the stream type
is 'mainline', otherwise must be set to an existing stream
identifier, of the form //depotname/streamname.
Can be changed.

Type: 'mainline', 'virtual', 'development', 'release' or 'task'.
Defines the role of a stream: A 'mainline' may not have a
parent. A 'virtual' stream is not a stream but an alternate
view of its parent stream. The 'development' and 'release'
streams have controlled flow. Can be changed. A 'task'
stream is a lightweight short-lived stream that only
promotes edited files to the repository; branched and
integrated files are stored in shadow tables that are
removed when the task stream is deleted or unloaded.

Flow control is provided by 'p4 copy -S' and 'p4 merge -S'.
These commands restrict the flow of change as follows:

Stream Type Direction of flow Allowed with
----------- ----------------- ------------
development to parent stream 'p4 copy'
task to parent stream 'p4 copy'
release to parent stream 'p4 merge'
development from parent stream 'p4 merge'
release from parent stream 'p4 copy'

Description: An optional description of the stream.

Options: Flags to configure stream behavior. Defaults are marked *:

unlocked * Indicates whether the stream spec is locked
locked against modifications. If locked, the spec
may not be deleted, and only its owner or
group users can modify it.

allsubmit * Indicates whether all users or only the
ownersubmit owner (or group users) of the stream may
submit changes to the stream path.

toparent * Indicates if controlled flow from the
notoparent stream to its parent is expected to occur.

fromparent * Indicates if controlled flow to the stream
nofromparent from its parent is expected to occur.

mergedown * Indicates if merge flow is restricted or
mergeany merge is permitted from any other stream.

The [no]fromparent and [no]toparent options determine if
'p4 copy -S' and 'p4 merge -S' allow change to flow between
a stream and its parent. A 'virtual' stream must have its
flow options set as 'notoparent' and 'nofromparent'. Flow
options are ignored for 'mainline' streams.

Paths: One or more lines that define file paths in the stream view.
Each line is of the form:

<path_type> <view_path> [<depot_path>]

where <path_type> is a single keyword, <view_path> is a file
path with no leading slashes, and the optional <depot_path>
is a file path beginning with '//'. Both <view_path> and
<depot_path> may contain trailing wildcards, but no leading
or embedded wildcards. Lines in the Paths field may appear
in any order. A duplicated <view_path> overrides its
preceding entry.

For example:

share src/...
import lib/abc/... //over/there/abc/...
isolate bin/*

Default is:

share ...

The <path_type> keyword must be one of:

share: <view_path> will be included in client views and
in branch views. Files in this path are accessible
to workspaces, can be submitted to the stream, and
can be integrated with the parent stream.

isolate: <view_path> will be included in client views but
not in branch views. Files in this path are
accessible to workspaces, can be submitted to the
stream, but are not integratable with the parent
stream.

import: <view_path> will be included in client views but
not in branch views. Files in this path are mapped
as in the parent stream's view (the default) or to
<depot_path> (optional); they are accessible to
workspaces, but can not be submitted or integrated
to the stream. If <depot_path> is used it may
include a changelist specifier; clients of that
stream will be limited to seeing revisions at that
change or lower within that depot path.

import+: <view_path> same as 'import' except that files can
be submitted to the import path.

exclude: <view_path> will be excluded from client views
and branch views. Files in this path are not
accessible to workspaces, and can't be submitted
or integrated to the stream.

Paths are inherited by child stream views. A child stream's
paths can downgrade the inherited view, but not upgrade it.
(For instance, a child stream can downgrade a shared path to
an isolated path, but it can't upgrade an isolated path to a
shared path.) Note that <depot_path> is relevant only when
<path_type> is 'import'.

Remapped: Optional; one or more lines that define how stream view paths
are to be remapped in client views. Each line is of the form:

<view_path_1> <view_path_2>

where <view_path_1> and <view_path_2> are Perforce view paths
with no leading slashes and no leading or embedded wildcards.
For example:

... x/...
y/* y/z/*

Line ordering in the Remapped field is significant; if more
than one line remaps the same files, the later line has
precedence. Remapping is inherited by child stream client
views.

Ignored: Optional; a list of file or directory names to be ignored in
client views. For example:

/tmp # ignores files named 'tmp'
/tmp/... # ignores dirs named 'tmp'
.tmp # ignores file names ending in '.tmp'

Lines in the Ignored field may appear in any order. Ignored
names are inherited by child stream client views.

The -d flag causes the stream spec to be deleted. A stream spec may
not be deleted if it is referenced by child streams or stream clients.
Deleting a stream spec does not remove stream files, but it does mean
changes can no longer be submitted to the stream's path.

The -o flag causes the stream spec to be written to the standard
output. The user's editor is not invoked. -v may be used with -o to
expose the automatically generated client view for this stream.
('p4 help branch' describes how to expose the branch view.)

The -P flag can be used to insert a value into the Parent field of a
new stream spec. It has no effect on an existing spec.

The -t flag is used to insert a value into the type field of a
new stream spec and to adjust the default fromparent option
for a new 'release' -type stream. The flag has no effect on an
existing spec.

The -i flag causes a stream spec to be read from the standard input.
The user's editor is not invoked.

The -f flag allows a user other than the owner to modify or delete a
locked stream. It requires 'admin' access granted by 'p4 protect'.

Examples
To create a new mainline stream:
Stream main  = new Stream();
string mainTargetId = "//Rocket/mainline";
main.Id = mainTargetId;
main.Type = StreamType.Mainline;
main.Parent = new DepotPath("none");
main.Options = new StreamOptionEnum(StreamOption.None);
main.Name = "mainline";
main.Paths = new ViewMap();
MapEntry p1 = new MapEntry(MapType.Import, new DepotPath("..."), null);
main.Paths.Add(p1);
MapEntry p2 = new MapEntry(MapType.Share, new DepotPath("core/gui/..."), null);
main.Paths.Add(p2);
main.OwnerName = "admin";
Stream mainline = rep.CreateStream(main, null);
To create a new development type stream with the parent //Rocket/mainline:
Stream dev = new Stream();
string developmentTargetId = "//Rocket/dev";
dev.Id = developmentTargetId;
dev.Type = StreamType.Development;
dev.Parent = new DepotPath("//Rocket/mainline");
dev.Name = "releasetest";
dev.Options = new StreamOptionEnum(StreamOption.None);
dev.Paths = new ViewMap();
MapEntry devp1 = new MapEntry(MapType.Share, new DepotPath("..."), null);
dev.Paths.Add(devp1);
dev.OwnerName = "admin";
Stream dev1 = rep.CreateStream(dev, null);
See Also