Merge lp:~torkvemada/bzr/commit_hooks into lp:bzr
| Status: | Needs review |
|---|---|
| Proposed branch: | lp:~torkvemada/bzr/commit_hooks |
| Merge into: | lp:bzr |
| Diff against target: |
244 lines (+153/-20) 3 files modified
bzrlib/commit.py (+94/-0) bzrlib/tests/per_workingtree/test_commit.py (+23/-20) bzrlib/tests/test_commit.py (+36/-0) |
| To merge this branch: | bzr merge lp:~torkvemada/bzr/commit_hooks |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Martin Packman (community) | 2012-07-17 | Abstain on 2012-10-10 | |
|
Review via email:
|
|||
Description of the Change
New class of hooks: commit ones; and the corresponding Commit.start_commit hook to enable commit metadata modification.
Rationale: there's a set of the metadata properties that are stored along with the commit itself, but at the moment there is no way to fetch or set any of them.
I suppose that since the interaction with all the metadata strictly belongs to commit itself, it's reasonable to create the hook, allowing plugin to modify the metadata for the Commit class.
As a proof of concept I have implemented the 'cimage' plugin[1], which utilizes the start_hook invented in this diff to add the user webcam photo to commit metadata. Later the photo can be fetched from metadata by appropriate command. Practically, all the cimage branch commits are equipped with the stored photos so one can easily install plugin, checkout that branch and view them.
[1] http://
- 6540. By Vsevolod Velichko on 2012-10-02
-
Test for commit.start_commit hook.
- 6541. By Vsevolod Velichko on 2012-10-02
-
Merge with trunk
- 6542. By Vsevolod Velichko on 2012-10-02
-
Remove unnecessary import in hook test
| Jelmer Vernooij (jelmer) wrote : | # |
This doesn't look unreasonable.
I'm wary about passing an instance of the Commit object to a hook; Commit at the moment is fairly private, exposing it this way makes it harder to change things there in the future.
| Vsevolod Velichko (torkvemada) wrote : | # |
Jelmer, thanks for your look.
I thought about the idea passing the properties dict itself to the hook, but finally I supposed that one may wish to access commit timestamp or something like that.
Obviously, if you are sure, that one should never wish things like that, I can modify the hook and pass the properties dict :)
Or may be there should be some special struct having only "safe" fields?
| Martin Packman (gz) wrote : | # |
In the past, hooks have been given custom objects with just a selection of fields, see for instance bzrlib.
I'd be careful about what the hook is allowed to modify, particularly a test that sets an invalid revision property (see bzrlib.
- 6543. By Vsevolod Velichko on 2012-10-12
-
Do not pass all the commit data to the hook, but only some restricted set of properties.
- 6544. By Vsevolod Velichko on 2012-10-12
-
Some test cases on which Commit.start_commit hook should fail.
| Vsevolod Velichko (torkvemada) wrote : | # |
Martin, the idea of class with custom fields is cool (before your comment I was unsure about it, since I hadn't seen other hooks with such idea in bzr).
I've updated the hook, so it passes only limited set of params (I've eliminated even the message, I suppose that set_commit_message hook should be enough) and added some tests for invalid data.
Unmerged revisions
- 6544. By Vsevolod Velichko on 2012-10-12
-
Some test cases on which Commit.start_commit hook should fail.
- 6543. By Vsevolod Velichko on 2012-10-12
-
Do not pass all the commit data to the hook, but only some restricted set of properties.
- 6542. By Vsevolod Velichko on 2012-10-02
-
Remove unnecessary import in hook test
- 6541. By Vsevolod Velichko on 2012-10-02
-
Merge with trunk
- 6540. By Vsevolod Velichko on 2012-10-02
-
Test for commit.start_commit hook.
- 6539. By Vsevolod Velichko on 2012-07-17
-
Add commit.Commit hooks class and start_commit hook

Thanks for making these changes and explaining the merge proposal a little more. I've asked Jelmer to have a look.