Setting up the bot to handle Git repositories and pass the repository paths to the tools

Review Request #5869 — Created May 23, 2014 and discarded

Information

ReviewBot
release-0.2.x

Reviewers

Sets up repository on ReviewBot load
- stores repositories in root folder
- updates repositories programatically

Supports Git, but easy to extend for new types of repositories
- switch to base commit
- use SCM tool to apply patch to temp repository

Fixed bug in make_tempfile

Delete temporary folders

Added cached_property to ReviewBot
- turned File properties into cached properties
- cached path property on Repository_Clone

Added new Tool base class to support access to entire repository
- sending repository path to tool
- comment on a file by its path
- created example ReviewBot tool to look at entire repository
- added more Queues to Celery so that a bot only picks up a task that it has the repository for

Added flag to extension model to signal if ReviewBot tool supports entire directory
- added UI in admin panel to show this

The following configuration was used in reviewbot/config.py

from reviewbot.revisioning.constants import GIT


BOT_REPOSITORY_SETTINGS = {
    'http://localhost:8080/': {
        'ReviewBot': {
            'type': GIT,
            'url': 'git://github.com/reviewboard/ReviewBot.git',
        },
    },
}

The following tool was added at the path reviewbot/tools/pep8repo.py

import os

from reviewbot.tools import RepositoryTool
from reviewbot.tools.process import execute
from reviewbot.utils import is_exe_in_path


class PEP8RepoTool(RepositoryTool):
    name = 'PEP8 Style Checker - Entire Repository'
    version = '0.2'
    description = "Checks code for style errors using the PEP8 tool."

    def check_dependencies(self):
        return is_exe_in_path('pep8')

    def handle_repository(self, repository_working_directory):
        path = repository_working_directory.path
        if not path:
            return False

        for root, subFolders, files in os.walk(path):
            for file_path in files:
                if not file_path.endswith('.py'):
                    continue

                full_path = os.path.join(root, file_path)

                output = execute(
                    [
                        'pep8',
                        '-r',
                        full_path
                    ],
                    split_lines=True,
                    ignore_errors=True)

                for line in output:
                    parsed = line.split(':', 3)
                    lnum = int(parsed[1])
                    col = int(parsed[2])
                    msg = parsed[3]
                    repository_working_directory.comment(
                        full_path,
                        'Col: %s\n%s' % (col, msg),
                        lnum)

        return True

I used a server running on "http://localhost:8080" to test my changes. The setup process is the same as if you were setting up ReviewBot normally. When refreshing the list of tools, PEP8 Style Checker - Entire Repository should show up with a value of true in the 'working directory required' column. To test I set both it and the normal PEP8 Style Checker to run automatically to compare output.

Tests:
1. On the second startup of the bot, it should take less time than the second to start Celery (if you include the reviewboard repository it is more noticeable). This indicates that the repository is being stored between bot sessions as expected. These repositories should stored in a folder system ~/ReviewBotRepositories/server_url/repo_name/.
2. In the celery startup output, it should be shown that one of the Celery Queues the bot is listening on is: pep8repo.0.2.http://localhost:8080/.ReviewBot exchange=pep8repo.0.2.http://localhost:8080/.ReviewBot(direct) key=pep8repo.0.2.http://localhost:8080/.ReviewBot
3. The reviewboard page /admin/extensions/reviewbotext.extension.ReviewBotExtension/db/reviewbotext/reviewbottool/ should show a column called Working directory required. For the tool 'PEP8 Style Checker - Entire Repository' there should be a green check.
5. In the middle of a review being made (celery.contrib.rdb.set_trace() was used to pause in the middle), there should be a file in /tmp/ that contains the patch to apply to the repository to get the code as it is in the review request.
4. In the middle of a review being made (celery.contrib.rdb.set_trace() was used to pause in the middle), there should be a folder in /tmp/ that contains the ReviewBot repository without the .git folder. The state of the repository should be identical to that of the review request.
5. After a publishing a review, checking the /tmp/ folder of the bot should show there are no temp files or directories.
6. Both the normal PEP8 and the full repository PEP8 should complete without error. The resulting code comments should be identical. Of particular note, there should be no comments on files not changed in the review request.

Description From Last Updated

Col: 14 E203 whitespace before ':'

reviewbotreviewbot

Col: 14 E203 whitespace before ':'

reviewbotreviewbot

local variable 'repo' is assigned to but never used

reviewbotreviewbot

Col: 15 E203 whitespace before ':'

reviewbotreviewbot

Col: 14 E203 whitespace before ':'

reviewbotreviewbot

Col: 15 E203 whitespace before ':'

reviewbotreviewbot

Col: 14 E203 whitespace before ':'

reviewbotreviewbot

Col: 1 E302 expected 2 blank lines, found 1

reviewbotreviewbot

Col: 1 E302 expected 2 blank lines, found 1

reviewbotreviewbot

