Merge files from index. Returns: A string with the content of the file containing possible conflicts if use_deprecated==True. If use_deprecated==False then it returns an instance of MergeFileResult. ancestor The index entry which will be used as a common
(
self,
ancestor: 'IndexEntry | None',
ours: 'IndexEntry | None',
theirs: 'IndexEntry | None',
use_deprecated: bool = True,
)
| 809 | return opts |
| 810 | |
| 811 | def merge_file_from_index( |
| 812 | self, |
| 813 | ancestor: 'IndexEntry | None', |
| 814 | ours: 'IndexEntry | None', |
| 815 | theirs: 'IndexEntry | None', |
| 816 | use_deprecated: bool = True, |
| 817 | ) -> 'str | MergeFileResult | None': |
| 818 | """Merge files from index. |
| 819 | |
| 820 | Returns: A string with the content of the file containing |
| 821 | possible conflicts if use_deprecated==True. |
| 822 | If use_deprecated==False then it returns an instance of MergeFileResult. |
| 823 | |
| 824 | ancestor |
| 825 | The index entry which will be used as a common |
| 826 | ancestor. |
| 827 | ours |
| 828 | The index entry to take as "ours" or base. |
| 829 | theirs |
| 830 | The index entry which will be merged into "ours" |
| 831 | use_deprecated |
| 832 | This controls what will be returned. If use_deprecated==True (default), |
| 833 | a string with the contents of the file will be returned. |
| 834 | An instance of MergeFileResult will be returned otherwise. |
| 835 | """ |
| 836 | cmergeresult = ffi.new('git_merge_file_result *') |
| 837 | |
| 838 | cancestor, ancestor_str_ref = ( |
| 839 | ancestor._to_c() if ancestor is not None else (ffi.NULL, ffi.NULL) |
| 840 | ) |
| 841 | cours, ours_str_ref = ours._to_c() if ours is not None else (ffi.NULL, ffi.NULL) |
| 842 | ctheirs, theirs_str_ref = ( |
| 843 | theirs._to_c() if theirs is not None else (ffi.NULL, ffi.NULL) |
| 844 | ) |
| 845 | |
| 846 | err = C.git_merge_file_from_index( |
| 847 | cmergeresult, self._repo, cancestor, cours, ctheirs, ffi.NULL |
| 848 | ) |
| 849 | check_error(err) |
| 850 | |
| 851 | mergeFileResult = MergeFileResult._from_c(cmergeresult) |
| 852 | C.git_merge_file_result_free(cmergeresult) |
| 853 | |
| 854 | if use_deprecated: |
| 855 | warnings.warn( |
| 856 | 'Getting an str from Repository.merge_file_from_index is deprecated. ' |
| 857 | 'The method will later return an instance of MergeFileResult by default, instead. ' |
| 858 | 'Check parameter use_deprecated.', |
| 859 | DeprecationWarning, |
| 860 | ) |
| 861 | return mergeFileResult.contents if mergeFileResult else '' |
| 862 | |
| 863 | return mergeFileResult |
| 864 | |
| 865 | def merge_commits( |
| 866 | self, |