4364: rbt patch --px N throws exception because it fails to convert N to an int

sallan
brennie
brennie

What version are you running?

rbt --version
RBTools 0.7.4

What steps will reproduce the problem?

d:\work> rbt patch --px 4 --repository-type perforce -d 128385

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

I get an error because the '4' is not being converted to an integer. See debug output below. I edited clients/init.py to fix the problem:

--- broken.py 2016-03-07 09:26:28.137642200 -0800
+++ init.py 2016-03-07 09:26:45.392642200 -0800
@@ -194,7 +194,7 @@
cmd.append('-R')

     if p_num >= 0:
  • cmd.append('-p%d' % p_num)
  • cmd.append('-p%d' % int(p_num))
     cmd.extend(['-i', six.text_type(patch_file)])
    

And now I get the desiered result:
Patch is being applied from request 128385 with diff revision 2.

Running: patch -p4 -i c:\users\sallan\appdata\local\temp\tmp7hrwbp

<file list left out>

Successfully applied patch.

What operating system are you using?

Windows 7

Attach the debug out from the command.

d:\work> rbt patch --px 4 --repository-type perforce -d 128385

RBTools 0.7.4
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)]
Running on Windows-7-6.1.7601-SP1
Home = C:\Users\sallan\AppData\Roaming
Current directory = d:\data-dev
Running: git version
Checking for a Perforce repository...
Running: p4 info
Running: diff --version
repository info: Path: XXXXXXX, Base path: None, Supports changesets: True
Making HTTP GET request to http://reviewboard/api/
Making HTTP GET request to http://reviewboard/api/review-requests/128385/diffs/
Cached response for HTTP GET http://reviewboard/api/review-requests/128385/diffs/ expired and was modified
Making HTTP GET request to http://reviewboard/api/review-requests/128385/diffs/2/
Cached response for HTTP GET http://reviewboard/api/review-requests/128385/diffs/2/ expired and was not modified
Making HTTP GET request to http://reviewboard/api/review-requests/128385/diffs/2/
Cached response for HTTP GET http://reviewboard/api/review-requests/128385/diffs/2/ expired and was not modified
Patch is being applied from request 128385 with diff revision 2.
Traceback (most recent call last):
File "C:\Python27\Scripts\rbt-script.py", line 9, in <module>
load_entry_point('RBTools==0.7.4', 'console_scripts', 'rbt')()
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 612, in run_from_argv
exit_code = self.main(*args) or 0
File "C:\Python27\lib\site-packages\rbtools\commands\patch.py", line 189, in main
revert=self.options.revert_patch)
File "C:\Python27\lib\site-packages\rbtools\commands\patch.py", line 101, in apply_patch
base_dir, self.options.px, revert=revert)
File "C:\Python27\lib\site-packages\rbtools\clients__init__.py", line 197, in apply_patch
cmd.append('-p%d' % p_num)
TypeError: %d format: a number is required, not str

Please provide any additional information below.

I fixed it on my machine by editing rbtools/clients/init.py:
--- broken.py 2016-03-07 09:26:28.137642200 -0800
+++ init.py 2016-03-07 09:26:45.392642200 -0800
@@ -194,7 +194,7 @@
cmd.append('-R')

     if p_num >= 0:
  • cmd.append('-p%d' % p_num)
  • cmd.append('-p%d' % int(p_num))
     cmd.extend(['-i', six.text_type(patch_file)])
    
#1 sallan

I just installed 0.7.5 alpha and verified the bug is there as well, so maybe there's still time to get it fixed for 0.7.5?

$ rbt --version
RBTools 0.7.5 alpha 0 (dev)

brennie
#2 brennie
  • +brennie