local variable 'repo' is assigned to but never used

reviewbotreviewbot

'Repo' imported but unused

reviewbotreviewbot

'NoSuchPathError' imported but unused

reviewbotreviewbot

Col: 1 E302 expected 2 blank lines, found 1

reviewbotreviewbot

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

reviewbotreviewbot

Col: 1 E302 expected 2 blank lines, found 1

reviewbotreviewbot

Col: 52 E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

Col: 54 E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

Col: 51 E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

Col: 53 E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

Col: 71 E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

Col: 73 E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

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

reviewbotreviewbot

Col: 1 W391 blank line at end of file

reviewbotreviewbot

'ToolRepository' imported but unused

reviewbotreviewbot

Col: 5 E265 block comment should start with '# '

reviewbotreviewbot

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

reviewbotreviewbot

Col: 50 E261 at least two spaces before inline comment

reviewbotreviewbot

Col: 50 E262 inline comment should start with '# '

reviewbotreviewbot

Col: 5 E265 block comment should start with '# '

reviewbotreviewbot

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

reviewbotreviewbot

'RepositoryManager' imported but unused

reviewbotreviewbot

local variable 'tool_repository' is assigned to but never used

reviewbotreviewbot

Col: 22 E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

Col: 24 E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

Col: 29 E203 whitespace before ':'

reviewbotreviewbot

local variable 'tool_repository' is assigned to but never used

reviewbotreviewbot

You'll want to put a blank line before from reviewboar.revisioning.repository_manager import RepositoryManger. The why we style our imports is as …

SM smacleod

Leave this blank line in, we want 2 blanks here.

SM smacleod

So as I mentioned in the hackpad we want to namespace the configuration down one more level to include the …

SM smacleod

Is there a reason you chose to use abstract base classes for this? If not, I think we should just …

SM smacleod

The docstring should be before any code in the method.

SM smacleod

What is _path here suppose to represent, and why does it just return self.name? What am I missing?

SM smacleod

So a couple of things with this: @classmethod methods should generally use "cls" as the first argument, not "self". What …

SM smacleod

Instead of doing these checks from constants and then using a particular class, we should just create a dictionary mapping …

SM smacleod

Col: 1 E302 expected 2 blank lines, found 1

reviewbotreviewbot

In order to intiialize the tool repository we'll need: * The name of the repository * The Review Board server …

SM smacleod

local variable 'tool_repository' is assigned to but never used

reviewbotreviewbot

Lets call this working_dir_required

SM smacleod

'RepositoryManager' imported but unused

reviewbotreviewbot

undefined name 'shutil'

reviewbotreviewbot

Col: 1 E302 expected 2 blank lines, found 1

reviewbotreviewbot

Col: 1 W391 blank line at end of file

reviewbotreviewbot

local variable 'e' is assigned to but never used

reviewbotreviewbot

undefined name 'logging'

reviewbotreviewbot

Col: 25 E128 continuation line under-indented for visual indent

reviewbotreviewbot

'rdb' imported but unused

reviewbotreviewbot

Col: 9 E265 block comment should start with '# '

reviewbotreviewbot

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

reviewbotreviewbot

undefined name 'self'

reviewbotreviewbot

Col: 29 E126 continuation line over-indented for hanging indent

reviewbotreviewbot

Col: 17 E128 continuation line under-indented for visual indent

reviewbotreviewbot

undefined name 'path'

reviewbotreviewbot

undefined name 'payload'

reviewbotreviewbot

undefined name 'logger'

reviewbotreviewbot

undefined name 'repository_manager'

reviewbotreviewbot

undefined name 'payload'

reviewbotreviewbot

undefined name 'RepositoryClone'

reviewbotreviewbot

undefined name 'logger'

reviewbotreviewbot

undefined name 'repository_clone'

reviewbotreviewbot

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

reviewbotreviewbot

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

reviewbotreviewbot

Col: 21 E128 continuation line under-indented for visual indent

reviewbotreviewbot

'RepositoryClone' imported but unused

reviewbotreviewbot

Col: 19 E262 inline comment should start with '# '

reviewbotreviewbot

'GIT' imported but unused

reviewbotreviewbot

Maybe I should include this in the comments rather than in the actual code. I really want whoever writes the …

MA matthewcmaclean

Can you remove the extra space and add a period at the end of the sentence?

anselinaanselina

Capitalize the first word + period (for consistency?)

PE PeterTran

s/supoort/support

anselinaanselina

s/an/An

anselinaanselina

Can you capitalize URL? Here and in all your other comments/docstrings.

anselinaanselina

Remove the apostrophe on "name's".

anselinaanselina

We generally add full-package imports before single-item imports, so this should go after import tempfile.

anselinaanselina

Remove the extra space before and after the sentence, and add a period.

anselinaanselina

Can you add a blank line after this? We generally have one blank line before and after if/for/while blocks.

