`rbt land` command for landing changes in upstream
Review Request #6509 — Created Oct. 26, 2014 and submitted
rbt land
command for landing changes in upstream
See https://reviewboard.hackpad.com/rbt-land-YrgGuhTuseU
for detailed description of the command.What works:
- Merging/rebasing a branch with/on destination branch.
- Adding a commit message based on the review request.
- Pushing to upstream
- A wrapper around
rbt patch
in order to allow landing
others' changes.
-
Successfully merged and rebased a feature branch to/on master branch.
-
Successfully patched a review request from another user and landed it
on upstream. -
Tested with:
- empty repo
- unclean working directory
- unapproved review request
- same target and destination branches
- incorrect target/destination branch
- incorrect upstream repository
and got appropriate error messages, as expected.
Description | From | Last Updated |
---|---|---|
'APIError' imported but unused |
reviewbot | |
'execute' imported but unused |
reviewbot | |
Col: 80 E501 line too long (81 > 79 characters) |
reviewbot | |
Col: 1 W391 blank line at end of file |
reviewbot | |
'json' imported but unused |
reviewbot | |
local variable 'remote' is assigned to but never used |
reviewbot | |
'APIError' imported but unused |
reviewbot | |
'InvalidRevisionSpecError' imported but unused |
reviewbot | |
'execute' imported but unused |
reviewbot | |
Col: 80 E501 line too long (85 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (81 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (83 > 79 characters) |
reviewbot | |
Col: 1 W391 blank line at end of file |
reviewbot | |
'json' imported but unused |
reviewbot | |
'json' imported but unused |
reviewbot | |
'json' imported but unused |
reviewbot | |
Col: 1 W391 blank line at end of file |
reviewbot | |
'json' imported but unused |
reviewbot | |
Let's use "squash" instead of "flatten". Also, this function and push_upstream need to have NotImplemented stubs in SCMClient. |
chipx86 | |
Blank line between these. |
chipx86 | |
Say you do this on 'master', and your commit is already there. Doing a pull is going to pull down … |
chipx86 | |
Missing a trailing period. |
chipx86 | |
This doesn't really describe what the command does. We should have a lot more detail about what this is and … |
chipx86 | |
The """ should be on the next lin. |
chipx86 | |
Merging shouldn't squash. Or are you saying it'd be the inverse? |
chipx86 | |
Can this be done now? |
chipx86 | |
Just from the common ones, right? How about doing that as part of this change? |
chipx86 | |
'json' imported but unused |
reviewbot | |
Col: 80 E501 line too long (84 > 79 characters) |
reviewbot | |
undefined name 'branch' |
reviewbot | |
undefined name 'branch' |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
'json' imported but unused |
reviewbot | |
Col: 80 E501 line too long (83 > 79 characters) |
reviewbot | |
'json' imported but unused |
reviewbot | |
Col: 69 W291 trailing whitespace |
reviewbot | |
'json' imported but unused |
reviewbot | |
'json' imported but unused |
reviewbot | |
Use a double quote and put the branch name in single quotes, e.g. raise MergeError("Could not checkout branch '%s' ...) … |
brennie | |
Quote branchname in single quotes. |
brennie | |
"to the remote repository" |
chipx86 | |
.reviewboardrc shoudn't be required. It hsould be possible to specify on the command line. |
chipx86 | |
I prefer full sentences that sound more natural, like "A review request ID is required." |
chipx86 | |
This change I think predates the discussion on this, but "BRANCH" can't be used for any kind of real determinations … |
chipx86 | |
This may not be very clear when the user hits it and doesn't realize that they chose the same branch. … |
chipx86 | |
We can't depend on this attribute existing on the review request. It's new in 2.0. You can check with hasattr(). … |
chipx86 | |
"The specified review request ..." This should also include the review_request.approval_failure text. |
chipx86 | |
This should now be MergeError as e. Same in all other cases. |
chipx86 | |
How about "... has landed on <branch>" |
chipx86 | |
Since we're moving to Py2.5+, you'll want to use the new print function. At the top of your file: from … |
brennie | |
This was changed in https://reviews.reviewboard.org/r/6578/ to use __future__.print_function. You should pull master and rebase your changes off of it. Your … |
brennie | |
I had to read the code and think through it to realize what this is doing and why it's there. … |
chipx86 | |
There's a way to simplify this and make the function in general a lot more useful. Instead of hard-coding all … |
chipx86 | |
'json' imported but unused |
reviewbot | |
Col: 36 E111 indentation is not a multiple of four |
reviewbot | |
Col: 36 E113 unexpected indentation |
reviewbot | |
Col: 17 E113 unexpected indentation |
reviewbot | |
Col: 17 E112 expected an indented block |
reviewbot | |
Col: 25 W601 .has_key() is deprecated, use 'in' |
reviewbot | |
Col: 80 E501 line too long (81 > 79 characters) |
reviewbot | |
"are" considered optional. |
chipx86 | |
"an upstream repository." |
chipx86 | |
"the patching step." |
chipx86 | |
Instead of hard-coding here, it's best to identify what's missing in SCMClients that this function needs to support. We can … |
chipx86 | |
This needs to raise a CommandError for the output to be properly shown. Otherwise it'll appear as a crash. Also, … |
chipx86 | |
I just pushed a change that adds this. See what commands/stamp.py and commands/post.py do now. |
chipx86 | |
"Review Board". Can you say: "... an old version (pre-2.0)" that ..." |
chipx86 | |
"support the `approved` field." |
chipx86 | |
Blank line between these. |
chipx86 | |
If we have approved and approval_failure, we have issue_open_count. They were introduced in the same release. |
chipx86 | |
The ending paren should be on the self.options.squash line. |
chipx86 | |
We don't put parens around individual conditions. |
chipx86 | |
Same here. |
chipx86 | |
This looks left over from something. |
chipx86 | |
You can probably make this one line by doing: approval_failure = \ 'The review request ...' |
chipx86 |
- Description:
-
rbt land
command will be used for~ 1.Applying a specific review request to local source tree and pushing it to the main repository. ~ 1.Applying a specific review request to local source tree + and pushing it to the main repository. 2.Pushing users local branch to the main repository. It is not working yet.
Once it works, the command usage will be:
~ `rbt land <request-id> [--patch] [--remote-branch <branch-name>]
~ rbt land <request-id>
+ + Options:
+ + --patch Apply the review request to local
+ repository (i.e. RR belongs to someone else)
+ --history (preserve|squash)
+ Either keep commit history, or squash it into
+ a single commit
+ --remote-branch BRANCH_NAME
+ Push changes to BRANCH_NAME branch (overrides
+ the entry in .reviewboardrc)
+ + + Eventually, the command should be able to guess review request id
+ from past commits. But that code is embedded in rbt post
and needs+ to be refactored before it can be used. So, for now --path
option+ can be used.
- Summary:
-
[WIP] `rbt land` command for landing changes[WIP] `rbt land` command for landing changes in upstream
- Description:
-
~ rbt land
command will be used for~ 1.Applying a specific review request to local source tree ~ and pushing it to the main repository. ~ rbt land
command for landing changes in upstream~ See https://reviewboard.hackpad.com/rbt-land-YrgGuhTuseU ~ for detailed description of the command. - 2.Pushing users local branch to the main repository. ~ It is not working yet.
~ What works:
+ + Merging/rebasing a branch with/on destination branch. + + Adding a commit message based on the review request. + + Pushing to upstream ~ Once it works, the command usage will be:
~ ~ rbt land <request-id>
~ ~ Options:
~ ~ --patch Apply the review request to local
~ What needs to be done:
~ + A wrapper around rbt patch
in order to allow landing~ others' changes. ~ + Lots of error handling. Currently, no error handling is ~ being performed if commit/merge/push is unsuccessful. - repository (i.e. RR belongs to someone else)
- --history (preserve|squash)
- Either keep commit history, or squash it into
- a single commit
- --remote-branch BRANCH_NAME
- Push changes to BRANCH_NAME branch (overrides
- the entry in .reviewboardrc)
- - - Eventually, the command should be able to guess review request id
- from past commits. But that code is embedded in rbt post
and needs- to be refactored before it can be used. So, for now --path
option- can be used. - Testing Done:
-
+ - Successfully merged and rebased a feature branch to/on
master branch.
+ - Tested with
+ - empty repo
+ - unclean working directory
+ - unapproved review request
+ + and got appropriate error messages, as expected.
- Successfully merged and rebased a feature branch to/on
- Commit:
-
2580d773ef57860360adbe729694a213d955581641c142e6018b935ce14384ecaf5ccdb7a89e7140
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py setup.py rbtools/clients/git.py Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py setup.py rbtools/clients/git.py
-
-
-
-
-
-
-
-
-
- Change Summary:
-
Fixed style issues
- Commit:
-
41c142e6018b935ce14384ecaf5ccdb7a89e71401299b17f4cce826d1859168c7ce836e8efa474fb
- Groups:
- Description:
-
rbt land
command for landing changes in upstreamSee https://reviewboard.hackpad.com/rbt-land-YrgGuhTuseU for detailed description of the command. What works:
+ Merging/rebasing a branch with/on destination branch. + Adding a commit message based on the review request. ~ + Pushing to upstream ~ ~ ~ + Pushing to upstream ~ + A wrapper around rbt patch
in order to allow landing~ others' changes. What needs to be done:
- + A wrapper around rbt patch
in order to allow landing- others' changes. + Lots of error handling. Currently, no error handling is being performed if commit/merge/push is unsuccessful. - Commit:
-
1299b17f4cce826d1859168c7ce836e8efa474fbb7992fbe36fd18f9d21aa6de8423d08b194c1134
- Description:
-
rbt land
command for landing changes in upstreamSee https://reviewboard.hackpad.com/rbt-land-YrgGuhTuseU for detailed description of the command. ~ What works:
~ What works:
- + Merging/rebasing a branch with/on destination branch. - + Adding a commit message based on the review request. - + Pushing to upstream - + A wrapper around rbt patch
in order to allow landing- others' changes. ~ What needs to be done:
~ + Lots of error handling. Currently, no error handling is ~ being performed if commit/merge/push is unsuccessful. ~ - Merging/rebasing a branch with/on destination branch.
~ - Adding a commit message based on the review request.
~ - Pushing to upstream
+ - A wrapper around
rbt patch
in order to allow landing
others' changes.
+ + + + NOTE: I've added a new parameter to
rbtools.utils.process.execute()
+ that makes the function throw ExecuteError
exception when the+ command fails. That exception is then cathed and more user-friendly, + message is printed. However I'm not sure if this is the desired + behaviour, because I could not figure out how the errors are handled + right now. + Also, since rbtools.clients.git.GitClient.create_commit()
is being+ used from other places as well as the new code I've added, I could + not use the new exception throwing option on this case, so if commit + fails, the command terminates the old way. - Testing Done:
-
~ - Successfully merged and rebased a feature branch to/on
master branch.
~ - Tested with
~ - empty repo
~ -
Successfully merged and rebased a feature branch to/on master branch.
~ -
Successfully patched a review request from another user and landed it
on upstream.
~ -
Tested with:
- empty repo
- unclean working directory
- unapproved review request
- same target and destination branches
- incorrect target/destination branch
- incorrect upstream repository
- - unclean working directory
- - unapproved review request
and got appropriate error messages, as expected.
- Successfully merged and rebased a feature branch to/on
- Commit:
-
b7992fbe36fd18f9d21aa6de8423d08b194c11347c124acfe14cc450dcbabd75e06b3af1df4b1f53
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py setup.py rbtools/utils/process.py rbtools/clients/git.py Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py setup.py rbtools/utils/process.py rbtools/clients/git.py
-
-
-
-
Let's use "squash" instead of "flatten".
Also, this function and push_upstream need to have NotImplemented stubs in SCMClient.
-
-
Say you do this on 'master', and your commit is already there. Doing a pull is going to pull down new content and merge it in, creating a bit of an annoying merge graph, before pushing.
What you probably want here is 'git pull --rebase'.
Also, pull and push will, depending on settings/version of git, pull/push all branches. I'd be explicit with taking a branch name and passing it in this function.
-
-
This doesn't really describe what the command does. We should have a lot more detail about what this is and why/how it's used.
-
-
-
-
- Summary:
-
[WIP] `rbt land` command for landing changes in upstream`rbt land` command for landing changes in upstream
- Description:
-
rbt land
command for landing changes in upstreamSee https://reviewboard.hackpad.com/rbt-land-YrgGuhTuseU for detailed description of the command. What works:
- Merging/rebasing a branch with/on destination branch.
- Adding a commit message based on the review request.
- Pushing to upstream
- A wrapper around
rbt patch
in order to allow landing
others' changes.
- - - - NOTE: I've added a new parameter to
rbtools.utils.process.execute()
- that makes the function throw ExecuteError
exception when the- command fails. That exception is then cathed and more user-friendly, - message is printed. However I'm not sure if this is the desired - behaviour, because I could not figure out how the errors are handled - right now. - Also, since rbtools.clients.git.GitClient.create_commit()
is being- used from other places as well as the new code I've added, I could - not use the new exception throwing option on this case, so if commit - fails, the command terminates the old way. - Commit:
-
fc062a4201fe362d84752296900f8a3757b1bb7597bc388de9953325d3ea6ab2997651d3d39d04e0
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS
-
-
-
-
-
-
- Change Summary:
-
Fixed style issues
- Commit:
-
97bc388de9953325d3ea6ab2997651d3d39d04e0ba9559378aab4e43d7b524dd9d041bb27653577c
-
Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS
-
-
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS
-
-
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS
-
- Change Summary:
-
Better docstring for
commands.land.Land
- Commit:
-
41183d56fc229db1c212bde520be6bf33b461284139a4b4c0f18775fac796272bb6e493340335e7f
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS
-
-
-
-
-
-
This change I think predates the discussion on this, but "BRANCH" can't be used for any kind of real determinations like this. That option purely handles the visual display of a branch, and can contain any text.
-
This may not be very clear when the user hits it and doesn't realize that they chose the same branch. How about:
"The local branch cannot be merged onto itself. Try a different local branch or destination branch."
-
We can't depend on this attribute existing on the review request. It's new in 2.0.
You can check with
hasattr()
.If it doesn't exist, we can check
review_request.ship_it_count
. -
"The specified review request ..."
This should also include the
review_request.approval_failure
text. -
-
-
I had to read the code and think through it to realize what this is doing and why it's there.
How about calling this build_rbtools_cmd_argv, and having the docs be clear that this is used to take common options passed on the command line or in .reviewboardrc and convert them back into a set of arguments for calling another RBTools command?
-
There's a way to simplify this and make the function in general a lot more useful.
Instead of hard-coding all these here, this function can take a dictionary (defaulting to a predefiend dictionary constant in this module) and build the command lines from that. It can do this with:
```python
def build_rbtools_cmd_argv(options, options_map=DEFAULT_OPTIONS_MAP):
argv = []for option_key, arg_name in six.iteritems(options_map): option_value = getattr(options, option_key, None) if option_value is True: argv.append(arg_name) elif option_value not in (False, None): argv.extend([arg_name, option_value]) return argv
-
-
Use a double quote and put the branch name in single quotes, e.g.
raise MergeError("Could not checkout branch '%s' ...)
It also might read better if the error is on the same line, seperated by a colon instead of newlines.
Same below.
-
-
Since we're moving to Py2.5+, you'll want to use the new print function. At the top of your file:
from __future__ import print_function
and then here you call
print
as a function with parentheses:print('Review request %s ...' % request_id)
Likewise elsewhere you use
print
. -
This was changed in https://reviews.reviewboard.org/r/6578/ to use
__future__.print_function
.You should pull master and rebase your changes off of it. Your patch may not cleanly apply, otherwise.
-
Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS
-
-
-
-
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS
- Change Summary:
-
Changed branch related arguments and options to reflect the discussion in the last group meeting.
- Commit:
-
6c676b89c5b1cd8284bb97a1730bea4d585e7bc0d5e45e68edab59a4c7912523df8fd0c6ebb45498
-
Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/__init__.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/__init__.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS
-
-
Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/__init__.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/__init__.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/__init__.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/__init__.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS
-
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/__init__.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/__init__.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS
-
Just a few things left. Some small wording changes, and a couple things we can now implement based on a recent commit.
Looking great! Can't WAIT to land this :)
-
-
-
-
Instead of hard-coding here, it's best to identify what's missing in SCMClients that this function needs to support. We can then add a
can_<something>
boolean attribute toSCMClient
, defaulting toFalse
, and add an equivalent to the supported SCMClients, set toTrue
.This would then check for those attributes instead. See the new
rbt stamp
for another case where this is done.I imagine we'd want
can_merge
andcan_push_upstream
.This way, other SCMClients will get support for this when those functions are implemented.
-
-
-
-
If we have
approved
andapproval_failure
, we haveissue_open_count
. They were introduced in the same release. -
-
-
-
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/__init__.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/__init__.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS
-
-
This needs to raise a
CommandError
for the output to be properly shown. Otherwise it'll appear as a crash.Also, can you put the space after the
%s
instead of on the next line, and the% self.tool.name
on the next line? Like:raise CommandError('This command ... %s ' 'repositories.' % self.tool.name)
-
-
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/__init__.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/__init__.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS
-
Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/__init__.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/__init__.py rbtools/commands/patch.py rbtools/clients/__init__.py rbtools/clients/git.py setup.py rbtools/clients/errors.py Ignored Files: AUTHORS