[p4] Changing client Owner

Melissa Kacher mkacher at intrinsyc.com
Wed May 31 09:10:15 PDT 2006


See the -o and -i options below. If you know how to use sed, you are all
set. 


p4 help client

    client -- Create or edit a client specification and its view
    workspace -- synonym for 'client'

    p4 client [ -f -t template ] [ name ]
    p4 client -d [ -f ] name
    p4 client -o [ -t template ] [ name ]
    p4 client -i [ -f ]

	With no argument 'p4 client' creates a new client view
specification
	or edits an existing client specification.  The client name is
taken
	from the environment variable $P4CLIENT if set, or else from the
	current host name.  The specification form is put into a
temporary
	file and the editor (given by the environment variable
$P4EDITOR)
	is invoked.  If a name is given, the specification of the named
	client is used.

	The specification form contains the following fields:

	Client:      The client name (read only.)

	Host:        If set, restricts access to the named host.
		     If unset, access is allowed from any host.

	Owner:       The user who created this client.  Can be changed.

	Update:      The date this specification was last modified.

	Access:      The date this client was last used in any way.

	Description: A short description of the client (optional).

	Root:        The root directory of the client file workspace
		     (given in local file system syntax), under which
all
		     client files will be placed.  If you change this,
you
		     must physically relocate any files as well.  The
name
		     "null" may be used to allow files to be mapped to
		     multiple drives on Windows clients.

	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 matches the main root is used anyway.
		     'p4 info' reports the applicable root.

	Options:     Flags to change the client behavior.   The defaults
		     are marked with *.

		allwrite	Leaves all files writable on the client;
		noallwrite *	else only checked out files are
writable.

		clobber		Allows 'p4 sync' to overwrite writable
		noclobber *	files on the client.

		compress 	Compresses data sent between the client
		nocompress *	and server to speed up slow connections.

		locked   	Allows only the client owner to use the
		unlocked *	client or change its specification.
				Prevents the client from being deleted.

		modtime  	Causes 'p4 sync' to preserve file
		nomodtime *	modification time from submitting
client,
				as with files with +m type modifier.
				Otherwise modification time is left as
				when the file was fetched.

		rmdir		Makes 'p4 sync' attempt to delete a
client
		normdir *	directory when all files are removed.

	LineEnd:    Set line ending character(s) for client text files.

		local		Use mode 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:        A mapping from the files in the depot to files in
the
		     client workspace.  This is the mechanism by which
you
		     select what files you want on your client and where
you
		     want them to be.  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'.

	Note: changing the client root does not actually move the client
	files; you must relocate them yourself.  Similarly, changing
	the 'LineEnd' option does not actually update the client files;
	you can refresh them with 'p4 sync -f'.

	The -d flag causes the named client to be deleted, as long as it
	has no opened files.  The -f forces the delete.

	The -o flag causes the named client specification to be written
	to the standard output.  The user's editor is not invoked.

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

	The -t flag constructs the client's view by copying the named
	template client's view, instead of using the existing view or
	creating a new default view.  It also copies the client options
	from the template client.

	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'.



Thanks,
Melissa


-----Original Message-----
From: perforce-user-bounces at perforce.com
[mailto:perforce-user-bounces at perforce.com] On Behalf Of Lewis Baker
Sent: Tuesday, May 30, 2006 10:27 PM
To: Perforce User List
Subject: Re: [p4] Changing client Owner

Mohsin Saleem Khan wrote:
> Hi,
> 
> I am trying to change  client spec owner in perforce, right now I am
doing 
> p2 client <name> and than edit it. But I have almost 20 clients to
update, 
> is there any other way or can I do it via some kind of script.
> 

Scripting something like this is relatively straight forward with any of
the Perforce API bindings.

For example, using the PyPerforce interface for Python a simple script
such as this would do the trick:

----
#!/usr/bin/python
import sys

if len(sys.argv) < 3:
    print "Usage: %s <owner> [<client>]+" % sys.argv[0]
    sys.exit(1)

try:
    import perforce
except ImportError:
    print "Please install PyPerforce (http://pyperforce.sf.net/)"
    sys.exit(1)

newOwner = sys.argv[1]

p4 = perforce.Connection()
p4.connect()
try:
    for name in sys.argv[2:]:
        print "Changing owner of client %s to %s" % (name, newOwner)
        client = perforce.Client(p4, name)
        client['Owner'] = newOwner
        client.save()
finally:
    p4.disconnect()
----

Hope that helps.

Cheers,
Lewis.

-- 
Lewis Baker                                               I-SiTE
Software Engineer                               3D Laser Imaging
Email  : lewis at isite3d.com.au         http://www.isite3d.com.au/



More information about the perforce-user mailing list