Implementing merge with default options#295
Conversation
|
Hello Victor, thanks for contributing. We have the general policy to wrap git structs, so it should be like: Note that And please update the documentation |
|
Thanks @jdavid for your comments. About the MergeResult struct, you are right, i'll implement it in that way. |
…edef, pep7 fixes and some error checks
…imple type that maps git_merge_result to it
|
Fixes done, please take a look and tell me if you like them. |
|
Why do you need How that is better than: If |
|
Actually i don't need it but since the git_merge_result struct has an index field, i supposed you also wanted it here. I'll remove it so it's simpler |
|
Okey, I missed that. Anyway if you don't need it just remove. |
|
Index removed! |
|
@victorgp does merge_result has any attributes to indicate this merge is viable? like will it produce conflicts? there is 'is_fastforward', 'is_up_to_date', but no other identification for whether the merge is viable, (is it can be merged but not fastforward merge?) |
|
sorry I found that merge_result has an index object, that explains |
This pull request implements the merge operation based on the default options libgit2 defines.
The merge receives an Oid and returns a MergeResult object.
This MergeResult object is quite similar than the git_merge_result libgit2 implements. it has:
->is_fastforward: boolean field that indicates the merge was fastforward
->is_uptodate: boolean field that indicates the merge was already up to date
->fastforward_oid: python Oid object with the new fastforward Oid to be the new head (only if the merge was fastforward, None otherwise)
->status: dict with the repository status after the merge (if the merge was not fastforward, either there were conflicts or not, an empty dict otherwise)
Some notes:
-The merge, as it name says, only does the merge, it does not perform any commit nor updates the references (ex. in the fastforward case)
-This method does not allow customized parameters for the merge operation, i would like to leave that for a second iteration over this method and let's it work for the moment with the default options defined in the libgit2 constant GIT_MERGE_OPTS_INIT.
The tests i implemented would help to understand this behaviour easily.
Extra: there is also a minor change in the Repository_status method, i removed the args parameter because it wasn't being used anywhere within the method.