Discussion:
[p4] Determining client directory from depot directory?
Bob Arnson
2002-09-02 05:08:00 UTC
Permalink
I'm writing a tool to let users diff their client tree against the
head revisions in the depot. The approach I'm using is to throw up a
dialog box with a tree representing the depot, clone the user's
current clientspec, sync it, and run a diff tool capable of diffing
trees.

It works, but I'd like to optimize it. Currently, I run the diff tool
against the root of both clients. That's a lot of unnecessary diffing.
Eventually, I'd like to rewrite it to diff just opened files. In the
meantime, I'm looking to restrict the diffing to just the trees of
interest. So far, the only way I've found -- short of interpreting the
clientspec view mapping -- is to do a "files //depot/path/*" and then
an "fstat -C //depot/path/firstFile". (I know that if the user's
clientspec maps subordinate files outside that tree, it won't diff
them, but I'm willing to live with that limitation.)

Can anyone think of any quicker way to map from a depot directory to a
client directory?

--
sig://boB
http://IntellectualFrottage.com
Patrick Bennett
2002-09-02 05:38:50 UTC
Permalink
p4 where is the answer to your prayers. :>
Post by Bob Arnson
I'm writing a tool to let users diff their client tree against the
head revisions in the depot. The approach I'm using is to throw up a
dialog box with a tree representing the depot, clone the user's
current clientspec, sync it, and run a diff tool capable of diffing
trees.
It works, but I'd like to optimize it. Currently, I run the diff tool
against the root of both clients. That's a lot of unnecessary diffing.
Eventually, I'd like to rewrite it to diff just opened files. In the
meantime, I'm looking to restrict the diffing to just the trees of
interest. So far, the only way I've found -- short of interpreting the
clientspec view mapping -- is to do a "files //depot/path/*" and then
an "fstat -C //depot/path/firstFile". (I know that if the user's
clientspec maps subordinate files outside that tree, it won't diff
them, but I'm willing to live with that limitation.)
Can anyone think of any quicker way to map from a depot directory to a
client directory?
--
sig://boB
http://IntellectualFrottage.com
_______________________________________________
http://maillist.perforce.com/mailman/listinfo/perforce-user
Bob Arnson
2002-09-02 15:03:51 UTC
Permalink
Post by Patrick Bennett
p4 where is the answer to your prayers. :>
Yes it is. (It's alphabetically the last command, so naturally it
would be the one I need.<g>) It doesn't work with just directory
names, though; if you pass it a directory name, it will return names
without applying any special mappings. But it looks like you can pass
it "//depot/path/*" and just take the last line of output (which
solves the problem of multiple lines of output per file).

Thanks!

--
sig://boB
http://IntellectualFrottage.com
Stephen Vance
2002-09-04 10:49:57 UTC
Permalink
Actually, 'p4 where' doesn't care if the file you are asking about actually
exists. So you can do

p4 where //depot/path/foo

and get equally valid results without having to take the last line. You
will get confusing results if your client spec is ambiguous (i.e. not
one-to-one) though.
Post by Bob Arnson
Post by Patrick Bennett
p4 where is the answer to your prayers. :>
Yes it is. (It's alphabetically the last command, so naturally it
would be the one I need.<g>) It doesn't work with just directory
names, though; if you pass it a directory name, it will return names
without applying any special mappings. But it looks like you can pass
it "//depot/path/*" and just take the last line of output (which
solves the problem of multiple lines of output per file).
Thanks!
--
sig://boB
http://IntellectualFrottage.com
_______________________________________________
http://maillist.perforce.com/mailman/listinfo/perforce-user
Stephen Vance
mailto:***@vance.com
http://www.vance.com/
Jo Woodison
2002-09-02 06:18:58 UTC
Permalink
Don't forget p4 diff -sa too. That gives you the names of
all opened files that are different from their corresponding
revision in the depot (or missing).

Of course, that doesn't tell you whether they're at the head
revision or not, but a p4 sync -n will let you know that.

p4 where gives you the path of a file in depot, client, and
local (file path) syntax.

Regards,

Jo
Post by Bob Arnson
I'm writing a tool to let users diff their client tree against the
head revisions in the depot. The approach I'm using is to throw up a
dialog box with a tree representing the depot, clone the user's
current clientspec, sync it, and run a diff tool capable of diffing
trees.
It works, but I'd like to optimize it. Currently, I run the diff tool
against the root of both clients. That's a lot of unnecessary diffing.
Eventually, I'd like to rewrite it to diff just opened files. In the
meantime, I'm looking to restrict the diffing to just the trees of
interest. So far, the only way I've found -- short of interpreting the
clientspec view mapping -- is to do a "files //depot/path/*" and then
an "fstat -C //depot/path/firstFile". (I know that if the user's
clientspec maps subordinate files outside that tree, it won't diff
them, but I'm willing to live with that limitation.)
Can anyone think of any quicker way to map from a depot directory to a
client directory?
--
sig://boB
http://IntellectualFrottage.com
_______________________________________________
http://maillist.perforce.com/mailman/listinfo/perforce-user
--
Jo Woodison ***@mandarinconsulting.com +61 (0)438 243 027

~ mandarin consulting . melbourne . victoria . australia ~
Bennett, Patrick
2002-09-04 14:18:42 UTC
Permalink
As Bob said, this doesn't work for directories.
If path/foo resolved to a directory in the user's client mapping, it wouldn't return the correct result.
p4 where assumes (incorrectly) that it is a file.
You have to add /* at the end for it to resolve the directory mapping correctly.

-----Original Message-----
From: Stephen Vance [mailto:***@vance.com]
Sent: Wednesday, September 04, 2002 5:50 AM
To: Bob Arnson; Bennett, Patrick
Cc: Bob Arnson; perforce-***@perforce.com
Subject: Re[2]: [p4] Determining client directory from depot directory?


Actually, 'p4 where' doesn't care if the file you are asking about actually
exists. So you can do

p4 where //depot/path/foo

and get equally valid results without having to take the last line. You
will get confusing results if your client spec is ambiguous (i.e. not
one-to-one) though.
Post by Bob Arnson
Post by Patrick Bennett
p4 where is the answer to your prayers. :>
Yes it is. (It's alphabetically the last command, so naturally it
would be the one I need.<g>) It doesn't work with just directory
names, though; if you pass it a directory name, it will return names
without applying any special mappings. But it looks like you can pass
it "//depot/path/*" and just take the last line of output (which
solves the problem of multiple lines of output per file).
Thanks!
--
sig://boB
http://IntellectualFrottage.com
_______________________________________________
http://maillist.perforce.com/mailman/listinfo/perforce-user
Stephen Vance
mailto:***@vance.com
http://www.vance.com/
s***@vance.com
1970-01-01 00:00:00 UTC
Permalink
I agree. Perhaps a clearer example of what I propose is

p4 where //depot/path/ThisFileNameShouldNotExist

The suggestion is to use a dummy file name to avoid having
to list all files in the directory, thus simplifying the
parsing and reducing the overhead.

Steve
Post by Bennett, Patrick
As Bob said, this doesn't work for directories.
If path/foo resolved to a directory in the user's client
mapping, it wouldn't return the
correct result.
Post by Bennett, Patrick
p4 where assumes (incorrectly) that it is a file.
You have to add /* at the end for it to resolve the
directory mapping correctly.
Post by Bennett, Patrick
-----Original Message-----
Sent: Wednesday, September 04, 2002 5:50 AM
To: Bob Arnson; Bennett, Patrick
Subject: Re[2]: [p4] Determining client directory from
depot directory?
Post by Bennett, Patrick
Actually, 'p4 where' doesn't care if the file you are
asking about actually
Post by Bennett, Patrick
exists. So you can do
p4 where //depot/path/foo
and get equally valid results without having to take the
last line. You
Post by Bennett, Patrick
will get confusing results if your client spec is
ambiguous (i.e. not
Post by Bennett, Patrick
one-to-one) though.
Post by Bob Arnson
Post by Patrick Bennett
p4 where is the answer to your prayers. :>
Yes it is. (It's alphabetically the last command, so
naturally it
Post by Bennett, Patrick
Post by Bob Arnson
would be the one I need.<g>) It doesn't work with just
directory
Post by Bennett, Patrick
Post by Bob Arnson
names, though; if you pass it a directory name, it will
return names
Post by Bennett, Patrick
Post by Bob Arnson
without applying any special mappings. But it looks like
you can pass
Post by Bennett, Patrick
Post by Bob Arnson
it "//depot/path/*" and just take the last line of
output (which
Post by Bennett, Patrick
Post by Bob Arnson
solves the problem of multiple lines of output per file).
Thanks!
--
sig://boB
http://IntellectualFrottage.com
_______________________________________________
http://maillist.perforce.com/mailman/listinfo/perforce-
user
Post by Bennett, Patrick
Stephen Vance
http://www.vance.com/
_______________________________________________
http://maillist.perforce.com/mailman/listinfo/perforce-
user
---------------------------------------------
This message was sent using WebMail by ValueWeb.
http://www.valueweb.net/webmail
Bob Arnson
2002-09-04 16:14:58 UTC
Permalink
Post by s***@vance.com
I agree. Perhaps a clearer example of what I propose is
p4 where //depot/path/ThisFileNameShouldNotExist
The suggestion is to use a dummy file name to avoid having
to list all files in the directory, thus simplifying the
parsing and reducing the overhead.
Perforce rewrites the rules: Garbage in, useful data out.<g> Thanks!

--
sig://boB
http://IntellectualFrottage.com

Loading...