~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

(jelmer) Use the absolute_import feature everywhere in bzrlib,
 and add a source test to make sure it's used everywhere. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
import warnings
18
20
 
19
21
from bzrlib.lazy_import import lazy_import
44
46
    decorators,
45
47
    errors,
46
48
    hooks,
 
49
    registry,
47
50
    )
48
51
from bzrlib.symbol_versioning import (
49
52
    deprecated_in,
139
142
            params.winner == 'other' or
140
143
            # THIS and OTHER aren't both files.
141
144
            not params.is_file_merge() or
142
 
            # The filename doesn't match *.xml
 
145
            # The filename doesn't match
143
146
            not self.file_matches(params)):
144
147
            return 'not_applicable', None
145
148
        return self.merge_matching(params)
854
857
        else:
855
858
            entries = self._entries_lca()
856
859
            resolver = self._lca_multi_way
 
860
        # Prepare merge hooks
 
861
        factories = Merger.hooks['merge_file_content']
 
862
        # One hook for each registered one plus our default merger
 
863
        hooks = [factory(self) for factory in factories] + [self]
 
864
        self.active_hooks = [hook for hook in hooks if hook is not None]
857
865
        child_pb = ui.ui_factory.nested_progress_bar()
858
866
        try:
859
 
            factories = Merger.hooks['merge_file_content']
860
 
            hooks = [factory(self) for factory in factories] + [self]
861
 
            self.active_hooks = [hook for hook in hooks if hook is not None]
862
867
            for num, (file_id, changed, parents3, names3,
863
868
                      executable3) in enumerate(entries):
864
 
                child_pb.update(gettext('Preparing file merge'), num, len(entries))
 
869
                # Try merging each entry
 
870
                child_pb.update(gettext('Preparing file merge'),
 
871
                                num, len(entries))
865
872
                self._merge_names(file_id, parents3, names3, resolver=resolver)
866
873
                if changed:
867
874
                    file_status = self._do_merge_contents(file_id)
2038
2045
    merger.set_base_revision(get_revision_id(), this_branch)
2039
2046
    return merger.do_merge()
2040
2047
 
 
2048
 
 
2049
merge_type_registry = registry.Registry()
 
2050
merge_type_registry.register('diff3', Diff3Merger,
 
2051
                             "Merge using external diff3.")
 
2052
merge_type_registry.register('lca', LCAMerger,
 
2053
                             "LCA-newness merge.")
 
2054
merge_type_registry.register('merge3', Merge3Merger,
 
2055
                             "Native diff3-style merge.")
 
2056
merge_type_registry.register('weave', WeaveMerger,
 
2057
                             "Weave-based merge.")
 
2058
 
 
2059
 
2041
2060
def get_merge_type_registry():
2042
 
    """Merge type registry is in bzrlib.option to avoid circular imports.
 
2061
    """Merge type registry was previously in bzrlib.option
2043
2062
 
2044
 
    This method provides a sanctioned way to retrieve it.
 
2063
    This method provides a backwards compatible way to retrieve it.
2045
2064
    """
2046
 
    from bzrlib import option
2047
 
    return option._merge_type_registry
 
2065
    return merge_type_registry
2048
2066
 
2049
2067
 
2050
2068
def _plan_annotate_merge(annotated_a, annotated_b, ancestors_a, ancestors_b):