Add Mercurial hook to post to ReviewBoard on push
Review Request #8554 — Created Nov. 26, 2016 and discarded
Add Mercurial hook to post to ReviewBoard on push
The hook only allows to push if all commits have been approved in a
review requests, otherwise it rejects it and creates a review request
for the (new) commits. This is similar to "rbt post", but1. Does not require the user to install RBTools locally.
2. Makes sure any changes pushed to the central server have been
reviewed and approved.
3. Adds references to tickets/bugs/issues, which rbt post doesn't do.
4. Automatically finds the right review request to update if there
are any new commits, based the commit ID and a date/author hash.
This does not require the user to confirm anything, which rbt post
(often) requires. This also allows the hook to recognize
rebased/amended changesets, because the date/author hash
is unchanged.
- Created new review requests
- Updated existing review requests
- Tried to push not approved changesets
- Pushed approved changesets
- Checked matching of changesets with another date / author hash
Description | From | Last Updated |
---|---|---|
I like to replace this by rbtools stuff but I don't know how the rbtools API works. I tried to … |
misery | |
Col: 51 E226 missing whitespace around arithmetic operator |
reviewbot | |
Should probably just be "/usr/bin/env python" (which is defined to be python 2). |
david | |
Should probably just be "/usr/bin/env python" (which is defined to be python 2). |
david | |
"Review Board" |
david | |
"Review Board" |
david | |
Typo: changset |
david | |
It's much more correct to actually return 0 or 1 (or some other exit code number), rather than True or … |
david | |
This method doesn't seem to actually return anything?? |
david | |
This could be: return any( r.summary == request.summary for r in revreqs ) |
david | |
If this is similar to the methods in logging, you can pass the format argument in as an argument to … |
david | |
In order to be consistent with the other log messages, this should probably be "Ignoring..." |
david | |
"None" is probably more appropriate (and less likely to cause subtle bugs) than -1. |
david | |
Blank line between these two. |
david | |
a reviewboard hook information? |
david | |
Blank line after class docstrings. |
david | |
I don't understand what this is supposed to be testing. It looks like it just processes a constant and checks … |
david | |
This seems like something that should be in a separate change. |
david |
-
-
I like to replace this by rbtools stuff but I don't know how the rbtools API works.
I tried to derive Command to get an api_root with an authenticated session. But I get an error for this. Can someone help? :-)
class MercurialHookCmd(Command): name = 'MercurialHook' option_list = [ Command.server_options, ] cmd = MercurialHookCmd() # cmd.run_from_argv(['','','','','']) server_url = cmd.get_server_url(None, None) api_client, api_root = cmd.get_api(url) get_authenticated_session(api_client, api_root, auth_required=True, num_retries=0) self.root = api_root
AttributeError: 'MercurialHookCmd' object has no attribute 'options'
- Summary:
-
A Mercurial hook to post to ReviewBoard on pushAdd Mercurial hook to post to ReviewBoard on push
- Description:
-
~ A Mercurial hook to post to ReviewBoard on push
~ Add Mercurial hook to post to ReviewBoard on push
The hook only allows to push if all commits have been approved in a
review requests, otherwise it rejects it and creates a review request for the (new) commits. This is similar to "rbt post", but 1. Does not require the user to install RBTools locally.
2. Makes sure any changes pushed to the central server have been reviewed and approved. 3. Adds references to tickets/bugs/issues, which rbt post doesn't do. 4. Automatically finds the right review request to update if there are any new commits, based the commit ID and a date/author hash. This does not require the user to confirm anything, which rbt post (often) requires. This also allows the hook to recognize rebased/amended changesets, because the date/author hash is unchanged. - Testing Done:
-
+ - Created new review requests
+ - Updated existing review requests
+ - Tried to push not approved changesets
+ - Pushed approved changesets
+ - Checked matching of changesets with another date / author hash
- Commit:
-
efa27376c51823355d58b93bde602ba9e0ba4c7bf3e2978c0d8ee62e97398c9fa6449826ca413eb4
-
Tool: Pyflakes Processed Files: rbtools/utils/review_request.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/clients/mercurial.py rbtools/hooks/tests.py Tool: PEP8 Style Checker Processed Files: rbtools/utils/review_request.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/clients/mercurial.py rbtools/hooks/tests.py
- Change Summary:
-
Fix encoding again and use HookError exception
- Commit:
-
f3e2978c0d8ee62e97398c9fa6449826ca413eb40a9341082aa8f72f6c31059a868f5773c7a27b14
-
Tool: Pyflakes Processed Files: rbtools/utils/review_request.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/clients/mercurial.py rbtools/hooks/tests.py Tool: PEP8 Style Checker Processed Files: rbtools/utils/review_request.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/clients/mercurial.py rbtools/hooks/tests.py
-
New code, even that in contrib/, should use the new docstring conventions: https://www.reviewboard.org/docs/codebase/dev/docs/writing-codebase-docs/
-
-
-
-
-
-
It's much more correct to actually return 0 or 1 (or some other exit code number), rather than True or False.
-
-
-
If this is similar to the methods in
logging
, you can pass the format argument in as an argument tolog()
, which prevents trying to format it twice. -
-
-
-
-
-
I don't understand what this is supposed to be testing. It looks like it just processes a constant and checks how many lines in that constant start with + but not +++. That doesn't seem like a very useful thing to test.
-
-
Tool: Pyflakes Processed Files: rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/clients/mercurial.py rbtools/hooks/tests.py Tool: PEP8 Style Checker Processed Files: rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/clients/mercurial.py rbtools/hooks/tests.py