anselinaanselina

Can you add a blank line before this, while you're here?

anselinaanselina

Add a blank line before this.

anselinaanselina

Remove the extra space before the sentence.

anselinaanselina

Remove the extra space before and after the sentence.

anselinaanselina

Remove the extra space before and after the sentence. Here and in all other docstrings below.

anselinaanselina

Remove the extra space before the sentence, and add a period.

anselinaanselina

This should come directly after from git.exc import NoSuchPathError (since RBTools would be considered as a third-party library import for …

anselinaanselina

This should be: from os import chdir, get cwd from re import sub from django.utils.functional import cached_property from rbtools.commands.patch import …

anselinaanselina

We generally use single quotes for strings. (Here and in other places.)

anselinaanselina

Can you change this to: logging.warning( 'server: %s, repository %s: type%s is not supported' % (server_url, repo_name, repo_settings['type']))

anselinaanselina

You will need a space after been. Otherwise when the Exception is raised it'll be concatenated like: Respository _ in …

PE PeterTran

Can you make this into a single-line docstring, like """Returns the server URL and names of repositories the bot supports."""?

anselinaanselina

s/seperately/separately

anselinaanselina

Should this class be uppercase?

PE PeterTran

Can you remove the extra space before the sentence, and add a period?

anselinaanselina

Add a blank line after this.

anselinaanselina

Since you removed your pep8repo tool used for testing, this line should also be deleted.

anselinaanselina

If there are multiple tools with working_directory_required == True, this will initialize the RepositoryManager multiple times. Each queue would be …

anselinaanselina

If the patch doesn't apply cleanly or raises an error, we probably shouldn't proceed with the review. execute() has some …

anselinaanselina

Can we call this RepositoryWorkingDirectory instead (or something to that effect), and change the docstring to "Represents a working directory …

anselinaanselina

Can we put this in a function like initialize_repository_manager(), and just add a call to this in celery.py if a …

anselinaanselina

Can you indent this an extra level?

anselinaanselina

"static" should be removed since we can now do more than just static analysis with the full working directory.

anselinaanselina

Indent this an extra level.

anselinaanselina

Actually, sorry, instead of calling initialize_repositories() here, how about we call it in supported_repositories()?

anselinaanselina

Globals are usually capitalized, so can you make this be REPOSITORIES?

anselinaanselina

Let's set REPOSITORIES = None in line 12, and set REPOSITORIES = {} here. This way, we can just do …

anselinaanselina
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/config.py
      Ignored Files:
    
    
  2. bot/reviewbot/config.py (Diff revision 1)
     
     
    Col: 14
     E203 whitespace before ':'
    
  3. bot/reviewbot/config.py (Diff revision 1)
     
     
    Col: 14
     E203 whitespace before ':'
    
  4. 
      
reviewbot
  1. This is a review from Review Bot.
      Tool: Pyflakes
      Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/config.py
      Ignored Files:
    
    
  2. bot/reviewbot/tasks.py (Diff revision 1)
     
     
     local variable 'repo' is assigned to but never used
    
  3. 
      
MA
MA
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/revisioning/base_repository.py
        bot/setup.py
        bot/reviewbot/revisioning/tool_repository.py
        bot/reviewbot/celery.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/config.py
      Ignored Files:
    
    
  2. bot/reviewbot/config.py (Diff revision 2)
     
     
    Col: 15
     E203 whitespace before ':'
    
  3. bot/reviewbot/config.py (Diff revision 2)
     
     
    Col: 14
     E203 whitespace before ':'
    
  4. bot/reviewbot/config.py (Diff revision 2)
     
     
    Col: 15
     E203 whitespace before ':'
    
  5. bot/reviewbot/config.py (Diff revision 2)
     
     
    Col: 14
     E203 whitespace before ':'
    
  6. Col: 1
     E302 expected 2 blank lines, found 1
    
  7. Col: 1
     E302 expected 2 blank lines, found 1
    
  8. Col: 1
     E302 expected 2 blank lines, found 1
    
  9. Col: 80
     E501 line too long (99 > 79 characters)
    
  10. Col: 1
     E302 expected 2 blank lines, found 1
    
  11. Col: 52
     E251 unexpected spaces around keyword / parameter equals
    
  12. Col: 54
     E251 unexpected spaces around keyword / parameter equals
    
  13. Col: 51
     E251 unexpected spaces around keyword / parameter equals
    
  14. Col: 53
     E251 unexpected spaces around keyword / parameter equals
    
  15. Col: 71
     E251 unexpected spaces around keyword / parameter equals
    
  16. Col: 73
     E251 unexpected spaces around keyword / parameter equals
    
  17. Col: 80
     E501 line too long (83 > 79 characters)
    
  18. Col: 1
     W391 blank line at end of file
    
  19. bot/reviewbot/tasks.py (Diff revision 2)
     
     
    Col: 5
     E265 block comment should start with '# '
    
  20. bot/reviewbot/tasks.py (Diff revision 2)
     
     
    Col: 80
     E501 line too long (85 > 79 characters)
    
  21. bot/reviewbot/tasks.py (Diff revision 2)
     
     
    Col: 50
     E261 at least two spaces before inline comment
    
  22. bot/reviewbot/tasks.py (Diff revision 2)
     
     
    Col: 50
     E262 inline comment should start with '# '
    
  23. extension/reviewbotext/models.py (Diff revision 2)
     
     
    Col: 5
     E265 block comment should start with '# '
    
  24. 
      
reviewbot
  1. This is a review from Review Bot.
      Tool: Pyflakes
      Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/revisioning/base_repository.py
        bot/setup.py
        bot/reviewbot/revisioning/tool_repository.py
        bot/reviewbot/celery.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/config.py
      Ignored Files:
    
    
  2.  local variable 'repo' is assigned to but never used
    
  3.  'Repo' imported but unused
    
  4.  'NoSuchPathError' imported but unused
    
  5. bot/reviewbot/tasks.py (Diff revision 2)
     
     
     'ToolRepository' imported but unused
    
  6. 
      
MA
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/revisioning/base_repository.py
        bot/setup.py
        bot/reviewbot/revisioning/tool_repository.py
        bot/reviewbot/celery.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/config.py
      Ignored Files:
    
    
  2. bot/reviewbot/tasks.py (Diff revision 3)
     
     
    Col: 80
     E501 line too long (82 > 79 characters)
    
  3. 
      
reviewbot
  1. This is a review from Review Bot.
      Tool: Pyflakes
      Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/revisioning/base_repository.py
        bot/setup.py
        bot/reviewbot/revisioning/tool_repository.py
        bot/reviewbot/celery.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/config.py
      Ignored Files:
    
    
  2. 
      
MA
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/revisioning/base_repository.py
        bot/setup.py
        bot/reviewbot/revisioning/tool_repository.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/config.py
      Ignored Files:
    
    
  2. bot/reviewbot/tasks.py (Diff revision 4)
     
     
    Col: 22
     E251 unexpected spaces around keyword / parameter equals
    
  3. bot/reviewbot/tasks.py (Diff revision 4)
     
     
    Col: 24
     E251 unexpected spaces around keyword / parameter equals
    
  4. extension/reviewbotext/handlers.py (Diff revision 4)
     
     
    Col: 29
     E203 whitespace before ':'
    
  5. 
      
reviewbot
  1. This is a review from Review Bot.
      Tool: Pyflakes
      Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/revisioning/base_repository.py
        bot/setup.py
        bot/reviewbot/revisioning/tool_repository.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/config.py
      Ignored Files:
    
    
  2.  'RepositoryManager' imported but unused
    
  3. bot/reviewbot/tasks.py (Diff revision 4)
     
     
     local variable 'tool_repository' is assigned to but never used
    
  4. 
      
MA
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/revisioning/base_repository.py
        bot/setup.py
        bot/reviewbot/revisioning/tool_repository.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/config.py
      Ignored Files:
    
    
  2. 
      
reviewbot
  1. This is a review from Review Bot.
      Tool: Pyflakes
      Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/revisioning/base_repository.py
        bot/setup.py
        bot/reviewbot/revisioning/tool_repository.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/config.py
      Ignored Files:
    
    
  2. bot/reviewbot/tasks.py (Diff revision 5)
     
     
     local variable 'tool_repository' is assigned to but never used
    
  3. 
      
MA
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/revisioning/base_repository.py
        bot/setup.py
        bot/reviewbot/revisioning/tool_repository.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/config.py
    
    Ignored Files:
        bot/reviewbot/revisioning/.repository_manager.py.swp
        extension/reviewbotext/.handlers.py.swp
        bot/reviewbot/.config.py.swp
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/revisioning/base_repository.py
        bot/setup.py
        bot/reviewbot/revisioning/tool_repository.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/config.py
    
    Ignored Files:
        bot/reviewbot/revisioning/.repository_manager.py.swp
        extension/reviewbotext/.handlers.py.swp
        bot/reviewbot/.config.py.swp
    
    
  2. Col: 1
     E302 expected 2 blank lines, found 1
    
  3. bot/reviewbot/tasks.py (Diff revision 6)
     
     
     local variable 'tool_repository' is assigned to but never used
    
  4. 
      
SM
  1. I think we're moving in the right directions here. I've done a quick pass and noted some of the style issues I caught, as well as some of the bigger conventional, architectural, or preferential issues.

    Also, it looks like a bunch of binary swap files snuck into your diff. Please remove these from your commits in future revisions.

  2. bot/reviewbot/celery.py (Diff revision 6)
     
     
     
     
     
     
     

    You'll want to put a blank line before from reviewboar.revisioning.repository_manager import RepositoryManger.

    The why we style our imports is as follows:

    <Python Standard Library Imports>
    <Blank Line>
    <Third Party Library Imports>
    <Blank Line>
    <Package Imports>

    Where third party library imports are things from outside the project (anything not from "reviewbot")

  3. bot/reviewbot/celery.py (Diff revision 6)
     
     

    Leave this blank line in, we want 2 blanks here.

  4. bot/reviewbot/config.py (Diff revision 6)
     
     
     
     
     
     
     
     
     
     
     

    So as I mentioned in the hackpad we want to namespace the configuration down one more level to include the Review Board server url.

    So in this case we'd have:
    repo_settings = {
    "http://localhost:8080/": {
    "RBTools": {
    "type": GIT,
    "url": "git://github.com/reviewboard/rbtools.git",
    },
    "Review Board": {
    "type": GIT,
    "url": "git://github.com/reviewboard/reviewboard.git",
    },
    },
    }

  5. Is there a reason you chose to use abstract base classes for this?

    If not, I think we should just use the normal inheritance. Just defining a set of methods in the base class which make up the interace and then defining them in each class should be fine.

  6. The docstring should be before any code in the method.

  7. What is _path here suppose to represent, and why does it just return self.name? What am I missing?

  8. bot/reviewbot/revisioning/repository_manager.py (Diff revision 6)
     
     
     
     

    So a couple of things with this:

    @classmethod methods should generally use "cls" as the first argument, not "self". What is actually passed will be the class not an object so this makes that clearer.

    Using this sort of singleton class as an object is less testable than just actually using an object or sets of functions - and we usually don't do it this way around the rest of the code. (I know, Review Bot doesn't have test... but I hope it does one day).

  9. Instead of doing these checks from constants and then using a particular class, we should just create a dictionary mapping repositories type string to the classes. That will allow a quick lookup and instantiation of the proper class.

    All of these repo types should inherit from the same class and have the same interface going forward. So while there is only git right now, keep that in mind.

  10. bot/reviewbot/tasks.py (Diff revision 6)
     
     
     
     
     
     

    In order to intiialize the tool repository we'll need: * The name of the repository * The Review Board server URL,

    I think we should keep the commit information out of it at the initialization step, and move that into a method you call on the ToolRepository object - "getWorkingdirectoryForCommit()" or something.

  11. extension/reviewbotext/models.py (Diff revision 6)
     
     

    Lets call this working_dir_required

  12. 
      
