Added a mercurial hook for posting review requests when pushing to central repo.
Review Request #7100 — Created March 21, 2015 and discarded
A Mercurial hook to post to Review Board on push to a central server.
The hook was designed to make posting to Review Board easy for new or inexperienced users. It allows user to post to ReviewBoard by using the ordinary "hg push", without any need to learn or install RBTools locally.
The hook only allows the 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. makes links of all 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.
The hook has been tested both with some unit testing and partly in a production environment.
Unit testing also included testing communication with server, which revealed a few issues that have been fixed.
I wasn't sure how these unit tests should be included in the test suites for RBTools, so I've left them out for now.
Description | From | Last Updated |
---|---|---|
Col: 61 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 68 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 39 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 42 E251 unexpected spaces around keyword / parameter equals |
reviewbot | |
Col: 44 E226 missing whitespace around arithmetic operator |
reviewbot | |
'from rbtools.hooks.mercurial import *' used; unable to detect undefined names |
reviewbot | |
Col: 59 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 63 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
Col: 42 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 51 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 61 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 68 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 39 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 42 E251 unexpected spaces around keyword / parameter equals |
reviewbot | |
Col: 44 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 61 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 68 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
'from rbtools.hooks.mercurial import *' used; unable to detect undefined names |
reviewbot | |
Col: 23 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 22 W503 line break before binary operator |
reviewbot | |
Col: 21 W503 line break before binary operator |
reviewbot | |
Col: 27 W503 line break before binary operator |
reviewbot | |
Col: 23 W503 line break before binary operator |
reviewbot | |
Col: 23 W503 line break before binary operator |
reviewbot | |
Col: 61 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 30 W503 line break before binary operator |
reviewbot | |
Col: 68 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 29 W503 line break before binary operator |
reviewbot | |
Col: 25 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 30 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
'from rbtools.hooks.mercurial import *' used; unable to detect undefined names |
reviewbot | |
Col: 23 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 22 W503 line break before binary operator |
reviewbot | |
Col: 21 W503 line break before binary operator |
reviewbot | |
Col: 27 W503 line break before binary operator |
reviewbot | |
Col: 23 W503 line break before binary operator |
reviewbot | |
Col: 23 W503 line break before binary operator |
reviewbot | |
Col: 61 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 30 W503 line break before binary operator |
reviewbot | |
Col: 68 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 29 W503 line break before binary operator |
reviewbot | |
Col: 25 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 30 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 26 W503 line break before binary operator |
reviewbot | |
Col: 13 E128 continuation line under-indented for visual indent |
reviewbot | |
Col: 59 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 66 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 59 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 66 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 22 W503 line break before binary operator |
reviewbot | |
Branch information would be helpful |
misery | |
I think a new request should be in draft mode to allow the developer additional changes. Immediately public for updated … |
misery | |
This could fail if there is no address or the admin marked his profile information as private. |
misery | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E303 too many blank lines (3) |
reviewbot | |
Col: 29 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 29 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 29 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 5 E301 expected 1 blank line, found 0 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 80 E501 line too long (81 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
These imports should follow the PEP-8 standard (3 sections, first standard library, then third party, then "local" imports). We also … |
david | |
We should avoid using str (which has different meanings in python 2 and 3) and instead use six.text_type |
david | |
Please add a blank line before this. |
david | |
You don't need the + here, since strings will auto concatenate. Can we also say "repository's" instead of "repo's"? |
david | |
Please add a blank line before this. |
david | |
This check should be not ticket_url |
david | |
We generally use older-style format strings (`'%d changesets recieved' % len(changesets). |
david | |
Please add blank lines around the conditional blocks here and below. |
david | |
For multi-line docstrings, the closing """ should go on the next line. |
david | |
You can skip the [] inside all and it will be a bit more efficient (using a generator expression instead … |
david | |
Please use % formatting. |
david | |
This looks like it's part of a different change. |
david | |
""" on the next line. |
david | |
The formatted-in string needs to be run through re.escape. Please also use %-formatting. |
david | |
Please rearrange according to PEP-8. |
david | |
Please put each key/value on its own line. |
david | |
This should use six.text_type rather than str. |
david | |
This should fit on one line. |
david | |
Can you just put the format inline in the function call? |
david | |
This could be a single statement: return max([ datetime_from_timestamp(diff.timestamp) for diff in revreq.get_diffs(only_fields='timestamp') ]) |
david | |
""" on the next line. |
david | |
""" on the next line. |
david | |
This should be "Review Board", not "ReviewBoard" |
david | |
Same here. |
david | |
And here. |
david | |
And here. |
david | |
This should all be a single format operation rather than a format and a bunch of concatenations. You can also … |
david | |
Please import unicode_literals at the top of this file. |
david | |
Docstrings for TestCase test methods shouldn't end in periods. |
david | |
Docstrings for TestCase test methods shouldn't end in periods. |
david | |
Docstrings for TestCase test methods shouldn't end in periods. |
david | |
'itertools' imported but unused |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 5 E301 expected 1 blank line, found 0 |
reviewbot | |
Col: 80 E501 line too long (81 > 79 characters) |
reviewbot | |
Col: 5 E301 expected 1 blank line, found 0 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E402 module level import not at top of file |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 0 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 27 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 1 E303 too many blank lines (3) |
reviewbot | |
Col: 29 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 29 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 29 E226 missing whitespace around arithmetic operator |
reviewbot | |
local variable 'repo_id2' is assigned to but never used |
reviewbot | |
Col: 5 E301 expected 1 blank line, found 0 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (81 > 79 characters) |
reviewbot | |
'hg' imported but unused |
reviewbot | |
'ui' imported but unused |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
'itertools' imported but unused |
reviewbot | |
Code looks for "ticket_id_prefixes" |
misery | |
repo_root cannot be found here on reviewboard because reviewboard will use a remote connection like http://mercurial/scm/hg/Test. "hg root" will return … |
misery | |
Documentation uses "ticket_prefixes" |
misery | |
The link works if we replace "re.escape(base_url)" with "base_url", otherwise the URL is broken and reviewboard shows a broken link. … |
misery | |
Missing ticket_prefixes here :-) find_ticket_refs(new_plain_description, ticket_prefixes) |
misery | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 5 E301 expected 1 blank line, found 0 |
reviewbot | |
Col: 80 E501 line too long (81 > 79 characters) |
reviewbot | |
Col: 5 E301 expected 1 blank line, found 0 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E402 module level import not at top of file |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 0 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 27 E127 continuation line over-indented for visual indent |
reviewbot | |
Col: 1 E303 too many blank lines (3) |
reviewbot | |
Col: 29 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 29 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 29 E226 missing whitespace around arithmetic operator |
reviewbot | |
Col: 5 E301 expected 1 blank line, found 0 |
reviewbot | |
Col: 1 E302 expected 2 blank lines, found 1 |
reviewbot | |
Col: 80 E501 line too long (80 > 79 characters) |
reviewbot | |
Col: 80 E501 line too long (81 > 79 characters) |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
Col: 19 W503 line break before binary operator |
reviewbot | |
reviewboardhook can be CONFIG_SECTION |
misery | |
reviewboardhook can be CONFIG_SECTION |
misery | |
This will fail if "line" is unicode. We fixed it with hasher.update(line.encode('utf-8')) UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in … |
misery | |
It would be nice if the "get description" could be a separate function. So we can use it to check … |
misery | |
If you push multiple changesets in different branches this won't work with our workflow. Could you change it to this? … |
misery | |
^1 will leads to a broken "base_commit_id" See: https://code.google.com/p/reviewboard/issues/detail?id=3915 I added this as a work-around to rbtools in "clients/mercurial.py" at … |
misery | |
Col: 17 W503 line break before binary operator |
reviewbot | |
see above |
misery | |
see above |
misery | |
base_commit_id needs to be passed here, too. Because otherwise reviewboard will use "tip" as base and this will fail if … |
misery | |
We changed it to this since a rebase could lead to a useless "whitespace changed"-update: if len(line) > 0 and … |
misery |
-
Tool: Pyflakes Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py rbtools/hooks/tests.py Ignored Files: contrib/tools/mercurial-push Tool: PEP8 Style Checker Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py rbtools/hooks/tests.py Ignored Files: contrib/tools/mercurial-push
-
-
-
-
-
-
-
Tool: Pyflakes Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py rbtools/hooks/tests.py Ignored Files: contrib/tools/mercurial-push Tool: PEP8 Style Checker Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py rbtools/hooks/tests.py Ignored Files: contrib/tools/mercurial-push
-
-
-
- Description:
-
A Mercurial hook to post to ReviewBoard on push to a central server.
The hook was designed to make posting to ReviewBoard easy for new or inexperienced users. It allows user to post to ReviewBoard by using the ordinary "hg push", without any need to learn or install RBTools locally.
The hook only allows the 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 ~ 2) makes sure any changes pushed to the central server have been reviewed and approved + 3) makes links of all references to tickets/bugs/issues, which I don't think rbt post does?
- Change Summary:
-
More options for logging into the ReviewBoard server such as API token or "submit-as".
- Commit:
-
6a2ed22daf7d1b3cf8f7ee541996770fffa5a286de5572195fb1e40a165d174022be1f26216fe218
-
Tool: Pyflakes Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py setup.py rbtools/hooks/tests.py Tool: PEP8 Style Checker Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py setup.py rbtools/hooks/tests.py
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tool: Pyflakes Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py Tool: PEP8 Style Checker Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tool: Pyflakes Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py Tool: PEP8 Style Checker Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py
-
-
- Description:
-
A Mercurial hook to post to ReviewBoard on push to a central server.
The hook was designed to make posting to ReviewBoard easy for new or inexperienced users. It allows user to post to ReviewBoard by using the ordinary "hg push", without any need to learn or install RBTools locally.
The hook only allows the 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) makes links of all references to tickets/bugs/issues, which I don't think rbt post does? ~ 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. makes links of all references to tickets/bugs/issues, which I don't think rbt post does? + 4. automatically finds the right review request to update if there are any new commits, based on commit IDs. This does not require the user to confirm anything, which rbt post (often) requires.
- Description:
-
A Mercurial hook to post to ReviewBoard on push to a central server.
The hook was designed to make posting to ReviewBoard easy for new or inexperienced users. It allows user to post to ReviewBoard by using the ordinary "hg push", without any need to learn or install RBTools locally.
The hook only allows the 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. makes links of all references to tickets/bugs/issues, which I don't think rbt post does? ~ 3. makes links of all 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 on commit IDs. This does not require the user to confirm anything, which rbt post (often) requires.
- Description:
-
A Mercurial hook to post to ReviewBoard on push to a central server.
The hook was designed to make posting to ReviewBoard easy for new or inexperienced users. It allows user to post to ReviewBoard by using the ordinary "hg push", without any need to learn or install RBTools locally.
The hook only allows the 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. makes links of all 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 on commit IDs. This does not require the user to confirm anything, which rbt post (often) requires. ~ 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. - Commit:
-
8f7a030d32b693e373e64b54a5e1e9427fcdce984bb44e1559bf1ed6f592b74569bfead445f50daa
-
Tool: Pyflakes Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py Tool: PEP8 Style Checker Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py
-
-
-
-
Tool: Pyflakes Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py Tool: PEP8 Style Checker Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py
-
Tool: Pyflakes Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py Tool: PEP8 Style Checker Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py
- Change Summary:
-
Add option to publish draft (or not), add branch information, remove admin_email function.
- Commit:
-
cfde8d86b193e28e9e5d434bc14937ed614dcce4ccd37945eb7663a779e28ff1ca5d6f2ed8a7669d
-
Tool: PEP8 Style Checker Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py Tool: Pyflakes Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py
-
Tool: PEP8 Style Checker Processed Files: contrib/tools/test_reviewboardhook.py rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tool: Pyflakes Processed Files: contrib/tools/mercurial_push.py rbtools/utils/review_request.py rbtools/hooks/mercurial.py rbtools/commands/post.py rbtools/clients/mercurial.py rbtools/hooks/common.py rbtools/hooks/tests.py Tool: PEP8 Style Checker Processed Files: contrib/tools/mercurial_push.py rbtools/utils/review_request.py rbtools/hooks/mercurial.py rbtools/commands/post.py rbtools/clients/mercurial.py rbtools/hooks/common.py rbtools/hooks/tests.py
-
You have a mix of single-quoted and double-quoted strings throughout this change. Please go through and make sure you're using single quotes for everything unless the string itself has a single quote in it (for example, if there's a possesive).
-
These imports should follow the PEP-8 standard (3 sections, first standard library, then third party, then "local" imports). We also alphebetize imports when possible. As a result:
import itertools import getpass import logging import rbtools.hooks.mercurial as hghook from rbtools.api.errors import APIError from rbtools.utils.filesystem import load_config
-
We should avoid using
str
(which has different meanings in python 2 and 3) and instead usesix.text_type
-
-
You don't need the + here, since strings will auto concatenate. Can we also say "repository's" instead of "repo's"?
-
-
-
-
-
-
You can skip the [] inside
all
and it will be a bit more efficient (using a generator expression instead of a list comprehension) -
-
-
-
-
-
-
-
-
-
This could be a single statement:
return max([ datetime_from_timestamp(diff.timestamp) for diff in revreq.get_diffs(only_fields='timestamp') ])
-
-
-
-
-
-
-
This should all be a single format operation rather than a format and a bunch of concatenations. You can also use python's built-in concatenation:
raise LoginError( 'Could not open Review Board repository for path "%s". ' 'Please check with your server administrator to ensure ' 'you have the correct permissions.' % path)
-
-
-
-
- Change Summary:
-
Some formatting changes. Also added
extra_data.diff_hash
in order to know whether the diff has changed. This allows the hook to identify changesets that have been rebased, but not changed. - Commit:
-
17f95a982a7ba2d22a45729b017c5fbc07c5fdbfed8130f502dfe3a806b373ead5ce08d4ee9640e0
-
Tool: Pyflakes Processed Files: contrib/tools/test_reviewboardhook.py rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py Tool: PEP8 Style Checker Processed Files: contrib/tools/test_reviewboardhook.py rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tool: PEP8 Style Checker Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py Tool: Pyflakes Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py
-
- Description:
-
~ A Mercurial hook to post to ReviewBoard on push to a central server.
~ A Mercurial hook to post to Review Board on push to a central server.
~ The hook was designed to make posting to ReviewBoard easy for new or inexperienced users. It allows user to post to ReviewBoard by using the ordinary "hg push", without any need to learn or install RBTools locally.
~ The hook was designed to make posting to Review Board easy for new or inexperienced users. It allows user to post to ReviewBoard by using the ordinary "hg push", without any need to learn or install RBTools locally.
The hook only allows the 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. makes links of all 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.
-
Tool: PEP8 Style Checker Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py Tool: Pyflakes Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py
-
Tool: Pyflakes Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py Tool: PEP8 Style Checker Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py
-
Tool: PEP8 Style Checker Processed Files: contrib/tools/test_reviewboardhook.py rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/hooks/tests.py
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tool: Pyflakes Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/utils/review_request.py rbtools/hooks/tests.py Tool: PEP8 Style Checker Processed Files: rbtools/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/utils/review_request.py rbtools/hooks/tests.py
-
If this is a separate method we can check this in our workflow
if revreq.branch == branch and 'diff_hash' in revreq.extra_data and diff_hash == revreq.extra_data['diff_hash'] and hghook.get_description([changeset], revreq, ticket_url, ticket_prefixes) == revreq.description:
instead of
if revreq.branch == branch and 'diff_hash' in revreq.extra_data and diff_hash == revreq.extra_data['diff_hash']:
-
It would be nice if the "get description" could be a separate function. So we can use it to check if something is changed before we update the review request.
def get_description(changesets, revreq, ticket_url, ticket_prefixes): old_description = revreq.description new_plain_description = generate_description(changesets) linked_description = linkify_ticket_refs(new_plain_description, ticket_url, ticket_prefixes) return join_descriptions(old_description, linked_description)
-
Tool: Pyflakes Processed Files: rbtools/hooks/common.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/hooks/common.py rbtools/hooks/mercurial.py contrib/tools/mercurial_push.py rbtools/clients/mercurial.py rbtools/hooks/tests.py
-
-
Ping! Could some reviewer look into it to have it finally merged? We use this since 3-4 month without any problems.
-
-
^1 will leads to a broken "base_commit_id"
See:
https://code.google.com/p/reviewboard/issues/detail?id=3915I added this as a work-around to rbtools in "clients/mercurial.py" at "def diff":
if "^" in base_commit_id: base_commit_id = self._execute( ['hg', 'log', '-r', base_commit_id, '-T {node}'], env=self._hg_env, results_unicode=False)
-
-
-
base_commit_id needs to be passed here, too. Because otherwise reviewboard will use "tip" as base and this will fail if the changeset is based on a special branch.
diffs.upload_diff(diff_info['diff'], base_commit_id=diff_info['base_commit_id'])
-
We changed it to this since a rebase could lead to a useless "whitespace changed"-update:
if len(line) > 0 and (line[0] == b'+' or line[0] == b'-'):
Also this will use the embedded "date" in the patch that will be changed after a rebase.
Our workaround in "clients/mercurial.py" at "def diff":
diff_cmd = ['hg', 'diff', '--hidden', '--nodates']