4678: Get "patched file" of a deleted file results into an error

Misery

What version of Review Board are you running?

3.0.5

What version of Review Bot are you running?

1.0

What tool(s) is Review Bot running?

clazy (https://reviews.reviewboard.org/r/9647/)

What steps will reproduce the problem?

  1. Register a review bot that will checkout the whole repository instead of single files
  2. Create a review request that will delete a file
  3. See that review bot tries to check that review request and fails on patching this deleted file

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

no error ;-)

Please provide any additional information below.

ERROR/Worker-6] reviewbot.tasks.RunTool[2905dec2-1bd9-45f2-af08-89cdcf1415c5]: Error executing tool "Clazy": Object does not exist (HTTP 404, API Error 100) (server=https://reviewboard/, review_request_id=11458, diff_revision=1)
Traceback (most recent call last):
File "/[...]/lib/python2.7/site-packages/reviewbot/tasks.py", line 185, in RunTool
base_commit_id=base_commit_id)
File "/[...]/lib/python2.7/site-packages/reviewbot/tools/init.py", line 126, in execute
fp.write(f.patched_file_contents)
File "/[...]/lib/python2.7/site-packages/reviewbot/processing/review.py", line 52, in patched_file_contents
patched_file = self._api_filediff.get_patched_file()
File "/[...]/lib/python2.7/site-packages/rbtools/api/resource.py", line 146, in <lambda>
self._get_url(url, kwargs)))
File "/[...]/lib/python2.7/site-packages/rbtools/api/decorators.py", line 27, in request_method
*args,
kwargs)
File "/[...]/lib/python2.7/site-packages/rbtools/api/transport/sync.py", line 75, in execute_request_method
return self._execute_request(request)
File "/[...]/lib/python2.7/site-packages/rbtools/api/transport/sync.py", line 84, in _execute_request
rsp = self.server.make_request(request)
File "/[...]/lib/python2.7/site-packages/rbtools/api/request.py", line 587, in make_request
self.process_error(e.code, e.read())
File "/[...]/lib/python2.7/site-packages/rbtools/api/request.py", line 560, in process_error
rsp['err']['msg'])
APIError: Object does not exist (HTTP 404, API Error 100)

Misery
#1 Misery

bot/reviewbot/tools/init.py

line 125:

            with open(f.dest_file, 'wb') as fp:
                fp.write(f.patched_file_contents)

            f.patched_file_path = f.dest_file

This should check if the file is deleted and call "os.remove(f.source_file)". Don't know enough of the API to change that.

Does it remove the source_file if dest_file is another file (aka moved file)?