MA
MA
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/revisioning/base_repository.py
        bot/reviewbot/processing/filesystem.py
        bot/setup.py
        bot/reviewbot/revisioning/tool_repository.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/config.py
    
    
  2. bot/reviewbot/processing/filesystem.py (Diff revision 7)
     
     
    Col: 1
     E302 expected 2 blank lines, found 1
    
  3. bot/reviewbot/processing/filesystem.py (Diff revision 7)
     
     
    Col: 1
     W391 blank line at end of file
    
  4. Col: 25
     E128 continuation line under-indented for visual indent
    
  5. 
      
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/revisioning/base_repository.py
        bot/reviewbot/processing/filesystem.py
        bot/setup.py
        bot/reviewbot/revisioning/tool_repository.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/config.py
    
    
  2. bot/reviewbot/celery.py (Diff revision 7)
     
     
     'RepositoryManager' imported but unused
    
  3. bot/reviewbot/processing/filesystem.py (Diff revision 7)
     
     
     undefined name 'shutil'
    
  4.  local variable 'e' is assigned to but never used
    
  5.  undefined name 'logging'
    
  6. 
      
MA
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2.  'rdb' imported but unused
    
  3. Col: 9
     E265 block comment should start with '# '
    
  4. Col: 80
     E501 line too long (85 > 79 characters)
    
  5.  undefined name 'self'
    
  6. Col: 29
     E126 continuation line over-indented for hanging indent
    
  7. Col: 17
     E128 continuation line under-indented for visual indent
    
  8. 
      
