[p4ruby] Creating client from scratch

Dale Quigg daleq at messagegate.com
Thu Feb 28 16:03:55 PST 2008


Hi,

I want to create a client from scratch (specifically the view spec)

I can use the code below to get the client created, but the resulting view spec contains (in my case)
	//test/... //dq-auto-1/test/...
	//messagegate/... //dq-auto-1/messagegate/...
	//depot/... //dq-auto-1/depot/...
	//messagegate/foo/... //dq-auto-1/foo/...
	//messagegate/bar/... //dq-auto-1/bar/...

All I want are the last two lines that I added.

I'm sure this is a basic question, but I don't see how to iterate through spec._view and make changes.

If I add code to my example like;
	spec._view = ""
prior to adding my entries, the resulting client has no reference to View:

Also, doing something like;
  spec._view = spec._view << "//messagegate/bar/... //" << ClientName << "/bar/..."
gives pretty odd results.  I'm sure there is some reason for this, and I'm fine with creating a variable and using it like in my example.

Thanks for any help.
Dale


--- begin sample ---

require "P4"
p4 = P4.new
p4.connect

ClientName = "dq-auto-1"

begin
  spec = p4.fetch_client( ClientName )

  a = "//messagegate/foo/... //" << ClientName << "/foo/..."
  b = "//messagegate/bar/... //" << ClientName << "/bar/..."
  spec._view = spec._view <<  a
  spec._view = spec._view <<  b
  spec._description	= ClientName << " description"
 
  p4.save_client( spec )

rescue P4Exception
  p4.errors.each { |e| $stderr.puts( e ) }
  raise
end

--- end sample ---




Dale Quigg  |||  Senior Build / Configuration / Installation Engineer
MessageGate  |||  Enterprise Email Governance




More information about the p4ruby mailing list