4003: Regression from 0.7.4 - Fails to post a review from Perforce client

a.tinsmith

What version are you running?

RBTools 0.7.5

What steps will reproduce the problem?

  1. rbt post -d //repo/path/...@123,@456

What is the expected output? What do you see instead?

Expected: New review request posted.
Actual: Fails to post.

What operating system are you using?

  • Windows 7 64-bit
  • MSYS2 as command prompt.
  • Python 2.7.10
  • p4 client: Rev. P4/NTX64/2015.1/1227227 (2015/08/27).
  • p4 server: P4D/SOLARIS10X86_64/2015.1/1204891 (2015/07/17)

Attach the debug out from the command.

$ rbt post -d //repo/path/...@123,@456
>>> RBTools 0.7.5
>>> Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]
>>> Running on Windows-7-6.1.7601-SP1
>>> Home = C:\msys64\home\username
>>> Current directory = C:\dev\blah
>>> Checking for a Perforce repository...
>>> Running: p4 info
>>> Running: diff --version
>>> repository info: Path: perforce.company_host:1666, Base path: None, Supports changesets: True
>>> Making HTTP GET request to http://reviews.company_host/api/
>>> Running: p4 info
>>> Writing "//repo/path/file.cpp#1" to "c:\users\username\appdata\local\temp\tmp_3jkfy"
>>> Running: p4 print -o c:\users\username\appdata\local\temp\tmp_3jkfy -q //repo/path/file.cpp#1
>>> Writing "//repo/path/file.cpp#3" to "c:\users\username\appdata\local\temp\tmpkkkaqq"
>>> Running: p4 print -o c:\users\username\appdata\local\temp\tmpkkkaqq -q //repo/path/file.cpp#3
>>> Running: diff -urNp c:\users\username\appdata\local\temp\tmp_3jkfy c:\users\username\appdata\local\temp\tmpkkkaqq
>>> Command exited with rc 1: [u'diff', u'-urNp', 'c:\\users\\username\\appdata\\local\\temp\\tmp_3jkfy', 'c:\\users\\username\\appdata\\local\\temp\\tmpkkkaqq']
>>> Making HTTP GET request to http://reviews.company_host/api/validation/diffs/
>>> Cached response for HTTP GET http://reviews.company_host/api/validation/diffs/ expired and was modified
>>> Making HTTP POST request to http://reviews.company_host/api/validation/diffs/
Traceback (most recent call last):
  File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\rbt.exe\__main__.py", line 9, in <module>
  File "c:\python27\lib\site-packages\rbtools\commands\main.py", line 133, in main
    command.run_from_argv([RB_MAIN, command_name] + args)
  File "c:\python27\lib\site-packages\rbtools\commands\__init__.py", line 622, in run_from_argv
    exit_code = self.main(*args) or 0
  File "c:\python27\lib\site-packages\rbtools\commands\post.py", line 765, in main
    changenum = self.tool.get_changenum(self.revisions)
  File "c:\python27\lib\site-packages\rbtools\clients\perforce.py", line 663, in get_changenum
    tip = revisions['tip']
TypeError: 'NoneType' object has no attribute '__getitem__'

Please provide any additional information below.

The same command works perfectly with RBTools 0.7.4

I have the following C:\Users\username\AppData\Roaming\.reviewboardrc file:

REVIEWBOARD_URL = 'http://reviews.company_host/'
REPOSITORY = 'repo'
REPOSITORY_TYPE = 'perforce'
USERNAME = 'rbuser'
PASSWORD = 'rbpass'
OPEN_BROWSER = True
#1 a.tinsmith

This fix apparently eliminates the problem.

  • +
    --- /c/Python27/Lib/site-packages/rbtools/clients/perforce.py.orig	2015-10-28 17:53:53.485204400 +1100
    +++ /c/Python27/Lib/site-packages/rbtools/clients/perforce.py	2015-10-28 17:51:38.350204400 +1100
    @@ -660,12 +660,13 @@
             # this to remove the server-side implementation and just implement
             # --guess-summary and --guess-description, but that would likely
             # create a lot of unhappy users.
    -        tip = revisions['tip']
    +        if revisions is not None:
    +            tip = revisions['tip']
     
    -        if tip.startswith(self.REVISION_PENDING_CLN_PREFIX):
    -            tip = tip[len(self.REVISION_PENDING_CLN_PREFIX):]
    -            if tip != self.REVISION_DEFAULT_CLN:
    -                return tip
    +            if tip.startswith(self.REVISION_PENDING_CLN_PREFIX):
    +                tip = tip[len(self.REVISION_PENDING_CLN_PREFIX):]
    +                if tip != self.REVISION_DEFAULT_CLN:
    +                    return tip
     
             return None
     
brennie
#2 brennie

Hi there!

Would you mind posting this change for review on https://reviews.reviewboard.org/r/new/ ?

Thanks!

#3 a.tinsmith

Hi,

I can't post it since I made it by hacking files after installation on my machine, not in Git branch. Also, I think that the check should be better than just naive if revisions is not None:. Maybe something like:

if revisions is not None and 'tip' in revisions:
    tip = revisions['tip']

# ...

And I didn't run any tests to verify the fix.

I'd appreciate if you post new review request, since you have dev environment set up and ready and I don't.

Thanks.

#4 a.tinsmith

Updated version of the fix. So far, no problems detected.

  • +
    --- rbtools/clients/perforce.py	2015-10-28 17:53:53.485204400 +1100
    +++ rbtools/clients/perforce.py	2015-10-29 09:00:22.396494600 +1100
    @@ -660,12 +660,13 @@
             # this to remove the server-side implementation and just implement
             # --guess-summary and --guess-description, but that would likely
             # create a lot of unhappy users.
    -        tip = revisions['tip']
    +        if revisions is not None and 'tip' in revisions:
    +            tip = revisions['tip']
     
    -        if tip.startswith(self.REVISION_PENDING_CLN_PREFIX):
    -            tip = tip[len(self.REVISION_PENDING_CLN_PREFIX):]
    -            if tip != self.REVISION_DEFAULT_CLN:
    -                return tip
    +            if tip.startswith(self.REVISION_PENDING_CLN_PREFIX):
    +                tip = tip[len(self.REVISION_PENDING_CLN_PREFIX):]
    +                if tip != self.REVISION_DEFAULT_CLN:
    +                    return tip
     
             return None
     
david
#5 david

This was fixed in 4fb00467, which shipped in 0.7.7

  • -New
    +Fixed