[p4] what's the best way to determine the current client workspace?

Jeff Grills jgrills at junctionpoint.com
Wed Jun 27 13:23:03 PDT 2007


Maybe try "p4 info". Since it looks like you want the output to be
easily parsed, you might try "p4 -ztag info".

However, if you just want the latest change of the current workspace and
don't need to be able to pass other workspaces names into the script,
try "p4 changes -m1 //branch_name/...#have".

j

-----Original Message-----
From: perforce-user-bounces at perforce.com
[mailto:perforce-user-bounces at perforce.com] On Behalf Of Jay Glanville
Sent: Wednesday, June 27, 2007 2:00 PM
To: Perforce Users Mailing List
Subject: [p4] what's the best way to determine the current client
workspace?

I want to write a script that calls a perforce command where one of the
arguments is the name of the current workspace.  The desired output of
the command is the latest change list number on the current hard drive.
In other words, I want to execute the following command:

    p4 changes -m 1 \
      //branch_name/...@[current_workspace] | \
      sed 's/Change \([0-9]*\).*/\1/'

Where [current_workspace] is the name of the current workspace.  My
question is this: what is the best way to determine what is the current
workspace?  My original thought was to parse the client spec, something
like this:

    p4 client -o | \
      sed 's/^Client: *\([a-zA-Z_0-9]*\).*/\1/'

(I know that this sed won't actually work, but you get the idea).

So, is this the best way?  Is there a better way?  Is there a direct way
to do this (by that, I mean simply ask p4 directly 'what is the current
workspace')?

Thanks

JDG

---
Jay Dickon Glanville

_______________________________________________
perforce-user mailing list  -  perforce-user at perforce.com
http://maillist.perforce.com/mailman/listinfo/perforce-user



More information about the perforce-user mailing list