Add NoneType check for revisions in Perforce get_changenum().

Review Request #8133 — Created April 28, 2016 and submitted

Information

RBTools
master
6358738...

Reviewers

When posting a diff of a range of submitted changelists, rbt post command fails with teh following Traceback:
rbt post --repository=Perforce //a/b/c/...@23,@28

File "/usr/local/bin/rbt", line 9, in <module>
load_entry_point('RBTools==0.7.6', 'console_scripts', 'rbt')()
File "/usr/local/lib/python2.7/dist-packages/RBTools-0.7.6-py2.7.egg/rbtools/commands/main.py", line 133, in main
command.run_from_argv([RB_MAIN, command_name] + args)
File "/usr/local/lib/python2.7/dist-packages/RBTools-0.7.6-py2.7.egg/rbtools/commands/init.py", line 629, in run_from_argv
exit_code = self.main(*args) or 0
File "/usr/local/lib/python2.7/dist-packages/RBTools-0.7.6-py2.7.egg/rbtools/commands/post.py", line 767, in main
changenum = self.tool.get_changenum(self.revisions)
File "/usr/local/lib/python2.7/dist-packages/RBTools-0.7.6-py2.7.egg/rbtools/clients/perforce.py", line 666, in get_changenum
tip = revisions['tip']
TypeError: 'NoneType' object has no attribute 'getitem'

This is because the range of revisions does not associate with a single changelist.
Adding a NoneType check for revisions in Perforce get_changenum() fixes it.

Manual Testing:
Uploaded / updated Perforce reviews.

Description From Last Updated

Col: 22 E711 comparison to None should be 'if cond is not None:'

reviewbotreviewbot
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/clients/perforce.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/clients/perforce.py
    
    
  2. rbtools/clients/perforce.py (Diff revision 1)
     
     
    Show all issues
    Col: 22
     E711 comparison to None should be 'if cond is not None:'
    
  3. 
      
AM
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/clients/perforce.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/clients/perforce.py
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
AM
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-0.7.x (4fb0046)
PE
  1. Ship It!
  2. 
      
Loading...