Add command for configuring a repository to point to a Review Board server
Review Request #4662 — Created Sept. 28, 2013 and submitted
Add command for configuring a repository to point to a Review Board server
The new command 'setup-repo' interactively creates the configuration file
.reviewboard in the user's current working directory.Reviewed at https://reviews.reviewboard.org/r/4662/
Tested with Git and Subversion on two Review Board servers.
Unit tests pass.
Description | From | Last Updated |
---|---|---|
'CommandError' imported but unused |
reviewbot | |
Col: 80 E501 line too long (82 > 79 characters) |
reviewbot | |
'test' imported but unused |
reviewbot | |
'json' imported but unused |
reviewbot | |
'CommandError' imported but unused |
reviewbot | |
You might want to look at using distutils.util.strtobool, as that can support multiple ways of yes/no, and can just return … |
PU puiterwijk | |
'test' imported but unused |
reviewbot | |
'json' imported but unused |
reviewbot | |
local variable 'origcwd' is assigned to but never used |
reviewbot | |
Duplicate line. Need to remove. |
ED edwlee | |
'test' imported but unused |
reviewbot | |
'json' imported but unused |
reviewbot | |
undefined name 'PerforceClient' |
reviewbot | |
local variable 'newfile' is assigned to but never used |
reviewbot | |
Col: 1 W391 blank line at end of file |
reviewbot | |
'test' imported but unused |
reviewbot | |
'json' imported but unused |
reviewbot | |
undefined name 'PerforceClient' |
reviewbot | |
local variable 'newfile' is assigned to but never used |
reviewbot | |
'test' imported but unused |
reviewbot | |
'json' imported but unused |
reviewbot | |
undefined name 'PerforceClient' |
reviewbot | |
local variable 'newfile' is assigned to but never used |
reviewbot | |
Col: 20 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 20 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
'test' imported but unused |
reviewbot | |
'json' imported but unused |
reviewbot | |
undefined name 'PerforceClient' |
reviewbot | |
local variable 'newfile' is assigned to but never used |
reviewbot | |
Col: 80 E501 line too long (83 > 79 characters) |
reviewbot | |
Col: 20 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (90 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
'test' imported but unused |
reviewbot | |
'json' imported but unused |
reviewbot | |
I think I'd like "guess_current_branch" more. This method will actually "guess" the branch, rather than "get the guess". I also … |
SM smacleod | |
While a lot of old code doesn't match this, the format should be: """One-line summary.""" or: """One-line summary. Multi-line description. … |
chipx86 | |
I'd like to see a docstring on this, and as part of it an explanation (in git terms) of what … |
SM smacleod | |
This should not be changed like this here. Any command that talks to the Review Board server needs to support … |
SM smacleod | |
Imports go in three groups: Built-in Python modules. Third-party Python modules. Modules as part of the current codebase. The rbtools … |
chipx86 | |
Class names never use _. They're CamelCase. |
chipx86 | |
"Interactively creates" |
chipx86 | |
If you could try to wrap the text so that it's more consistent at where the line ends, that would … |
chipx86 | |
How about we just switch this to say "if the scm client supports it" |
SM smacleod | |
name = "config-repo" |
SM smacleod | |
Maybe we should have something about generating a configuration file here |
SM smacleod | |
I don't know how I feel about changing this from the same option we use for all other commands. Should … |
SM smacleod | |
Same note about docstrings. This applies to all remaining ones. |
chipx86 | |
Docstrings should have a single line summary on the first line, and then a longer description after, like your docstring … |
SM smacleod | |
These don't need to be raw strings. |
chipx86 | |
Same docstring formatting |
SM smacleod | |
This will not return every repository. The API resources are paged so you'll need to be looping through the pages … |
SM smacleod | |
Blank line between these (surrounding blocks) |
chipx86 | |
This if statement is a bit unwieldy. Maybe break it up. You can do: is_match = ( tool_name == repo.tool … |
chipx86 | |
Blank line before. |
chipx86 | |
It's unclear to me what's happening here. In one case, if the user says Yes, we return directly. Otherwise, if … |
chipx86 | |
We do this tool comparison twice. Might be nice to first filter into a list of repositories matching the proper … |
chipx86 | |
Blank line before. |
chipx86 | |
Missing a docstring for this function. |
chipx86 | |
This is unnecessary since the RBTools API doesn't support any reviewboard version <1.6.12 or something |
SM smacleod | |
Missing a docstring. |
chipx86 | |
This won't work in Python 2.4, or 2.5 without importing with_statement from __future__. |
chipx86 | |
print is wrong here. You should be using die(). |
chipx86 | |
This could be combined to one statement. |
chipx86 | |
Use parens for multiple lines instead of . In this case, we usually like to see it like: print ('......' … |
chipx86 | |
Shouldn't call sys.exit. Instead, just return. We don't want callers that call into these classes to exit prematurely. |
chipx86 | |
Ideally, this file wouldn't know which can be guessed. Instead, try calling get_guessed_branch, and if it raises NotImplementedError, catch it … |
chipx86 | |
let's make this "config-repo", instead of "config_repo". We've set a convention with the "api-get", and "list-repo-types" commands that we use … |
SM smacleod | |
All other commands use - instead of _. I think a better name for this would just be "setup", or … |
chipx86 | |
The === length should match the title. |
chipx86 | |
Should be one line. |
chipx86 | |
Python 2.4 doesn't support with, so we can't use that. |
chipx86 | |
"it attempts to guess" |
chipx86 | |
Not all repositories use this format. For example, git@github.com:reviewboard/reviewboard. Nothing else in our codebase attempts to fuzzy-match repositories. I'd suggest … |
chipx86 | |
This needs to compare against both path and mirror_path. |
chipx86 | |
One line. |
chipx86 | |
Can't use with on Python 2.4. |
chipx86 | |
Can't use .format() on the versions of Python we support. |
chipx86 | |
There will always be a name, and we should always generate with a name and not a path. |
chipx86 | |
This doesn't look like it will render the cofnig very nicely to the user. |
chipx86 | |
What about Y, N, YES, Yes, NO, No, etc? Is it case-sensitive? |
chipx86 | |
If this fails, we should probably display something like %s is not a valid answer first. |
chipx86 | |
Two blank lines between top-level items. |
david |
-
This is a review from Review Bot.
Tool: PEP8 Style Checker
Processed Files:
rbtools/commands/create_rc.py
setup.py
Ignored Files:
-
This is a review from Review Bot.
Tool: PEP8 Style Checker
Processed Files:
rbtools/commands/create_rc.py
setup.py
Ignored Files:
-
This is a review from Review Bot.
Tool: Pyflakes
Processed Files:
rbtools/commands/create_rc.py
setup.py
rbtools/clients/init.py
rbtools/commands/init.py
rbtools/clients/git.py
Ignored Files: -
-
-
-
-
This is a review from Review Bot.
Tool: PEP8 Style Checker
Processed Files:
rbtools/commands/create_rc.py
setup.py
rbtools/clients/init.py
rbtools/commands/init.py
rbtools/clients/git.py
Ignored Files:
-
This is a review from Review Bot.
Tool: Pyflakes
Processed Files:
rbtools/commands/create_rc.py
setup.py
rbtools/clients/init.py
rbtools/commands/init.py
rbtools/clients/git.py
Ignored Files: -
-
-
-
- Summary:
-
[WIP] Add command for creating .reviewboardrcAdd command for configuring a repository to point to a Review Board server
- Description:
-
~ [WIP] Add command for creating .reviewboardrc
~ Add command for configuring a repository to point to a Review Board server
+ + The new command 'config_repo' interactively creates the
+ configuration file .reviewboard in the user's current + working directory. + + Reviewed at https://reviews.reviewboard.org/r/4662/
- Testing Done:
-
+ Tested with Git and Subversion on two Review Board servers.
+ + Unit tests pass.
-
This is a review from Review Bot.
Tool: PEP8 Style Checker
Processed Files:
rbtools/commands/config_repo.py
setup.py
rbtools/clients/init.py
rbtools/commands/init.py
rbtools/clients/git.py
Ignored Files: -
-
-
-
This is a review from Review Bot.
Tool: Pyflakes
Processed Files:
rbtools/commands/config_repo.py
setup.py
rbtools/clients/init.py
rbtools/commands/init.py
rbtools/clients/git.py
Ignored Files: -
-
-
-
-
This is a review from Review Bot.
Tool: PEP8 Style Checker
Processed Files:
rbtools/commands/config_repo.py
setup.py
rbtools/clients/init.py
rbtools/commands/init.py
rbtools/clients/git.py
Ignored Files: -
-
-
-
-
-
This is a review from Review Bot.
Tool: Pyflakes
Processed Files:
rbtools/commands/config_repo.py
setup.py
rbtools/clients/init.py
rbtools/commands/init.py
rbtools/clients/git.py
Ignored Files: -
-
-
-
-
-
While a lot of old code doesn't match this, the format should be:
"""One-line summary."""
or:
"""One-line summary.
Multi-line description.
""" -
Imports go in three groups:
- Built-in Python modules.
- Third-party Python modules.
- Modules as part of the current codebase.
The rbtools imports should be separated from the distutils/pkg_resources ones.
-
-
-
If you could try to wrap the text so that it's more consistent at where the line ends, that would be great. Each line should end as close as possible to column 79.
-
-
-
-
This if statement is a bit unwieldy. Maybe break it up. You can do:
is_match = (
tool_name == repo.tool and
self.match_repository_paths(...))if is_match:
May seem silly, but it's nice to keep conditionals a bit simpler.
-
-
It's unclear to me what's happening here.
In one case, if the user says Yes, we return directly. Otherwise, if they say no, we're storing the name. "matched" makes it sound like one that's valid and good, but it seems to me that it's one that we don't want. That could come up multiple times, so that should be a list of discarded_repo_names.
Can you add some comments explaining the workflow for what this is all doing?
-
We do this tool comparison twice. Might be nice to first filter into a list of repositories matching the proper tool. You can do this in the first pass so that you're only iterating through the good list the second time.
In fact, I mentioned a discarded_repo_names list above. We could build a list of good repo names that consists of every entry matching the repo name and not explicitly denied by the user.
-
-
-
-
-
-
-
Use parens for multiple lines instead of .
In this case, we usually like to see it like:
print ('......' '....' % (...))
-
Shouldn't call sys.exit. Instead, just return. We don't want callers that call into these classes to exit prematurely.
-
Ideally, this file wouldn't know which can be guessed. Instead, try calling get_guessed_branch, and if it raises NotImplementedError, catch it and ignore. We'll only store a branch if the tool supports it.
That way, it's easy to add support without touching this file, and third parties can add support as well to their own modules.
-
All other commands use - instead of _.
I think a better name for this would just be "setup", or "setup-repo", but I want David and Steven to weigh in on that.
-
-
I think I'd like "guess_current_branch" more. This method will actually "guess" the branch, rather than "get the guess".
I also kind of like throwing "current" in there since this could be a working directory supporting multiple branches (such as in the git case).
As for the docstring styling, let's go ahead and update this to look like the PEP8 docstrings (see sanitize_changenum above). I understand you're probably just following the majority style in this file, but it does appear we've started to transition to the standard style, so lets keep going.
I'd also like if we could be a little more verbose in describing the intended purpose of this method. How about something like::
"""Guess the repository branch of the current directory. Derived classes should override this method if they are able to determine the current branch of the working directory. The name of the branch which diffs will be generated against should returned. If a derived class supports guessing, but is unable to determine the branch, ``None`` should be returned. """
-
I'd like to see a docstring on this, and as part of it an explanation (in git terms) of what branch is being returned
-
This should not be changed like this here.
Any command that talks to the Review Board server needs to support the "username" and "password" options. (These should be added to your command)
As part of a cleanup I'd like to have some pre-defined options like:
RB_SERVER_OPTIONS = [ ... ] SCM_CLIENT_OPTIONS = [ ... ]
and any commands that use the respective functionality just add these to their list of options. I haven't got around to doing this yet though.
-
-
-
-
I don't know how I feel about changing this from the same option we use for all other commands.
Should probably be:
Option("--server", dest="server", metavar="SERVER", config_key="REVIEWBOARD_URL", default=None, help="specify a different Review Board server to use"),
-
Docstrings should have a single line summary on the first line, and then a longer description after, like your docstring for the whole command
-
-
This will not return every repository. The API resources are paged so you'll need to be looping through the pages as well. You can see an example of this in "rbt post", in the "get_repository_path" method. You'll do something like:
repositories = api_root.get_repositories() try: while True: for repo in repositories: # Your looping in here repositories = repositories.get_next() except StopIteration: pass
-
This is unnecessary since the RBTools API doesn't support any reviewboard version <1.6.12 or something
-
let's make this "config-repo", instead of "config_repo". We've set a convention with the "api-get", and "list-repo-types" commands that we use dashes to seperate words in command names.
- Change Summary:
-
Update description.
- Description:
-
Add command for configuring a repository to point to a Review Board server
~ The new command 'config_repo' interactively creates the
~ configuration file .reviewboard in the user's current ~ The new command 'setup-repo' interactively creates the configuration file
~ .reviewboard in the user's current working directory. - working directory. Reviewed at https://reviews.reviewboard.org/r/4662/
- Change Summary:
-
-Move confirm() to its own file so it can be shared.
-Add command documentation
-Simplify logic in prompting for a matching repository.
-Import with_statement from future for compatibility with Python
2.4 and 2.5.
-Fix loop in iterating through repositories so it retrieve all possible
repositories.
-Update doc strings.
-Fix styling issues.
- Change Summary:
-
-Rename get_guessed_branch() to get_current_branch()
-Extract confirm() to its own file for reusability
-Move confirmation for creating/overwriting .reviewboardrc to the end