MA
MA
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2. Col: 80
     E501 line too long (85 > 79 characters)
    
  3. Col: 80
     E501 line too long (83 > 79 characters)
    
  4. Col: 21
     E128 continuation line under-indented for visual indent
    
  5. bot/reviewbot/tools/__init__.py (Diff revision 9)
     
     
    Col: 19
     E262 inline comment should start with '# '
    
  6. 
      
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2. bot/reviewbot/processing/filesystem.py (Diff revision 9)
     
     
     undefined name 'path'
    
  3. bot/reviewbot/processing/review.py (Diff revision 9)
     
     
     undefined name 'payload'
    
  4. bot/reviewbot/processing/review.py (Diff revision 9)
     
     
     undefined name 'logger'
    
  5. bot/reviewbot/processing/review.py (Diff revision 9)
     
     
     undefined name 'repository_manager'
    
  6. bot/reviewbot/processing/review.py (Diff revision 9)
     
     
     undefined name 'payload'
    
  7. bot/reviewbot/processing/review.py (Diff revision 9)
     
     
     undefined name 'RepositoryClone'
    
  8. bot/reviewbot/processing/review.py (Diff revision 9)
     
     
     undefined name 'logger'
    
  9. bot/reviewbot/processing/review.py (Diff revision 9)
     
     
     undefined name 'repository_clone'
    
  10. bot/reviewbot/tasks.py (Diff revision 9)
     
     
     'RepositoryClone' imported but unused
    
  11. 
      
