[p4ruby] fix for symlink-in-PWD problem

Tony Smith tony at smee.org
Tue Mar 11 04:28:54 PDT 2008


On Monday 10 March 2008 18:11:06 bob p4 wrote:
> I claim the fix is compatible with the default behavior; that is why I
> suggested it.  I may be wrong, but that remains to be shown.  Can you
> give an example where this would break existing code?

Anytime there's a symlink in the cwd and it's part of the client root/view, 
but the linked location isn't, existing code using local syntax would break.

For example:

tony at barney:~/p4tmp/client$ p4 client -o

Client: barney
Root:   /home/tony/p4tmp/client
View:
        //depot/... //barney/...

tony at barney:~/p4tmp/client$ p4 where
//depot/... //barney/... /home/tony/p4tmp/client/...

tony at barney:~/p4tmp/client$ ls -l
lrwxrwxrwx 1 tony tony 16 2008-03-11 11:08 symlink -> ../not-in-client

tony at barney:~/p4tmp/client$ cd symlink
tony at barney:~/p4tmp/client/symlink$ irb
irb(main):001:0> require "P4"
=> true
irb(main):002:0> p4 = P4.new
=> #<P4:0x2b8104872d90>
irb(main):003:0> p4.connect
=> true
irb(main):004:0> p4.run_where
=> 
[{"clientFile"=>"//barney/symlink/...", "path"=>"/home/tony/p4tmp/client/symlink/...", "depotFile"=>"//depot/symlink/..."}]


Now, with your change:

tony at barney:~/p4tmp/client/symlink$ irb
irb(main):001:0> require "P4"
=> true
irb(main):002:0> class P4
irb(main):003:1>    class << self
irb(main):004:2>       alias_method :previous_new, :new
irb(main):005:2>       def new(*args, &block)
irb(main):006:3>          previous_pwd = ENV["PWD"]
irb(main):007:3>          begin
irb(main):008:4*             ENV.delete("PWD")
irb(main):009:4>             previous_new(*args, &block)
irb(main):010:4>          ensure
irb(main):011:4*             if previous_pwd
irb(main):012:5>                ENV["PWD"] = previous_pwd
irb(main):013:5>             end
irb(main):014:4>          end
irb(main):015:3>       end
irb(main):016:2>    end
irb(main):017:1> end
=> nil
irb(main):018:0> p4 = P4.new
=> #<P4:0x2af8abc51ee8>
irb(main):019:0> p4.connect
=> true
irb(main):020:0> p4.run_where
P4Exception: [P4#run] Errors during command execution( "p4 where" )

        [Error]: Path '/home/tony/p4tmp/not-in-client/...' is not under 
client's root '/home/tony/p4tmp/client'.


        from /usr/local/lib/site_ruby/1.8/P4.rb:67:in `run'
        from /usr/local/lib/site_ruby/1.8/P4.rb:67:in `method_missing'
        from (irb):20
irb(main):021:0>

> You have said, "The problem is that not everyone wants what you want."
>  But everybody *does* want what I want, which is for this bug to be
> fixed.

This really isn't a bug; it's just the way that ALL Perforce clients handle 
symlinks, and as far as I know, it's always been this way. See also:

http://kb.perforce.com/UserTasks/ConfiguringP4/SymbolicLinks

I think we've covered this subject in sufficient depth here, but if you still 
feel strongly that it's a bug, or you'd like to discuss it further, please 
log a support call by sending a message to support at perforce.com including the 
output of 'p4 info'.

Thanks,

Tony



More information about the p4ruby mailing list