Enabling rbt stamp for Perforce
Review Request #7153 — Created April 2, 2015 and submitted
Enable rbt stamp for Perforce
Previously, rbt stamp supported only git. I want to use it for perforce too,
so this change accomplishes that. I've tried to make stamp behave as similarly
as possible to post, with respect to the way a changelist is specified.For perforce, rbt post is able to "update" an existing review without the -u
flag by trying to post the changelist to a new review. ReviewBoard then returns
an exception stating that the changelist already has a review, and then rbt
updates that review instead. To imitate this behavior in rbt stamp, since I
didn't want to actually have to post a review, I implemented a "guessing
strategy" that queries ReviewBoard for a review request associated with the
particular changelist ID. If one is found, that is the review whose URL is
stamped.I would also like to add a stamp option directly into rbt post, so that a
review can be posted and stamped in one command (this would also eliminate
ambiguity about which commit the stamp is attached to), but that will come in a
a separate code review. This would also allow for an additional useful guessing
strategy, to find the review request ID by searching the commit message for a
URL.
Tested manually by posting and stamping many draft reviews with Perforce and Git.
Description | From | Last Updated |
---|---|---|
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
You don't need pass if you have a docstring. We need to fix all these eventually |
brennie | |
I feel like we should have files=None be an extra key word arg to this function so that we can … |
brennie | |
Why are you removing this behaviour? Also no blank line after the docstring. |
brennie | |
You can do git rev-parse <revision-1> <revision-2> and Git will output them on seperate lines. We don't want to be … |
brennie | |
Blank line between these. |
brennie | |
Col: 21 E128 continuation line under-indented for visual indent |
reviewbot | |
Missing capital and period. |
brennie | |
Docstrings must be formatted as follows: """Single line summary. Multi line description. """ |
brennie | |
No blank line here. |
brennie | |
Can you replace this with a raise statement? We are moving away from die going forward. |
brennie | |
Col: 40 E261 at least two spaces before inline comment |
reviewbot | |
Col: 50 E203 whitespace before ':' |
reviewbot | |
Blank line between these. Also, we are moving away from die. Please raise an exception instead. |
brennie | |
Col: 80 E501 line too long (84 > 79 characters) |
reviewbot | |
How many colons to we expect to be in tip? |
brennie | |
The summary should be on the first line. Please use the imperative mood ("Extract ..."). |
brennie | |
Blank line between these. |
brennie | |
Same question here as the one regarding the number of colons we can have in tip. |
brennie | |
Col: 80 E501 line too long (81 > 79 characters) |
reviewbot | |
Docstrings should be formatted as follows: """Single line summary. Multi-line description """ Also, docstrings should be written in the imperative … |
brennie | |
Blank line between these. |
brennie | |
Blank line between these. |
brennie | |
Can you change this into an elif ? |
brennie | |
No blank line here. |
brennie | |
CLN = Change list name? Don't use the acronym here. |
brennie | |
New line between these. |
brennie | |
Blank line between these. |
brennie | |
Col: 80 E501 line too long (82 > 79 characters) |
reviewbot | |
Col: 42 W292 no newline at end of file |
reviewbot | |
Could you split out the changes to this file into a new review request? The --stamp feature isn't really tied … |
brennie | |
Col: 21 E128 continuation line under-indented for visual indent |
reviewbot | |
Undo this change. |
brennie | |
Undo this change. |
brennie | |
Undo this change. |
brennie | |
undefined name 'get_user' |
reviewbot | |
Why this change? |
brennie | |
undefined name 'get_repository_id' |
reviewbot | |
undefined name 'repository_name' |
reviewbot | |
Col: 17 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 1 W293 blank line contains whitespace |
reviewbot | |
Undo this. |
brennie | |
Undo this change. |
brennie | |
Do we really need ALL perforce options in stamp? Why don't we need the options of other SCMs? |
brennie | |
See previous comments on docstrings. Also, if what we are determining is being returned, just say "Return ..." instead. |
brennie | |
No blank line here. |
brennie | |
Can you build this using an {}-expression? |
brennie | |
Blank line here. |
brennie | |
Blank line between tehse. |
brennie | |
Can you add these to the {} expression I asked about above? |
brennie | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
Blank line between these. |
brennie | |
So if we've found multiple review requests, we don't use any of the results? What advantage does this have over … |
brennie | |
Blank line between these. |
brennie | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
Blank line between these. |
brennie | |
You're missing the "latest commit" bit. |
brennie | |
Undo this change. |
brennie | |
Missing a period. |
brennie | |
undefined name 'rid' |
reviewbot | |
Col: 80 E501 line too long (85 > 79 characters) |
reviewbot | |
Col: 1 W293 blank line contains whitespace |
reviewbot | |
Col: 34 W292 no newline at end of file |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
See previous comment about docstrings. |
brennie | |
No blank line here. |
brennie | |
Blank line between these. |
brennie | |
Since we're not expecting to use the STAMP_STRING_FORMAT anywhere else, you can just do a % formatting expression with the … |
brennie | |
Blank line between these. |
brennie | |
'get_repository_id' imported but unused |
reviewbot | |
'get_user' imported but unused |
reviewbot | |
Why do we need the review request and not just the ID? This is to save a round trip right? |
brennie | |
Col: 38 E127 continuation line over-indented for visual indent |
reviewbot | |
Can you format these args better? guess_summary should be on the previous line. |
brennie | |
"A generic error..." |
brennie | |
Please ensure these are alphabetized. |
brennie | |
Period. Perhaps "Query the Review Board server" ? |
brennie | |
Period. |
brennie | |
Period. |
brennie | |
Can we put this in a comment above STMAMP_STRING_FORMAT ? |
brennie | |
Typo -- compatibility. |
gmyers | |
"which is delimited" |
brennie | |
Blank line between these. |
brennie | |
Missing a period. |
brennie | |
Since you're only using the tip key of revisions, can we explicitly take the tip (and call it change_id) ? |
brennie | |
How about "The review request objects returned by this function will only contain some fields, namely:" followed by a list … |
brennie | |
How about "None will be returned instead." ? |
brennie | |
Can you combine these two loggin calls? |
brennie | |
I think it would be easier to read if we didn't use kwargs this way since most of the keys … |
brennie | |
Missing a period. |
brennie | |
Can we remove this debugging call since its basically the same as the next one? |
brennie | |
Can we mention that this matches the tip revision so we know in the debug log what its referring to? |
brennie | |
This function doesn't just determine the review request ID, but also the URL. Since it is returning both, can we … |
brennie | |
This should also mention that its returning the URL. |
brennie | |
Missing a period. |
brennie | |
You shouldn't seperate sentences in comments onto separate lines. |
brennie | |
Should we also have a debugging message when we've found it if we're going to print it out when we … |
brennie | |
Col: 37 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 37 E127 continuation line over-indented for visual indent |
reviewbot | |
undefined name 'repository_name' |
reviewbot | |
Col: 16 E225 missing whitespace around operator |
reviewbot | |
This should use self.git instead of 'git'. |
brennie | |
revisions should line up with the ' in 'git' |
brennie | |
input => input_string ? |
brennie | |
Blank line between end of block and statement. |
brennie | |
I don't know if this comment is necessary. |
brennie | |
Blank line between end of block and statement. |
brennie | |
Can we do from __future__ import unicode_literals here? |
brennie |
-
I'd appreciate it if you could split out the
--strip
option forrbt post
to another review request.Also, could you please write a more detailed description? Summaries should be in the imperative mood ("Enable rbt stamp...").
-
-
I feel like we should have
files=None
be an extra key word arg to this function so that we can provide the original behaviour as well. -
-
You can do
git rev-parse <revision-1> <revision-2>
and Git will output them on seperate lines. We don't want to be executing a lot of other processes unless we need to.You can give the
split_lines=True
key word argument toexecute
to have it split the lines for you. -
-
-
-
-
-
-
-
-
-
-
Docstrings should be formatted as follows:
"""Single line summary. Multi-line description """
Also, docstrings should be written in the imperative mood. For example, "Replace the current description in the specified changeset."
-
-
-
-
-
-
-
-
Could you split out the changes to this file into a new review request? The
--stamp
feature isn't really tied to the Perforce changes. It will make both features easier to review. -
-
-
-
-
-
-
-
See previous comments on docstrings.
Also, if what we are determining is being returned, just say "Return ..." instead.
-
-
-
-
-
-
-
So if we've found multiple review requests, we don't use any of the results? What advantage does this have over the behaviour of the
-u
parameter we use elsewhere that will list out the review request it finds and ask if they are the correct one?Can the behaviour of the
-u
flag be reused? -
-
-
-
-
-
-
-
-
Since we're not expecting to use the
STAMP_STRING_FORMAT
anywhere else, you can just do a%
formatting expression with the "Reviewed at ..." string in there. -
-
-
- Change Summary:
-
Style changes according to comments from Review Bot and Barret, and removed the stamp-while-posting flag from the code review.
- Description:
-
~ Also adding a '-s' flag to rbt post, to post and stamp in the same command
~ Enable rbt stamp for Perforce
+ + Previously, rbt stamp supported only git. I want to use it for perforce too,
+ so this change accomplishes that. I've tried to make stamp behave as similarly + as possible to post, with respect to the way a changelist is specified. + + For perforce, rbt post is able to "update" an existing review without the -u
+ flag by trying to post the changelist to a new review. ReviewBoard then returns + an exception stating that the changelist already has a review, and then rbt + updates that review instead. To imitate this behavior in rbt stamp, since I + didn't want to actually have to post a review, I implemented a "guessing + strategy" that queries ReviewBoard for a review request associated with the + particular changelist ID. If one is found, that is the review whose URL is + stamped. + + I would also like to add a stamp option directly into rbt post, so that a
+ review can be posted and stamped in one command (this would also eliminate + ambiguity about which commit the stamp is attached to), but that will come in a + a separate code review. This would also allow for an additional useful guessing + strategy, to find the review request ID by searching the commit message for a + URL. - Commit:
-
9f8187c167f2102b1e346c17100383fbfb9c0da89c44c843141ac2fa7fe6de864c64fcaf8c7bec33
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py
- Change Summary:
-
More changes per Barret's comments. Most importantly, moved the new "find review ID from change ID" behind a flag, so it's invoked only for repositories that support changesets.
- Commit:
-
9c44c843141ac2fa7fe6de864c64fcaf8c7bec334ce5afa59d8896f11daa15bb43c3d9af45d84455
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py
- Change Summary:
-
Fixed the typo from the last version.
- Commit:
-
4ce5afa59d8896f11daa15bb43c3d9af45d844557753dad6f53c6e2d9c4492dee778b5f022ac542f
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py
- Change Summary:
-
Changes according to the latest round of comments.
Barret, could you please respond to my comments on the remaining open issues from your first review?
- Commit:
-
7753dad6f53c6e2d9c4492dee778b5f022ac542fcc6f07d7abecfa604a120127bd272d784df8b512
-
Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py
- Change Summary:
-
Comments per the latest review comments. Also moved the find_review_request_by_change_id function to review_request.py, since it could be applicable to commands besides stamp.
Something weird is going on with the uploaded diff (between r5-r6), but the full diff (from original) reflects the changes correctly.
- Commit:
-
cc6f07d7abecfa604a120127bd272d784df8b5123c0bf566e5c90ba724ad9402ef0c1df83f78a6bf
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py
-
I'm not sure what happened in the diff generation... I used the tip of mainline (plus my changes) to post the review. I have been rebasing/squashing my commits on a regular-ish basis between postings of the review, so hopefully this won't break the diffing/posting functionality.
-
-
-
-
-
Since you're only using the
tip
key ofrevisions
, can we explicitly take thetip
(and call itchange_id
) ? -
How about
"The review request objects returned by this function will only contain some fields, namely:"
followed by a list of the fields, either inline or in a reST list.
-
-
-
I think it would be easier to read if we didn't use
kwargs
this way since most of the keys in it will be passed no matter what. Sincechangenum
is the only optional argument, can we do something like the following:optional_args = {} if change_id.isdigit(): # ... optional_args['changenum'] = int(change_id) review_requests = api_root.get_review_requests(repository=repository_id, from_user=user.username, #..., **optional_args)
-
-
-
Can we mention that this matches the
tip
revision so we know in the debug log what its referring to? -
This function doesn't just determine the review request ID, but also the URL. Since it is returning both, can we call it
determine_review_request_id_and_url
ordetermine_review_request
? -
-
-
-
Should we also have a debugging message when we've found it if we're going to print it out when we attempt to find it?
- Change Summary:
-
Changes per latest comments, and fixed a None case that I caught in testing.
- Commit:
-
3c0bf566e5c90ba724ad9402ef0c1df83f78a6bf17c5a02ce10b85d09a56cf110e87d8ca25c4276c
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py
-
- Change Summary:
-
Addressed the latest comments and rebased (so some changes that aren't mine are now in the inter-revision diff).
Also moved get_user and get_repository_info back to their original locations, to cut down on the amount in the diff. I know it's sacrificing performance for one particular use case (making the same API call twice), but it avoids duplicating those lines of code in the different command files (land, stamp, post).
- Commit:
-
17c5a02ce10b85d09a56cf110e87d8ca25c4276c19907a5b3a2def6d0bb224b2cd5103055f390e6f
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py
-
-
Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py
-
-
- Change Summary:
-
Fixed issues from Review Bot
- Commit:
-
19907a5b3a2def6d0bb224b2cd5103055f390e6fcf9bc3cc3d824b4d4133cc5e625ec3e6cf33b61b
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py
- Change Summary:
-
Fixed an accidental omission in the log statement
- Commit:
-
cf9bc3cc3d824b4d4133cc5e625ec3e6cf33b61be5026cdbc1397e94f4162a4933a2a4bb30f64753
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py
- Change Summary:
-
Changed per latest comments.
- Commit:
-
e5026cdbc1397e94f4162a4933a2a4bb30f647531eff637b003d37b67878f49fbaf51a6d2338d58a
-
Tool: Pyflakes Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py Tool: PEP8 Style Checker Processed Files: rbtools/commands/land.py rbtools/utils/commands.py rbtools/commands/stamp.py rbtools/commands/post.py rbtools/clients/__init__.py rbtools/clients/git.py rbtools/clients/perforce.py rbtools/utils/review_request.py rbtools/clients/errors.py