MA
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/tools/pep8repo.py
        extension/reviewbotext/admin.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2. 
      
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/tools/pep8repo.py
        extension/reviewbotext/admin.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2. 
      
MA
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/tools/pep8repo.py
        extension/reviewbotext/admin.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/tools/pep8repo.py
        extension/reviewbotext/admin.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2. 
      
MA
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/tools/pep8repo.py
        extension/reviewbotext/admin.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/tools/pep8repo.py
        extension/reviewbotext/admin.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2. 
      
MA
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/admin.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/admin.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2. bot/reviewbot/config.py (Diff revision 13)
     
     
     'GIT' imported but unused
    
  3. 
      
MA
  1. 
      
  2. bot/reviewbot/config.py (Diff revision 13)
     
     

    Maybe I should include this in the comments rather than in the actual code. I really want whoever writes the config to use those constants, hence the inclusion here.

  3. 
      
MA
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/admin.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/admin.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2. 
      
PE
  1. 
      
  2. bot/reviewbot/celery.py (Diff revision 14)
     
     
     

    Capitalize the first word + period (for consistency?)

  3. You will need a space after been. Otherwise when the Exception is raised it'll be concatenated like:

    Respository _ in server __ has not beeninitialized in ...

  4. bot/reviewbot/utils.py (Diff revision 14)
     
     

    Should this class be uppercase?

    1. Since it is a property, it shouldn't be uppercase.

  5. 
      
anselina
  1. Thanks for the detailed description! This is mostly a style review since I haven't been following your project closely. I'll try to follow up with another review of the logic though, after I read your Hackpad.

  2. bot/reviewbot/celery.py (Diff revision 14)
     
     

    Can you remove the extra space and add a period at the end of the sentence?

  3. bot/reviewbot/config.py (Diff revision 14)
     
     

    s/supoort/support

  4. bot/reviewbot/config.py (Diff revision 14)
     
     

    s/an/An

  5. bot/reviewbot/config.py (Diff revision 14)
     
     

    Can you capitalize URL? Here and in all your other comments/docstrings.

  6. bot/reviewbot/config.py (Diff revision 14)
     
     

    Remove the apostrophe on "name's".

  7. bot/reviewbot/processing/filesystem.py (Diff revision 14)
     
     

    We generally add full-package imports before single-item imports, so this should go after import tempfile.

  8. bot/reviewbot/processing/filesystem.py (Diff revision 14)
     
     

    Remove the extra space before and after the sentence, and add a period.

  9. bot/reviewbot/processing/filesystem.py (Diff revision 14)
     
     

    Can you add a blank line after this? We generally have one blank line before and after if/for/while blocks.

  10. bot/reviewbot/processing/filesystem.py (Diff revision 14)
     
     

    Can you add a blank line before this, while you're here?

  11. bot/reviewbot/processing/filesystem.py (Diff revision 14)
     
     

    Add a blank line before this.

  12. bot/reviewbot/processing/filesystem.py (Diff revision 14)
     
     

    Remove the extra space before the sentence.

  13. bot/reviewbot/processing/filesystem.py (Diff revision 14)
     
     

    Remove the extra space before and after the sentence.

  14. bot/reviewbot/processing/review.py (Diff revision 14)
     
     

    Remove the extra space before and after the sentence. Here and in all other docstrings below.

  15. bot/reviewbot/processing/review.py (Diff revision 14)
     
     

    Remove the extra space before the sentence, and add a period.

  16. This should come directly after from git.exc import NoSuchPathError (since RBTools would be considered as a third-party library import for Review Bot).

  17. bot/reviewbot/revisioning/repository_client.py (Diff revision 14)
     
     
     
     
     
     
     

    This should be:

    from os import chdir, get cwd
    from re import sub
    
    from django.utils.functional import cached_property
    from rbtools.commands.patch import Patch
    
    from reviewbot.processing.filesystem import make_tempfile
    
  18. We generally use single quotes for strings. (Here and in other places.)

  19. bot/reviewbot/revisioning/repository_manager.py (Diff revision 14)
     
     
     
     
     
     

    Can you change this to:

    logging.warning(
        'server: %s, repository %s: type%s is not supported' %
        (server_url, repo_name, repo_settings['type']))
    
  20. Can you make this into a single-line docstring, like """Returns the server URL and names of repositories the bot supports."""?

  21. bot/reviewbot/tools/__init__.py (Diff revision 14)
     
     

    s/seperately/separately

  22. bot/reviewbot/utils.py (Diff revision 14)
     
     

    Can you remove the extra space before the sentence, and add a period?

  23. bot/reviewbot/utils.py (Diff revision 14)
     
     

    Add a blank line after this.

  24. bot/setup.py (Diff revision 14)
     
     

    Since you removed your pep8repo tool used for testing, this line should also be deleted.

  25. 
      
