/*******************************************************************************
Copyright (c) 2011, Perforce Software, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
/*******************************************************************************
* Name : Repository.Client.cs
*
* Author : dbb
*
* Description : Class used to abstract a client in Perforce.
*
******************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Perforce.P4
{
public partial class Repository
{
///
/// Create a new client in the repository.
///
/// Client specification for the new user
/// The '-i' flags is required when creating a new user
/// The Client object if new user was created, null if creation failed
/// The '-i' flag is added if not specified by the caller
///
///
p4 help client
///
///
client -- Create or edit a client workspace specification and its view
///
workspace -- Synonym for 'client'
///
///
p4 client [-f -t template] [name]
///
p4 client -d [[-f] [-Fs]]name
///
p4 client -o [-t template] [name]
///
p4 client -S stream [[-c change] -o] [name]
///
p4 client -s [-f] -S stream [name]
///
p4 client -s [-f] -t template [name]
///
p4 client -i [-f]
///
///
Creates a new client specification ('spec') or edits an existing
///
spec. A client spec is a named mapping of depot files to workspace
///
files.
///
///
The 'p4 client' command puts the client spec into a temporary file
///
and invokes the editor configured by the environment variable
///
$P4EDITOR. For new workspaces, the client name defaults to the
///
$P4CLIENT environment variable, if set, or to the current host name.
///
Saving the file creates or modifies the client spec.
///
///
The client spec contains the following fields:
///
///
Client: The client name.
///
///
Host: If set, restricts access to the named host.
///
If unset, access is allowed from any host.
///
///
Owner: The user who created this client.
///
///
Update: The date that this spec was last modified.
///
///
Access: The date that this client was last used in any way.
///
///
Description: A short description of the workspace.
///
///
Root: The root directory of the workspace (specified in local
///
file system syntax), under which all versioned files
///
will be placed. If you change this setting, you must
///
physically relocate any files that currently reside
///
there. On Windows client machines, you can specify the
///
root as "null" to enable you to map files to multiple
///
drives.
///
///
AltRoots: Up to two optional alternate client workspace roots.
///
The first of the main and alternate roots to match the
///
client program's current working directory is used. If
///
none match, the main root is used. 'p4 info' displays
///
the root that is being used.
///
///
Options: Flags to configure the client behavior. Defaults
///
are marked with *.
///
///
allwrite Leaves all files writable on the client;
///
noallwrite * by default, only files opened by 'p4 edit'
///
are writable. If set, files might be clobbered
///
as a result of ignoring the clobber option
///
(see below).
///
///
clobber Permits 'p4 sync' to overwrite writable
///
noclobber * files on the client. noclobber is ignored if
///
allwrite is set.
///
///
compress Compresses data sent between the client
///
nocompress * and server to speed up slow connections.
///
///
locked Allows only the client owner to use or change
///
unlocked * the client spec. Prevents the client spec from
///
being deleted.
///
///
modtime Causes 'p4 sync' and 'p4 submit' to preserve
///
nomodtime * file modification time, as with files with the
///
+m type modifier. (See 'p4 help filetypes'.)
///
With nomodtime, file timestamps are updated by
///
sync and submit operations.
///
///
rmdir Makes 'p4 sync' attempt to delete a workspace
///
normdir * directory when all files in it are removed.
///
///
SubmitOptions: Flags to change submit behaviour.
///
///
submitunchanged All open files are submitted (default).
///
///
revertunchanged Files that have content or type changes
///
are submitted. Unchanged files are
///
reverted.
///
///
leaveunchanged Files that have content or type changes
///
are submitted. Unchanged files are moved
///
to the default changelist.
///
///
+reopen Can be appended to the submit option flag
///
to cause submitted files to be reopened in
///
the default changelist.
///
Example: submitunchanged+reopen
///
///
LineEnd: Set line-ending character(s) for client text files.
///
///
local mode that is native to the client (default).
///
unix linefeed: UNIX style.
///
mac carriage return: Macintosh style.
///
win carriage return-linefeed: Windows style.
///
share hybrid: writes UNIX style but reads UNIX,
///
Mac or Windows style.
///
///
View: Maps files in the depot to files in your client
///
workspace. Defines the files that you want in your
///
client workspace and specifies where you want them
///
to reside. The default view maps all depot files
///
onto the client. See 'p4 help views' for view syntax.
///
A new view takes effect on the next 'p4 sync'.
///
///
Stream: The stream to which this client's view will be dedicated.
///
(Files in stream paths can be submitted only by dedicated
///
stream clients.) When this optional field is set, the
///
View field will be automatically replaced by a stream
///
view as the client spec is saved.
///
///
StreamAtChange:
///
Stream meta-data (for view creation) is versioned.
///
When StreamAtChange is set, the stream hierarchy is
///
constructed back-in-time to reproduce the view that was
///
available to clients in the past. With this field set
///
changes cannot be be submitted from the client.
///
StreamAtChange is optional; Stream must be set as well.
///
///
ServerID: If set, restricts usage to the named server.
///
If unset, usage is allowed on the master server and on
///
any replicas of the master other than Edge Servers.
///
///
Note: changing the client root does not actually move the client
///
files; you must relocate them manually. Similarly, changing
///
the 'LineEnd' option does not actually update the client files;
///
you can refresh them with 'p4 sync -f'.
///
///
The -d flag deletes the specified spec, as long as the client
///
workspace has no opened files or pending changes. (See 'p4 help
///
opened'.) The -f flag forces the delete. The -Fs option used with -f
///
forces client deletion even when the user has shelved changes. In
///
this case, the shelved changes are left intact.
///
///
The -o flag writes the named client spec to the standard output.
///
The user's editor is not invoked.
///
///
The -i flag reads a client spec from the standard input. The
///
user's editor is not invoked.
///
///
The -t template flag, where 'template' is the name of another client
///
spec, causes the View and Options fields to be replaced by those of
///
the template.
///
///
The -f flag can force the updating of locked clients; normally
///
locked clients can only be modified by their owner. -f also allows
///
the last modified date to be set. The -f flag requires 'admin'
///
access granted by 'p4 protect'.
///
///
The -s flag is used to switch an existing client spec's view without
///
invoking the editor. It can be used with -S to switch to a stream
///
view, or with -t to switch to a view defined in another client spec.
///
Switching views is not allowed in a client that has opened files.
///
The -f flag can be used with -s to force switching with opened files.
///
View switching has no effect on files in a client workspace until
///
'p4 sync' is run.
///
///
Without -s, the '-S stream' flag can be used to create a new client
///
spec dedicated to a stream. If the client spec already exists, and
///
-S is used without -s, it is ignored. Using -S sets the client's
///
Stream field. The special syntax '-S //a/stream@changelist' can be
///
be used to set both Stream and StreamAtChange at the same time.
///
///
The '-S stream' flag can be used with '-o -c change' to inspect an
///
old stream client view. It yields the client spec that would have
///
been created for the stream at the moment the change was recorded.
///
///
A server of type 'build-server' (see 'p4 help server') is a replica
///
which supports build farm integration, and the 'p4 client' command
///
may be used to create or edit client workspaces on a build-server.
///
Such workspaces may issue the 'p4 sync' command, in addition to any
///
read-only command supported by the replica. For more information, run
///
'p4 help buildserver'.
///
///
When creating or editing a client workspace for a build-server,
///
the client specified by the optional 'name' argument, as well as the
///
client specified by the $P4CLIENT environment variable or via the
///
global '-c client' argument must not exist, or must be restricted
///
to this server; this command may not be used to create or edit a
///
workspace that is not restricted to this build-server.
///
///
///
///
/// To create a client named main_ws:
///
/// Client c = Repository.GetClient("main_ws");
/// c.OwnerName= "bsmith";
/// c.Description = "client for main dev";
/// Repository.CreateClient(c, null);
///
/// To create a client named main_ws using existing admin_main_ws
/// as a template:
///
/// ClientCmdOptions opts =
/// new ClientCmdOptions(ClientCmdFlags.None, "admin_main_ws", null, 0);
/// Client c = Repository.GetClient("main_ws",opts);
/// Repository.CreateClient(c, null);
///
/// To create a streams client named main_ws for the mainline stream
/// //MobileApp/Main:
///
/// ClientCmdOptions opts =
/// new ClientCmdOptions(ClientCmdFlags.None, null, "//MobileApp/Main", 0);
/// Client c = Repository.GetClient("main_ws",opts);
/// Repository.CreateClient(c, null);
///
///
///
public Client CreateClient(Client client, Options options)
{
if (client == null)
{
throw new ArgumentNullException("client");
}
P4Command cmd = new P4Command(this, "client", true);
cmd.DataSet = client.ToString();
if (options == null)
{
options = new Options();
}
options["-i"] = null;
P4CommandResult results = cmd.Run(options);
if (results.Success)
{
return client;
}
else
{
P4Exception.Throw(results.ErrorList);
}
return null;
}
///
/// Create a new client in the repository.
///
/// Client specification for the new user
/// The '-i' flags is required when creating a new user
/// The Client object if new user was created, null if creation failed
/// The '-i' flag is added if not specified by the caller
///
///
p4 help client
///
///
client -- Create or edit a client workspace specification and its view
///
workspace -- Synonym for 'client'
///
///
p4 client [-f -t template] [name]
///
p4 client -d [[-f] [-Fs]]name
///
p4 client -o [-t template] [name]
///
p4 client -S stream [[-c change] -o] [name]
///
p4 client -s [-f] -S stream [name]
///
p4 client -s [-f] -t template [name]
///
p4 client -i [-f]
///
///
Creates a new client specification ('spec') or edits an existing
///
spec. A client spec is a named mapping of depot files to workspace
///
files.
///
///
The 'p4 client' command puts the client spec into a temporary file
///
and invokes the editor configured by the environment variable
///
$P4EDITOR. For new workspaces, the client name defaults to the
///
$P4CLIENT environment variable, if set, or to the current host name.
///
Saving the file creates or modifies the client spec.
///
///
The client spec contains the following fields:
///
///
Client: The client name.
///
///
Host: If set, restricts access to the named host.
///
If unset, access is allowed from any host.
///
///
Owner: The user who created this client.
///
///
Update: The date that this spec was last modified.
///
///
Access: The date that this client was last used in any way.
///
///
Description: A short description of the workspace.
///
///
Root: The root directory of the workspace (specified in local
///
file system syntax), under which all versioned files
///
will be placed. If you change this setting, you must
///
physically relocate any files that currently reside
///
there. On Windows client machines, you can specify the
///
root as "null" to enable you to map files to multiple
///
drives.
///
///
AltRoots: Up to two optional alternate client workspace roots.
///
The first of the main and alternate roots to match the
///
client program's current working directory is used. If
///
none match, the main root is used. 'p4 info' displays
///
the root that is being used.
///
///
Options: Flags to configure the client behavior. Defaults
///
are marked with *.
///
///
allwrite Leaves all files writable on the client;
///
noallwrite * by default, only files opened by 'p4 edit'
///
are writable. If set, files might be clobbered
///
as a result of ignoring the clobber option
///
(see below).
///
///
clobber Permits 'p4 sync' to overwrite writable
///
noclobber * files on the client. noclobber is ignored if
///
allwrite is set.
///
///
compress Compresses data sent between the client
///
nocompress * and server to speed up slow connections.
///
///
locked Allows only the client owner to use or change
///
unlocked * the client spec. Prevents the client spec from
///
being deleted.
///
///
modtime Causes 'p4 sync' and 'p4 submit' to preserve
///
nomodtime * file modification time, as with files with the
///
+m type modifier. (See 'p4 help filetypes'.)
///
With nomodtime, file timestamps are updated by
///
sync and submit operations.
///
///
rmdir Makes 'p4 sync' attempt to delete a workspace
///
normdir * directory when all files in it are removed.
///
///
SubmitOptions: Flags to change submit behaviour.
///
///
submitunchanged All open files are submitted (default).
///
///
revertunchanged Files that have content or type changes
///
are submitted. Unchanged files are
///
reverted.
///
///
leaveunchanged Files that have content or type changes
///
are submitted. Unchanged files are moved
///
to the default changelist.
///
///
+reopen Can be appended to the submit option flag
///
to cause submitted files to be reopened in
///
the default changelist.
///
Example: submitunchanged+reopen
///
///
LineEnd: Set line-ending character(s) for client text files.
///
///
local mode that is native to the client (default).
///
unix linefeed: UNIX style.
///
mac carriage return: Macintosh style.
///
win carriage return-linefeed: Windows style.
///
share hybrid: writes UNIX style but reads UNIX,
///
Mac or Windows style.
///
///
View: Maps files in the depot to files in your client
///
workspace. Defines the files that you want in your
///
client workspace and specifies where you want them
///
to reside. The default view maps all depot files
///
onto the client. See 'p4 help views' for view syntax.
///
A new view takes effect on the next 'p4 sync'.
///
///
Stream: The stream to which this client's view will be dedicated.
///
(Files in stream paths can be submitted only by dedicated
///
stream clients.) When this optional field is set, the
///
View field will be automatically replaced by a stream
///
view as the client spec is saved.
///
///
StreamAtChange:
///
Stream meta-data (for view creation) is versioned.
///
When StreamAtChange is set, the stream hierarchy is
///
constructed back-in-time to reproduce the view that was
///
available to clients in the past. With this field set
///
changes cannot be be submitted from the client.
///
StreamAtChange is optional; Stream must be set as well.
///
///
ServerID: If set, restricts usage to the named server.
///
If unset, usage is allowed on the master server and on
///
any replicas of the master other than Edge Servers.
///
///
Note: changing the client root does not actually move the client
///
files; you must relocate them manually. Similarly, changing
///
the 'LineEnd' option does not actually update the client files;
///
you can refresh them with 'p4 sync -f'.
///
///
The -d flag deletes the specified spec, as long as the client
///
workspace has no opened files or pending changes. (See 'p4 help
///
opened'.) The -f flag forces the delete. The -Fs option used with -f
///
forces client deletion even when the user has shelved changes. In
///
this case, the shelved changes are left intact.
///
///
The -o flag writes the named client spec to the standard output.
///
The user's editor is not invoked.
///
///
The -i flag reads a client spec from the standard input. The
///
user's editor is not invoked.
///
///
The -t template flag, where 'template' is the name of another client
///
spec, causes the View and Options fields to be replaced by those of
///
the template.
///
///
The -f flag can force the updating of locked clients; normally
///
locked clients can only be modified by their owner. -f also allows
///
the last modified date to be set. The -f flag requires 'admin'
///
access granted by 'p4 protect'.
///
///
The -s flag is used to switch an existing client spec's view without
///
invoking the editor. It can be used with -S to switch to a stream
///
view, or with -t to switch to a view defined in another client spec.
///
Switching views is not allowed in a client that has opened files.
///
The -f flag can be used with -s to force switching with opened files.
///
View switching has no effect on files in a client workspace until
///
'p4 sync' is run.
///
///
Without -s, the '-S stream' flag can be used to create a new client
///
spec dedicated to a stream. If the client spec already exists, and
///
-S is used without -s, it is ignored. Using -S sets the client's
///
Stream field. The special syntax '-S //a/stream@changelist' can be
///
be used to set both Stream and StreamAtChange at the same time.
///
///
The '-S stream' flag can be used with '-o -c change' to inspect an
///
old stream client view. It yields the client spec that would have
///
been created for the stream at the moment the change was recorded.
///
///
A server of type 'build-server' (see 'p4 help server') is a replica
///
which supports build farm integration, and the 'p4 client' command
///
may be used to create or edit client workspaces on a build-server.
///
Such workspaces may issue the 'p4 sync' command, in addition to any
///
read-only command supported by the replica. For more information, run
///
'p4 help buildserver'.
///
///
When creating or editing a client workspace for a build-server,
///
the client specified by the optional 'name' argument, as well as the
///
client specified by the $P4CLIENT environment variable or via the
///
global '-c client' argument must not exist, or must be restricted
///
to this server; this command may not be used to create or edit a
///
workspace that is not restricted to this build-server.
///
///
///
///
/// To create a client named main_ws:
///
/// Client c = Repository.GetClient("main_ws");
/// c.OwnerName= "bsmith";
/// c.Description = "client for main dev";
/// Repository.CreateClient(c);
///
/// To create a client named main_ws using existing admin_main_ws
/// as a template:
///
/// ClientCmdOptions opts =
/// new ClientCmdOptions(ClientCmdFlags.None, "admin_main_ws", null, 0);
/// Client c = Repository.GetClient("main_ws",opts);
/// Repository.CreateClient(c);
///
/// To create a streams client named main_ws for the mainline stream
/// //MobileApp/Main:
///
/// ClientCmdOptions opts =
/// new ClientCmdOptions(ClientCmdFlags.None, null, "//MobileApp/Main", 0);
/// Client c = Repository.GetClient("main_ws",opts);
/// Repository.CreateClient(c);
///
///
public Client CreateClient(Client client)
{
return CreateClient(client, null);
}
///
/// Update the record for a client in the repository
///
/// Client specification for the client being updated
/// The Client object if new client was saved, null if creation failed
///
/// Create a new client in the repository.
///
/// Client specification for the new user
/// The '-i' flags is required when creating a new user
/// The Client object if new user was created, null if creation failed
/// The '-i' flag is added if not specified by the caller
///
///
p4 help client
///
///
client -- Create or edit a client workspace specification and its view
///
workspace -- Synonym for 'client'
///
///
p4 client [-f -t template] [name]
///
p4 client -d [[-f] [-Fs]]name
///
p4 client -o [-t template] [name]
///
p4 client -S stream [[-c change] -o] [name]
///
p4 client -s [-f] -S stream [name]
///
p4 client -s [-f] -t template [name]
///
p4 client -i [-f]
///
///
Creates a new client specification ('spec') or edits an existing
///
spec. A client spec is a named mapping of depot files to workspace
///
files.
///
///
The 'p4 client' command puts the client spec into a temporary file
///
and invokes the editor configured by the environment variable
///
$P4EDITOR. For new workspaces, the client name defaults to the
///
$P4CLIENT environment variable, if set, or to the current host name.
///
Saving the file creates or modifies the client spec.
///
///
The client spec contains the following fields:
///
///
Client: The client name.
///
///
Host: If set, restricts access to the named host.
///
If unset, access is allowed from any host.
///
///
Owner: The user who created this client.
///
///
Update: The date that this spec was last modified.
///
///
Access: The date that this client was last used in any way.
///
///
Description: A short description of the workspace.
///
///
Root: The root directory of the workspace (specified in local
///
file system syntax), under which all versioned files
///
will be placed. If you change this setting, you must
///
physically relocate any files that currently reside
///
there. On Windows client machines, you can specify the
///
root as "null" to enable you to map files to multiple
///
drives.
///
///
AltRoots: Up to two optional alternate client workspace roots.
///
The first of the main and alternate roots to match the
///
client program's current working directory is used. If
///
none match, the main root is used. 'p4 info' displays
///
the root that is being used.
///
///
Options: Flags to configure the client behavior. Defaults
///
are marked with *.
///
///
allwrite Leaves all files writable on the client;
///
noallwrite * by default, only files opened by 'p4 edit'
///
are writable. If set, files might be clobbered
///
as a result of ignoring the clobber option
///
(see below).
///
///
clobber Permits 'p4 sync' to overwrite writable
///
noclobber * files on the client. noclobber is ignored if
///
allwrite is set.
///
///
compress Compresses data sent between the client
///
nocompress * and server to speed up slow connections.
///
///
locked Allows only the client owner to use or change
///
unlocked * the client spec. Prevents the client spec from
///
being deleted.
///
///
modtime Causes 'p4 sync' and 'p4 submit' to preserve
///
nomodtime * file modification time, as with files with the
///
+m type modifier. (See 'p4 help filetypes'.)
///
With nomodtime, file timestamps are updated by
///
sync and submit operations.
///
///
rmdir Makes 'p4 sync' attempt to delete a workspace
///
normdir * directory when all files in it are removed.
///
///
SubmitOptions: Flags to change submit behaviour.
///
///
submitunchanged All open files are submitted (default).
///
///
revertunchanged Files that have content or type changes
///
are submitted. Unchanged files are
///
reverted.
///
///
leaveunchanged Files that have content or type changes
///
are submitted. Unchanged files are moved
///
to the default changelist.
///
///
+reopen Can be appended to the submit option flag
///
to cause submitted files to be reopened in
///
the default changelist.
///
Example: submitunchanged+reopen
///
///
LineEnd: Set line-ending character(s) for client text files.
///
///
local mode that is native to the client (default).
///
unix linefeed: UNIX style.
///
mac carriage return: Macintosh style.
///
win carriage return-linefeed: Windows style.
///
share hybrid: writes UNIX style but reads UNIX,
///
Mac or Windows style.
///
///
View: Maps files in the depot to files in your client
///
workspace. Defines the files that you want in your
///
client workspace and specifies where you want them
///
to reside. The default view maps all depot files
///
onto the client. See 'p4 help views' for view syntax.
///
A new view takes effect on the next 'p4 sync'.
///
///
Stream: The stream to which this client's view will be dedicated.
///
(Files in stream paths can be submitted only by dedicated
///
stream clients.) When this optional field is set, the
///
View field will be automatically replaced by a stream
///
view as the client spec is saved.
///
///
StreamAtChange:
///
Stream meta-data (for view creation) is versioned.
///
When StreamAtChange is set, the stream hierarchy is
///
constructed back-in-time to reproduce the view that was
///
available to clients in the past. With this field set
///
changes cannot be be submitted from the client.
///
StreamAtChange is optional; Stream must be set as well.
///
///
ServerID: If set, restricts usage to the named server.
///
If unset, usage is allowed on the master server and on
///
any replicas of the master other than Edge Servers.
///
///
Note: changing the client root does not actually move the client
///
files; you must relocate them manually. Similarly, changing
///
the 'LineEnd' option does not actually update the client files;
///
you can refresh them with 'p4 sync -f'.
///
///
The -d flag deletes the specified spec, as long as the client
///
workspace has no opened files or pending changes. (See 'p4 help
///
opened'.) The -f flag forces the delete. The -Fs option used with -f
///
forces client deletion even when the user has shelved changes. In
///
this case, the shelved changes are left intact.
///
///
The -o flag writes the named client spec to the standard output.
///
The user's editor is not invoked.
///
///
The -i flag reads a client spec from the standard input. The
///
user's editor is not invoked.
///
///
The -t template flag, where 'template' is the name of another client
///
spec, causes the View and Options fields to be replaced by those of
///
the template.
///
///
The -f flag can force the updating of locked clients; normally
///
locked clients can only be modified by their owner. -f also allows
///
the last modified date to be set. The -f flag requires 'admin'
///
access granted by 'p4 protect'.
///
///
The -s flag is used to switch an existing client spec's view without
///
invoking the editor. It can be used with -S to switch to a stream
///
view, or with -t to switch to a view defined in another client spec.
///
Switching views is not allowed in a client that has opened files.
///
The -f flag can be used with -s to force switching with opened files.
///
View switching has no effect on files in a client workspace until
///
'p4 sync' is run.
///
///
Without -s, the '-S stream' flag can be used to create a new client
///
spec dedicated to a stream. If the client spec already exists, and
///
-S is used without -s, it is ignored. Using -S sets the client's
///
Stream field. The special syntax '-S //a/stream@changelist' can be
///
be used to set both Stream and StreamAtChange at the same time.
///
///
The '-S stream' flag can be used with '-o -c change' to inspect an
///
old stream client view. It yields the client spec that would have
///
been created for the stream at the moment the change was recorded.
///
///
A server of type 'build-server' (see 'p4 help server') is a replica
///
which supports build farm integration, and the 'p4 client' command
///
may be used to create or edit client workspaces on a build-server.
///
Such workspaces may issue the 'p4 sync' command, in addition to any
///
read-only command supported by the replica. For more information, run
///
'p4 help buildserver'.
///
///
When creating or editing a client workspace for a build-server,
///
the client specified by the optional 'name' argument, as well as the
///
client specified by the $P4CLIENT environment variable or via the
///
global '-c client' argument must not exist, or must be restricted
///
to this server; this command may not be used to create or edit a
///
workspace that is not restricted to this build-server.
///
///
///
///
/// To update a client named main_ws:
///
/// Client c = Repository.GetClient("main_ws");
///
/// // change the description add add a MapEntry to the ViewMap
/// c.Description = "client for main dev. Adding tools path";
///
/// DepotPath left = new DepotPath("//depot/tools/...");
/// ClientPath right = new ClientPath("//main_ws/tools/...");
///
/// MapEntry line = new MapEntry(MapType.Include, left, right);
/// c.ViewMap.Add(line);
///
/// Repository.UpdateClient(c);
///
///
public Client UpdateClient(Client client)
{
return CreateClient(client, null);
}
///
/// Get the record for an existing client from the repository.
///
/// Client name
/// There are no valid flags to use when fetching an existing client
/// The Client object if new client was found, null if creation failed
///
/// Create a new client in the repository.
///
/// Client specification for the new user
/// The '-i' flags is required when creating a new user
/// The Client object if new user was created, null if creation failed
/// The '-i' flag is added if not specified by the caller
///
///
p4 help client
///
///
client -- Create or edit a client workspace specification and its view
///
workspace -- Synonym for 'client'
///
///
p4 client [-f -t template] [name]
///
p4 client -d [[-f] [-Fs]]name
///
p4 client -o [-t template] [name]
///
p4 client -S stream [[-c change] -o] [name]
///
p4 client -s [-f] -S stream [name]
///
p4 client -s [-f] -t template [name]
///
p4 client -i [-f]
///
///
Creates a new client specification ('spec') or edits an existing
///
spec. A client spec is a named mapping of depot files to workspace
///
files.
///
///
The 'p4 client' command puts the client spec into a temporary file
///
and invokes the editor configured by the environment variable
///
$P4EDITOR. For new workspaces, the client name defaults to the
///
$P4CLIENT environment variable, if set, or to the current host name.
///
Saving the file creates or modifies the client spec.
///
///
The client spec contains the following fields:
///
///
Client: The client name.
///
///
Host: If set, restricts access to the named host.
///
If unset, access is allowed from any host.
///
///
Owner: The user who created this client.
///
///
Update: The date that this spec was last modified.
///
///
Access: The date that this client was last used in any way.
///
///
Description: A short description of the workspace.
///
///
Root: The root directory of the workspace (specified in local
///
file system syntax), under which all versioned files
///
will be placed. If you change this setting, you must
///
physically relocate any files that currently reside
///
there. On Windows client machines, you can specify the
///
root as "null" to enable you to map files to multiple
///
drives.
///
///
AltRoots: Up to two optional alternate client workspace roots.
///
The first of the main and alternate roots to match the
///
client program's current working directory is used. If
///
none match, the main root is used. 'p4 info' displays
///
the root that is being used.
///
///
Options: Flags to configure the client behavior. Defaults
///
are marked with *.
///
///
allwrite Leaves all files writable on the client;
///
noallwrite * by default, only files opened by 'p4 edit'
///
are writable. If set, files might be clobbered
///
as a result of ignoring the clobber option
///
(see below).
///
///
clobber Permits 'p4 sync' to overwrite writable
///
noclobber * files on the client. noclobber is ignored if
///
allwrite is set.
///
///
compress Compresses data sent between the client
///
nocompress * and server to speed up slow connections.
///
///
locked Allows only the client owner to use or change
///
unlocked * the client spec. Prevents the client spec from
///
being deleted.
///
///
modtime Causes 'p4 sync' and 'p4 submit' to preserve
///
nomodtime * file modification time, as with files with the
///
+m type modifier. (See 'p4 help filetypes'.)
///
With nomodtime, file timestamps are updated by
///
sync and submit operations.
///
///
rmdir Makes 'p4 sync' attempt to delete a workspace
///
normdir * directory when all files in it are removed.
///
///
SubmitOptions: Flags to change submit behaviour.
///
///
submitunchanged All open files are submitted (default).
///
///
revertunchanged Files that have content or type changes
///
are submitted. Unchanged files are
///
reverted.
///
///
leaveunchanged Files that have content or type changes
///
are submitted. Unchanged files are moved
///
to the default changelist.
///
///
+reopen Can be appended to the submit option flag
///
to cause submitted files to be reopened in
///
the default changelist.
///
Example: submitunchanged+reopen
///
///
LineEnd: Set line-ending character(s) for client text files.
///
///
local mode that is native to the client (default).
///
unix linefeed: UNIX style.
///
mac carriage return: Macintosh style.
///
win carriage return-linefeed: Windows style.
///
share hybrid: writes UNIX style but reads UNIX,
///
Mac or Windows style.
///
///
View: Maps files in the depot to files in your client
///
workspace. Defines the files that you want in your
///
client workspace and specifies where you want them
///
to reside. The default view maps all depot files
///
onto the client. See 'p4 help views' for view syntax.
///
A new view takes effect on the next 'p4 sync'.
///
///
Stream: The stream to which this client's view will be dedicated.
///
(Files in stream paths can be submitted only by dedicated
///
stream clients.) When this optional field is set, the
///
View field will be automatically replaced by a stream
///
view as the client spec is saved.
///
///
StreamAtChange:
///
Stream meta-data (for view creation) is versioned.
///
When StreamAtChange is set, the stream hierarchy is
///
constructed back-in-time to reproduce the view that was
///
available to clients in the past. With this field set
///
changes cannot be be submitted from the client.
///
StreamAtChange is optional; Stream must be set as well.
///
///
ServerID: If set, restricts usage to the named server.
///
If unset, usage is allowed on the master server and on
///
any replicas of the master other than Edge Servers.
///
///
Note: changing the client root does not actually move the client
///
files; you must relocate them manually. Similarly, changing
///
the 'LineEnd' option does not actually update the client files;
///
you can refresh them with 'p4 sync -f'.
///
///
The -d flag deletes the specified spec, as long as the client
///
workspace has no opened files or pending changes. (See 'p4 help
///
opened'.) The -f flag forces the delete. The -Fs option used with -f
///
forces client deletion even when the user has shelved changes. In
///
this case, the shelved changes are left intact.
///
///
The -o flag writes the named client spec to the standard output.
///
The user's editor is not invoked.
///
///
The -i flag reads a client spec from the standard input. The
///
user's editor is not invoked.
///
///
The -t template flag, where 'template' is the name of another client
///
spec, causes the View and Options fields to be replaced by those of
///
the template.
///
///
The -f flag can force the updating of locked clients; normally
///
locked clients can only be modified by their owner. -f also allows
///
the last modified date to be set. The -f flag requires 'admin'
///
access granted by 'p4 protect'.
///
///
The -s flag is used to switch an existing client spec's view without
///
invoking the editor. It can be used with -S to switch to a stream
///
view, or with -t to switch to a view defined in another client spec.
///
Switching views is not allowed in a client that has opened files.
///
The -f flag can be used with -s to force switching with opened files.
///
View switching has no effect on files in a client workspace until
///
'p4 sync' is run.
///
///
Without -s, the '-S stream' flag can be used to create a new client
///
spec dedicated to a stream. If the client spec already exists, and
///
-S is used without -s, it is ignored. Using -S sets the client's
///
Stream field. The special syntax '-S //a/stream@changelist' can be
///
be used to set both Stream and StreamAtChange at the same time.
///
///
The '-S stream' flag can be used with '-o -c change' to inspect an
///
old stream client view. It yields the client spec that would have
///
been created for the stream at the moment the change was recorded.
///
///
A server of type 'build-server' (see 'p4 help server') is a replica
///
which supports build farm integration, and the 'p4 client' command
///
may be used to create or edit client workspaces on a build-server.
///
Such workspaces may issue the 'p4 sync' command, in addition to any
///
read-only command supported by the replica. For more information, run
///
'p4 help buildserver'.
///
///
When creating or editing a client workspace for a build-server,
///
the client specified by the optional 'name' argument, as well as the
///
client specified by the $P4CLIENT environment variable or via the
///
global '-c client' argument must not exist, or must be restricted
///
to this server; this command may not be used to create or edit a
///
workspace that is not restricted to this build-server.
///
///
///
///
/// To get the spec for a client named main_ws:
///
/// Client c = Repository.GetClient("main_ws", null);
///
///
///
public Client GetClient(string client, Options options)
{
if (client == null)
{
throw new ArgumentNullException("client");
}
P4Command cmd = new P4Command(this, "client", true, client);
if (options == null)
{
options = new Options();
}
options["-o"] = null;
P4CommandResult results = cmd.Run(options);
if (results.Success)
{
if ((results.TaggedOutput == null) || (results.TaggedOutput.Count <= 0))
{
return null;
}
Client value = new Client();
value.FromClientCmdTaggedOutput(results.TaggedOutput[0]);
return value;
}
else
{
P4Exception.Throw(results.ErrorList);
}
return null;
}
///
/// Get the record for an existing client from the repository.
///
/// Client name
/// There are no valid flags to use when fetching an existing client
/// The Client object if new client was found, null if creation failed
///
/// Create a new client in the repository.
///
/// Client specification for the new user
/// The '-i' flags is required when creating a new user
/// The Client object if new user was created, null if creation failed
/// The '-i' flag is added if not specified by the caller
///
///
p4 help client
///
///
client -- Create or edit a client workspace specification and its view
///
workspace -- Synonym for 'client'
///
///
p4 client [-f -t template] [name]
///
p4 client -d [[-f] [-Fs]]name
///
p4 client -o [-t template] [name]
///
p4 client -S stream [[-c change] -o] [name]
///
p4 client -s [-f] -S stream [name]
///
p4 client -s [-f] -t template [name]
///
p4 client -i [-f]
///
///
Creates a new client specification ('spec') or edits an existing
///
spec. A client spec is a named mapping of depot files to workspace
///
files.
///
///
The 'p4 client' command puts the client spec into a temporary file
///
and invokes the editor configured by the environment variable
///
$P4EDITOR. For new workspaces, the client name defaults to the
///
$P4CLIENT environment variable, if set, or to the current host name.
///
Saving the file creates or modifies the client spec.
///
///
The client spec contains the following fields:
///
///
Client: The client name.
///
///
Host: If set, restricts access to the named host.
///
If unset, access is allowed from any host.
///
///
Owner: The user who created this client.
///
///
Update: The date that this spec was last modified.
///
///
Access: The date that this client was last used in any way.
///
///
Description: A short description of the workspace.
///
///
Root: The root directory of the workspace (specified in local
///
file system syntax), under which all versioned files
///
will be placed. If you change this setting, you must
///
physically relocate any files that currently reside
///
there. On Windows client machines, you can specify the
///
root as "null" to enable you to map files to multiple
///
drives.
///
///
AltRoots: Up to two optional alternate client workspace roots.
///
The first of the main and alternate roots to match the
///
client program's current working directory is used. If
///
none match, the main root is used. 'p4 info' displays
///
the root that is being used.
///
///
Options: Flags to configure the client behavior. Defaults
///
are marked with *.
///
///
allwrite Leaves all files writable on the client;
///
noallwrite * by default, only files opened by 'p4 edit'
///
are writable. If set, files might be clobbered
///
as a result of ignoring the clobber option
///
(see below).
///
///
clobber Permits 'p4 sync' to overwrite writable
///
noclobber * files on the client. noclobber is ignored if
///
allwrite is set.
///
///
compress Compresses data sent between the client
///
nocompress * and server to speed up slow connections.
///
///
locked Allows only the client owner to use or change
///
unlocked * the client spec. Prevents the client spec from
///
being deleted.
///
///
modtime Causes 'p4 sync' and 'p4 submit' to preserve
///
nomodtime * file modification time, as with files with the
///
+m type modifier. (See 'p4 help filetypes'.)
///
With nomodtime, file timestamps are updated by
///
sync and submit operations.
///
///
rmdir Makes 'p4 sync' attempt to delete a workspace
///
normdir * directory when all files in it are removed.
///
///
SubmitOptions: Flags to change submit behaviour.
///
///
submitunchanged All open files are submitted (default).
///
///
revertunchanged Files that have content or type changes
///
are submitted. Unchanged files are
///
reverted.
///
///
leaveunchanged Files that have content or type changes
///
are submitted. Unchanged files are moved
///
to the default changelist.
///
///
+reopen Can be appended to the submit option flag
///
to cause submitted files to be reopened in
///
the default changelist.
///
Example: submitunchanged+reopen
///
///
LineEnd: Set line-ending character(s) for client text files.
///
///
local mode that is native to the client (default).
///
unix linefeed: UNIX style.
///
mac carriage return: Macintosh style.
///
win carriage return-linefeed: Windows style.
///
share hybrid: writes UNIX style but reads UNIX,
///
Mac or Windows style.
///
///
View: Maps files in the depot to files in your client
///
workspace. Defines the files that you want in your
///
client workspace and specifies where you want them
///
to reside. The default view maps all depot files
///
onto the client. See 'p4 help views' for view syntax.
///
A new view takes effect on the next 'p4 sync'.
///
///
Stream: The stream to which this client's view will be dedicated.
///
(Files in stream paths can be submitted only by dedicated
///
stream clients.) When this optional field is set, the
///
View field will be automatically replaced by a stream
///
view as the client spec is saved.
///
///
StreamAtChange:
///
Stream meta-data (for view creation) is versioned.
///
When StreamAtChange is set, the stream hierarchy is
///
constructed back-in-time to reproduce the view that was
///
available to clients in the past. With this field set
///
changes cannot be be submitted from the client.
///
StreamAtChange is optional; Stream must be set as well.
///
///
ServerID: If set, restricts usage to the named server.
///
If unset, usage is allowed on the master server and on
///
any replicas of the master other than Edge Servers.
///
///
Note: changing the client root does not actually move the client
///
files; you must relocate them manually. Similarly, changing
///
the 'LineEnd' option does not actually update the client files;
///
you can refresh them with 'p4 sync -f'.
///
///
The -d flag deletes the specified spec, as long as the client
///
workspace has no opened files or pending changes. (See 'p4 help
///
opened'.) The -f flag forces the delete. The -Fs option used with -f
///
forces client deletion even when the user has shelved changes. In
///
this case, the shelved changes are left intact.
///
///
The -o flag writes the named client spec to the standard output.
///
The user's editor is not invoked.
///
///
The -i flag reads a client spec from the standard input. The
///
user's editor is not invoked.
///
///
The -t template flag, where 'template' is the name of another client
///
spec, causes the View and Options fields to be replaced by those of
///
the template.
///
///
The -f flag can force the updating of locked clients; normally
///
locked clients can only be modified by their owner. -f also allows
///
the last modified date to be set. The -f flag requires 'admin'
///
access granted by 'p4 protect'.
///
///
The -s flag is used to switch an existing client spec's view without
///
invoking the editor. It can be used with -S to switch to a stream
///
view, or with -t to switch to a view defined in another client spec.
///
Switching views is not allowed in a client that has opened files.
///
The -f flag can be used with -s to force switching with opened files.
///
View switching has no effect on files in a client workspace until
///
'p4 sync' is run.
///
///
Without -s, the '-S stream' flag can be used to create a new client
///
spec dedicated to a stream. If the client spec already exists, and
///
-S is used without -s, it is ignored. Using -S sets the client's
///
Stream field. The special syntax '-S //a/stream@changelist' can be
///
be used to set both Stream and StreamAtChange at the same time.
///
///
The '-S stream' flag can be used with '-o -c change' to inspect an
///
old stream client view. It yields the client spec that would have
///
been created for the stream at the moment the change was recorded.
///
///
A server of type 'build-server' (see 'p4 help server') is a replica
///
which supports build farm integration, and the 'p4 client' command
///
may be used to create or edit client workspaces on a build-server.
///
Such workspaces may issue the 'p4 sync' command, in addition to any
///
read-only command supported by the replica. For more information, run
///
'p4 help buildserver'.
///
///
When creating or editing a client workspace for a build-server,
///
the client specified by the optional 'name' argument, as well as the
///
client specified by the $P4CLIENT environment variable or via the
///
global '-c client' argument must not exist, or must be restricted
///
to this server; this command may not be used to create or edit a
///
workspace that is not restricted to this build-server.
///
///
///
///
/// To get the spec for a client named main_ws:
///
/// Client c = Repository.GetClient("main_ws");
///
///
public Client GetClient(string client)
{
return GetClient(client, null);
}
///
/// Get a list of clients from the repository
///
/// options for the clients command
/// A list containing the matching clients
///
///
p4 help clients
///
///
clients -- Display list of clients
///
workspaces -- synonym for 'clients'
///
///
p4 clients [-t] [-u user] [[-e|-E] nameFilter -m max] [-S stream]
///
[-a | -s serverID]
///
p4 clients -U
///
///
Lists all client workspaces currently defined in the server.
///
///
The -t flag displays the time as well as the date.
///
///
The -u user flag lists client workspaces that are owned by the
///
specified user.
///
///
The -e nameFilter flag lists workspaces with a name that matches
///
the nameFilter pattern, for example: -e 'svr-dev-rel*'. -E makes
///
the matching case-insensitive.
///
///
The -m max flag limits output to the specified number of workspaces.
///
///
The -S stream flag limits output to the client workspaces dedicated
///
to the stream.
///
///
The -U flag lists unloaded clients (see 'p4 help unload').
///
///
The -a flag specifies that all clients should be displayed, not just
///
those that are bound to this server.
///
///
The -s serverID flag specifies that only those clients bound to the
///
specified serverID should be displayed. On an Edge Server, the -s
///
flag defaults to the Edge Server's serverID.
///
///
///
///
/// To get a list of a maximum of 10 clients:
///
/// ClientsCmdOptions opts =
/// new ClientsCmdOptions(ClientsCmdFlags.NoneIncludeTime, null, null, 10, null));
///
/// IList<Client> clients = Repository.GetClients(opts);
///
/// To get a list of clients that have "iOS_app" in their name:
///
/// ClientsCmdOptions opts =
/// new ClientsCmdOptions(ClientsCmdFlags.NoneIncludeTime, null, "*iOS_app*, 0, null));
///
/// IList<Client> clients = Repository.GetClients(opts);
///
/// To get a list of clients that can be used with stream //depot/main:
///
/// ClientsCmdOptions opts =
/// new ClientsCmdOptions(ClientsCmdFlags.NoneIncludeTime, null, null, 0, "//depot/main"));
///
/// IList<Client> clients = Repository.GetClients(opts);
///
/// To get a list clients owned by user bsmith:
///
/// ClientsCmdOptions opts =
/// new ClientsCmdOptions(ClientsCmdFlags.NoneIncludeTime, "bsmith", null, 0, null));
///
/// IList<Client> clients = Repository.GetClients(opts);
///
///
///
public IList GetClients(Options options)
{
P4Command cmd = new P4Command(this, "clients", true);
P4CommandResult results = cmd.Run(options);
if (results.Success)
{
if ((results.TaggedOutput == null) || (results.TaggedOutput.Count <= 0))
{
return null;
}
List value = new List();
foreach (TaggedObject obj in results.TaggedOutput)
{
Client client = new Client();
bool dst_mismatch = false;
string offset = string.Empty;
if (Server != null && Server.Metadata != null)
{
offset = Server.Metadata.DateTimeOffset;
dst_mismatch = FormBase.DSTMismatch(Server.Metadata);
}
client.FromClientsCmdTaggedOutput(obj, offset,dst_mismatch);
value.Add(client);
}
return value;
}
else
{
P4Exception.Throw(results.ErrorList);
}
return null;
}
///
/// Delete a client from the repository
///
/// The client to be deleted
/// Only the '-f' flag is valid when deleting an existing client
///
///
///
p4 help client
///
///
client -- Create or edit a client workspace specification and its view
///
workspace -- Synonym for 'client'
///
///
p4 client [-f -t template] [name]
///
p4 client -d [[-f] [-Fs]]name
///
p4 client -o [-t template] [name]
///
p4 client -S stream [[-c change] -o] [name]
///
p4 client -s [-f] -S stream [name]
///
p4 client -s [-f] -t template [name]
///
p4 client -i [-f]
///
///
Creates a new client specification ('spec') or edits an existing
///
spec. A client spec is a named mapping of depot files to workspace
///
files.
///
///
The 'p4 client' command puts the client spec into a temporary file
///
and invokes the editor configured by the environment variable
///
$P4EDITOR. For new workspaces, the client name defaults to the
///
$P4CLIENT environment variable, if set, or to the current host name.
///
Saving the file creates or modifies the client spec.
///
///
The client spec contains the following fields:
///
///
Client: The client name.
///
///
Host: If set, restricts access to the named host.
///
If unset, access is allowed from any host.
///
///
Owner: The user who created this client.
///
///
Update: The date that this spec was last modified.
///
///
Access: The date that this client was last used in any way.
///
///
Description: A short description of the workspace.
///
///
Root: The root directory of the workspace (specified in local
///
file system syntax), under which all versioned files
///
will be placed. If you change this setting, you must
///
physically relocate any files that currently reside
///
there. On Windows client machines, you can specify the
///
root as "null" to enable you to map files to multiple
///
drives.
///
///
AltRoots: Up to two optional alternate client workspace roots.
///
The first of the main and alternate roots to match the
///
client program's current working directory is used. If
///
none match, the main root is used. 'p4 info' displays
///
the root that is being used.
///
///
Options: Flags to configure the client behavior. Defaults
///
are marked with *.
///
///
allwrite Leaves all files writable on the client;
///
noallwrite * by default, only files opened by 'p4 edit'
///
are writable. If set, files might be clobbered
///
as a result of ignoring the clobber option
///
(see below).
///
///
clobber Permits 'p4 sync' to overwrite writable
///
noclobber * files on the client. noclobber is ignored if
///
allwrite is set.
///
///
compress Compresses data sent between the client
///
nocompress * and server to speed up slow connections.
///
///
locked Allows only the client owner to use or change
///
unlocked * the client spec. Prevents the client spec from
///
being deleted.
///
///
modtime Causes 'p4 sync' and 'p4 submit' to preserve
///
nomodtime * file modification time, as with files with the
///
+m type modifier. (See 'p4 help filetypes'.)
///
With nomodtime, file timestamps are updated by
///
sync and submit operations.
///
///
rmdir Makes 'p4 sync' attempt to delete a workspace
///
normdir * directory when all files in it are removed.
///
///
SubmitOptions: Flags to change submit behaviour.
///
///
submitunchanged All open files are submitted (default).
///
///
revertunchanged Files that have content or type changes
///
are submitted. Unchanged files are
///
reverted.
///
///
leaveunchanged Files that have content or type changes
///
are submitted. Unchanged files are moved
///
to the default changelist.
///
///
+reopen Can be appended to the submit option flag
///
to cause submitted files to be reopened in
///
the default changelist.
///
Example: submitunchanged+reopen
///
///
LineEnd: Set line-ending character(s) for client text files.
///
///
local mode that is native to the client (default).
///
unix linefeed: UNIX style.
///
mac carriage return: Macintosh style.
///
win carriage return-linefeed: Windows style.
///
share hybrid: writes UNIX style but reads UNIX,
///
Mac or Windows style.
///
///
View: Maps files in the depot to files in your client
///
workspace. Defines the files that you want in your
///
client workspace and specifies where you want them
///
to reside. The default view maps all depot files
///
onto the client. See 'p4 help views' for view syntax.
///
A new view takes effect on the next 'p4 sync'.
///
///
Stream: The stream to which this client's view will be dedicated.
///
(Files in stream paths can be submitted only by dedicated
///
stream clients.) When this optional field is set, the
///
View field will be automatically replaced by a stream
///
view as the client spec is saved.
///
///
StreamAtChange:
///
Stream meta-data (for view creation) is versioned.
///
When StreamAtChange is set, the stream hierarchy is
///
constructed back-in-time to reproduce the view that was
///
available to clients in the past. With this field set
///
changes cannot be be submitted from the client.
///
StreamAtChange is optional; Stream must be set as well.
///
///
ServerID: If set, restricts usage to the named server.
///
If unset, usage is allowed on the master server and on
///
any replicas of the master other than Edge Servers.
///
///
Note: changing the client root does not actually move the client
///
files; you must relocate them manually. Similarly, changing
///
the 'LineEnd' option does not actually update the client files;
///
you can refresh them with 'p4 sync -f'.
///
///
The -d flag deletes the specified spec, as long as the client
///
workspace has no opened files or pending changes. (See 'p4 help
///
opened'.) The -f flag forces the delete. The -Fs option used with -f
///
forces client deletion even when the user has shelved changes. In
///
this case, the shelved changes are left intact.
///
///
The -o flag writes the named client spec to the standard output.
///
The user's editor is not invoked.
///
///
The -i flag reads a client spec from the standard input. The
///
user's editor is not invoked.
///
///
The -t template flag, where 'template' is the name of another client
///
spec, causes the View and Options fields to be replaced by those of
///
the template.
///
///
The -f flag can force the updating of locked clients; normally
///
locked clients can only be modified by their owner. -f also allows
///
the last modified date to be set. The -f flag requires 'admin'
///
access granted by 'p4 protect'.
///
///
The -s flag is used to switch an existing client spec's view without
///
invoking the editor. It can be used with -S to switch to a stream
///
view, or with -t to switch to a view defined in another client spec.
///
Switching views is not allowed in a client that has opened files.
///
The -f flag can be used with -s to force switching with opened files.
///
View switching has no effect on files in a client workspace until
///
'p4 sync' is run.
///
///
Without -s, the '-S stream' flag can be used to create a new client
///
spec dedicated to a stream. If the client spec already exists, and
///
-S is used without -s, it is ignored. Using -S sets the client's
///
Stream field. The special syntax '-S //a/stream@changelist' can be
///
be used to set both Stream and StreamAtChange at the same time.
///
///
The '-S stream' flag can be used with '-o -c change' to inspect an
///
old stream client view. It yields the client spec that would have
///
been created for the stream at the moment the change was recorded.
///
///
A server of type 'build-server' (see 'p4 help server') is a replica
///
which supports build farm integration, and the 'p4 client' command
///
may be used to create or edit client workspaces on a build-server.
///
Such workspaces may issue the 'p4 sync' command, in addition to any
///
read-only command supported by the replica. For more information, run
///
'p4 help buildserver'.
///
///
When creating or editing a client workspace for a build-server,
///
the client specified by the optional 'name' argument, as well as the
///
client specified by the $P4CLIENT environment variable or via the
///
global '-c client' argument must not exist, or must be restricted
///
to this server; this command may not be used to create or edit a
///
workspace that is not restricted to this build-server.
///
///
///
///
/// To delete a client named main_ws with the user who owns it:
///
/// Client c = Repository.GetClient("main_ws");
/// Repository.DeleteClient(c, null);
///
/// To delete a locked client named main_ws with an admin user:
///
/// Client c = Repository.GetClient("main_ws", null);
///
/// ClientCmdOptions opts = new ClientCmdOptions(ClientCmdFlags.Force);
/// rep.DeleteClient(c, opts);
///
///
///
public void DeleteClient(Client client, Options options)
{
if (client == null)
{
throw new ArgumentNullException("client");
}
P4Command cmd = new P4Command(this, "client", true, client.Name);
if (options == null)
{
options = new Options();
}
options["-d"] = null;
P4CommandResult results = cmd.Run(options);
if (results.Success == false)
{
P4Exception.Throw(results.ErrorList);
}
}
}
}