Skip files where 'p4 print' provides a symlink

Review Request #3221 — Created July 16, 2012 and submitted

Information

RBTools

Reviewers

The riddle: how can a file both exist and not exist? The answer: symlinks!
When a symlink is checked into perforce running 'p4 print -o' will create a
symlink, not the file that it points to. This naturally makes postreview.py
choke...

~% post-review
Traceback (most recent call last):
  File "/share/rbtools/rbtools/postreview.py", line 4115, in <module>
    main()  
  File "/share/rbtools/rbtools/postreview.py", line 4061, in main 
    diff, parent_diff = tool.diff(args)
  File "/share/rbtools/rbtools/postreview.py", line 2002, in diff 
    return self._changenum_diff(changenum)
  File "/share/rbtools/rbtools/postreview.py", line 2299, in _changenum_diff
    self._write_file(old_depot_path, tmp_diff_from_filename)
  File "/share/rbtools/rbtools/postreview.py", line 2475, in _write_file
    os.chmod(tmpfile, stat.S_IREAD | stat.S_IWRITE)
OSError: [Errno 2] No such file or directory: '/tmp/tmpsCS-fw'

Resolving symlinks, especially those with a relative path would be tricky. 
Also, there's no certainty that the file it points to is even in version 
control. Hence I'm just dropping it from the review with a warning.
Tested this change both when reviewing a single symlink file and a batch of
files containing a symlink.

We've been using this change against RBTools 0.3. I've adapted the change for
the current master but this copy of it hasn't been exercised.
Description From Last Updated

Col: 80 E501 line too long (82 > 79 characters)

reviewbotreviewbot

This should probably either use logging.warning() or sys.stderr.write()

daviddavid

Same here.

daviddavid

And here.

daviddavid

Last one.

daviddavid
AT
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        rbtools/clients/perforce.py
      Ignored Files:
    
    
  2. rbtools/clients/perforce.py (Diff revision 2)
     
     
    Show all issues
    Col: 80
     E501 line too long (82 > 79 characters)
    
  3. 
      
AT
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        rbtools/clients/perforce.py
      Ignored Files:
    
    
  2. 
      
david
  1. 
      
  2. rbtools/clients/perforce.py (Diff revision 3)
     
     
    Show all issues
    This should probably either use logging.warning() or sys.stderr.write()
    1. Probably the former. We're trying to get rid of all direct stdout/stderr usage in the clients.
  3. rbtools/clients/perforce.py (Diff revision 3)
     
     
    Show all issues
    Same here.
  4. rbtools/clients/perforce.py (Diff revision 3)
     
     
    Show all issues
    And here.
  5. rbtools/clients/perforce.py (Diff revision 3)
     
     
    And here...
  6. rbtools/clients/perforce.py (Diff revision 3)
     
     
    Show all issues
    Last one.
  7. 
      
AT
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        rbtools/clients/perforce.py
      Ignored Files:
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
AT
Review request changed
Status:
Completed
Change Summary:
Pushed to master (8e72821). Thanks!