MA
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/tools/pep8repo.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/admin.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/tools/pep8repo.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/admin.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2. 
      
MA
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/admin.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2. 
      
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        bot/setup.py
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/admin.py
        bot/reviewbot/revisioning/repository_clone.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2. 
      
anselina
  1. This looks great! You may not have time for this, but I think it'd be good to also grab the branch information off the review request, and actually checkout that branch before switching to the base commit and applying the patch.

  2. bot/reviewbot/celery.py (Diff revision 16)
     
     
     
     
     
     

    If there are multiple tools with working_directory_required == True, this will initialize the RepositoryManager multiple times. Each queue would be added several times extra too.

    Also, I'm just curious if there is a reason for having separate queues for each repository (instead of a single pep8repo tool queue, for example)?

    1. The reason for each repository to have it's own queue is so particular workers can be configured to only service a subset of the repositories. In some organizations, repositories could be quite large, and there could be many of them - this multiple queue system allows specific workers to handle only certain repos.

    2. Cool, that makes sense!

  3. If the patch doesn't apply cleanly or raises an error, we probably shouldn't proceed with the review. execute() has some parameters dealing with errors.

    1. So the current behaviour is that if there is an error in executing the command, it will be thrown in execute via a call to sys.exit(1). This will terminate the process running the review on the repository; however, the bot will remain up. So any subsequent calls to the bot will be handled as normal. The error thrown will depend on what caused the command to fail, but an example error is:

      [2014-08-09 15:00:13,520: WARNING/Worker-1] Failed to execute command: ['git', 'apply', '/tmp/tmpsrBBQ9']
      error: patch failed: bot/reviewbot/celery.py:6
      error: bot/reviewbot/celery.py: patch does not apply
      error: bot/reviewbot/config.py: already exists in working directory
      error: patch failed: bot/reviewbot/processing/filesystem.py:1
      error: bot/reviewbot/processing/filesystem.py: patch does not apply
      error: patch failed: bot/reviewbot/processing/review.py:1
      error: bot/reviewbot/processing/review.py: patch does not apply
      error: bot/reviewbot/revisioning/init.py: already exists in working directory
      error: bot/reviewbot/revisioning/git_repository_client.py: already exists in working directory
      error: bot/reviewbot/revisioning/repository_client.py: already exists in working directory
      error: bot/reviewbot/revisioning/repository_clone.py: already exists in working directory
      error: bot/reviewbot/revisioning/repository_manager.py: already exists in working directory
      error: patch failed: bot/reviewbot/tasks.py:56
      error: bot/reviewbot/tasks.py: patch does not apply
      error: patch failed: bot/reviewbot/tools/init.py:1
      error: bot/reviewbot/tools/init.py: patch does not apply
      error: patch failed: bot/reviewbot/utils.py:20
      error: bot/reviewbot/utils.py: patch does not apply
      error: patch failed: bot/setup.py:28
      error: bot/setup.py: patch does not apply
      error: patch failed: extension/reviewbotext/admin.py:17
      error: extension/reviewbotext/admin.py: patch does not apply
      error: patch failed: extension/reviewbotext/extension.py:66
      error: extension/reviewbotext/extension.py: patch does not apply
      error: patch failed: extension/reviewbotext/handlers.py:23
      error: extension/reviewbotext/handlers.py: patch does not apply
      error: patch failed: extension/reviewbotext/models.py:24
      error: extension/reviewbotext/models.py: patch does not apply
      error: patch failed: extension/reviewbotext/resources.py:170
      error: extension/reviewbotext/resources.py: patch does not apply
      [2014-08-09 15:00:14,529: ERROR/MainProcess] Process 'Worker-1' pid:9312 exited with 'exitcode 1'
      [2014-08-09 15:00:14,541: ERROR/MainProcess] Task reviewbot.tasks.ProcessReviewRequest[13c1bc14-53eb-435c-8a75-b7d75b721da2] raised unexpected: WorkerLostError('W
      orker exited prematurely: exitcode 1.',)
      Traceback (most recent call last):
      File "/home/vagrant/rbenv/local/lib/python2.7/site-packages/billiard-3.3.0.17-py2.7-linux-x86_64.egg/billiard/pool.py", line 1169, in mark_as_worker_lost
      human_status(exitcode)),
      WorkerLostError: Worker exited prematurely: exitcode 1.

      The alternative to this is using the 'ignore_errors' flag in execute and instead using the 'none_on_ignored_error' flag. Then I could catch the result in the apply patch command and throw a custom Exception, but this would by-pass https://github.com/reviewboard/rbtools/blob/master/rbtools/utils/process.py#L7, which to be fair doesn't do a whole lot at the moment.

      Do you have a preference on how to handle the error?

    2. Sorry, should've been more specific! The latter is what I had in mind (setting ignore_errors=True and none_on_ignored_error=True and checking if execute() returns None) since in the new API, workers can update tool executions with their status and result. So in this case, the worker would update the tool execution as being "failed" and put the error message (e.g., "Patch did not apply cleanly") as the result.

    3. Cool, so I check for the None return in the git_repository_client.py. The other option is _apply_patch_to_current_directory could return None if it fails and some other value if it succeeds and then repository_client.py could throw the exception for all SCM implementations.

      Since we only care if it is an error, the more appropriate manner to communicate that seems to be through exception rather than return value. As well, we don't know the return values of future SCM patch implementations, so it seemed better to throw the exception in git_repository_client.py rather than in repository_client.py.

  4. bot/reviewbot/revisioning/repository_clone.py (Diff revision 16)
     
     
     

    Can we call this RepositoryWorkingDirectory instead (or something to that effect), and change the docstring to "Represents a working directory of a specified repository."? It's easy to mistake this to be an actual clone of the repo.

  5. bot/reviewbot/revisioning/repository_manager.py (Diff revision 16)
     
     
     
     
     
     
     
     
     
     
     
     
     
     

    Can we put this in a function like initialize_repository_manager(), and just add a call to this in celery.py if a working directory is required for one of the tools? This will make it more testable for the future.

    1. Would we want to move all the contents of this file into init.py in revisioning? The file was originally made since there was a manager object. I don't know what best practice is for that.

    2. I think it's a good idea to move this into revisioning/__init__.py.

    3. So I moved the repository_manager.py stuff into revisioning/__init__.py; however, it resulted in a circular dependency between config.py and revisioning/__init__.py. So I moved the declaration of GIT and REPOSITORY_MAP to revisioning/constants.py. This helps localize changes to constants when you add a new SCM and it means that revisioning/__init__.py doesn't need to import GIT anymore.

      I also switched the other global variables to be all caps.

  6. bot/reviewbot/tasks.py (Diff revision 16)
     
     

    Can you indent this an extra level?

  7. bot/reviewbot/tools/__init__.py (Diff revision 16)
     
     

    "static" should be removed since we can now do more than just static analysis with the full working directory.

  8. extension/reviewbotext/resources.py (Diff revision 16)
     
     

    Indent this an extra level.

  9. 
      
