Jump to content


managed symlinks in p4 - Why does "p4 print" output not match "ls -l" output


  • Please log in to reply
4 replies to this topic

#1 engr.vns

engr.vns

    Member

  • Members
  • PipPip
  • 12 posts

Posted 26 April 2020 - 09:29 PM

Assume that file.txt (which is a symlink) is in perforce.
To figure out the symlink is pointing to I used

p4 print -q file.txt
/A/B/2/file.txt

This would be mean that the symlink -
file.txt -> /A/B/C/file_v2.txt

I than execute "ls -l" on the same file.txt
file.txt -> /A/B/1/file.txt

My expectation was when you "p4 print" a symlink it prints out the path it's pointing to.

But the difference between "ls -l" and "p4 print" on symlink has got me puzzled.

1. Why is this so and what is the right method to figure out the destination of a symlink file in perforce

Thanks in advance..

#2 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1065 posts

Posted 26 April 2020 - 10:15 PM

Quote

p4 print -q file.txt
/A/B/2/file.txt

This would be mean that the symlink -
file.txt -> /A/B/C/file_v2.txt

How did you get from /A/B/2/file.txt to /A/B/C/file_v2.txt?  And are you positive that the symlink you have on your local disk is the same as the one in the depot?  (Do "p4 clean file.txt" to force a refresh.)

#3 engr.vns

engr.vns

    Member

  • Members
  • PipPip
  • 12 posts

Posted 13 May 2020 - 05:08 PM

HI Sambwise,

p4 clean followed by a "force" refresh did the trick.
The output of "p4 print" and "ls -l " are consistent.

Wonder why the symlink did not get updated with "p4 sync" before?

#4 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1065 posts

Posted 13 May 2020 - 06:23 PM

"p4 sync" will only update files if they have changed in the depot relative to what you synced previously; it's possible to calculate this on the server very quickly without even touching your workspace, which is why "sync" can be extremely fast even if you have a lot of files in the workspace.  

The catch is that if you've changed the file (in this case the symlink) on disk without opening it for edit, it can be different from the depot even though the depot file hasn't changed, and a sync won't update it.

"p4 clean" scans every file in your workspace and forces an update on everything that differs.  This is slower than a normal sync but it's guaranteed to get you back into a clean state.  Ideally, it's better to avoid modifying unopened files so you don't need to worry about ever having to do this.  :)  By default, anything you sync from the depot is read-only as a way of reminding you not to modify it (when you "p4 edit" it, that makes it writable).

#5 engr.vns

engr.vns

    Member

  • Members
  • PipPip
  • 12 posts

Posted 13 May 2020 - 11:17 PM

Thanks Sambwise. :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users