MA
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_working_dir.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/admin.py
        bot/setup.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2. 
      
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/repository_working_dir.py
        bot/reviewbot/revisioning/repository_manager.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/admin.py
        bot/setup.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2. 
      
anselina
  1. 
      
  2. bot/reviewbot/celery.py (Diff revision 17)
     
     

    Actually, sorry, instead of calling initialize_repositories() here, how about we call it in supported_repositories()?

  3. Globals are usually capitalized, so can you make this be REPOSITORIES?

  4. Let's set REPOSITORIES = None in line 12, and set REPOSITORIES = {} here.

    This way, we can just do if REPOSITORIES is None to check if the RepositoryClients have been instantiated/initialized, so we don't need the initialized boolean anymore.

    Let's actually also move this logic to supported_repositories(), so it'll look like:

    def supported_repositories():
        global REPOSITORIES
    
        if REPOSITORIES is None:
            initialize_repositories()
    
        return REPOSITORIES.keys()
    
    1. Oops, forgot one more thing - we won't need the global REPOSITORIES line in supported_repositories() or get_repository(). It's only needed to modify/create a global variable, not to access one.

  5. 
      
MA
MA
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/admin.py
        bot/setup.py
        bot/reviewbot/revisioning/repository_working_dir.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2. 
      
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        bot/reviewbot/tasks.py
        bot/reviewbot/revisioning/git_repository_client.py
        bot/reviewbot/tools/__init__.py
        bot/reviewbot/revisioning/constants.py
        bot/reviewbot/processing/filesystem.py
        extension/reviewbotext/admin.py
        bot/setup.py
        bot/reviewbot/revisioning/repository_working_dir.py
        bot/reviewbot/celery.py
        extension/reviewbotext/handlers.py
        extension/reviewbotext/resources.py
        extension/reviewbotext/extension.py
        bot/reviewbot/utils.py
        extension/reviewbotext/models.py
        bot/reviewbot/revisioning/__init__.py
        bot/reviewbot/processing/review.py
        bot/reviewbot/config.py
        bot/reviewbot/revisioning/repository_client.py
    
    
  2. 
      
david
Review request changed

Status: Discarded

Loading...