/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/merge.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 19:09:26 UTC
  • mfrom: (6622.1.36 breezy)
  • Revision ID: jelmer@jelmer.uk-20170521190926-5vtz8xaf0e9ylrpc
Merge rename to breezy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import warnings
20
20
 
21
 
from bzrlib.lazy_import import lazy_import
 
21
from breezy.lazy_import import lazy_import
22
22
lazy_import(globals(), """
23
 
from bzrlib import (
 
23
from breezy import (
24
24
    branch as _mod_branch,
25
25
    cleanup,
26
26
    conflicts as _mod_conflicts,
40
40
    versionedfile,
41
41
    workingtree,
42
42
    )
43
 
from bzrlib.i18n import gettext
 
43
from breezy.i18n import gettext
44
44
""")
45
 
from bzrlib import (
 
45
from breezy import (
46
46
    decorators,
47
47
    errors,
48
48
    hooks,
49
49
    registry,
50
50
    )
51
 
from bzrlib.symbol_versioning import (
 
51
from breezy.symbol_versioning import (
52
52
    deprecated_in,
53
53
    deprecated_method,
54
54
    )
66
66
class MergeHooks(hooks.Hooks):
67
67
 
68
68
    def __init__(self):
69
 
        hooks.Hooks.__init__(self, "bzrlib.merge", "Merger.hooks")
 
69
        hooks.Hooks.__init__(self, "breezy.merge", "Merger.hooks")
70
70
        self.add_hook('merge_file_content',
71
 
            "Called with a bzrlib.merge.Merger object to create a per file "
 
71
            "Called with a breezy.merge.Merger object to create a per file "
72
72
            "merge object when starting a merge. "
73
73
            "Should return either None or a subclass of "
74
 
            "``bzrlib.merge.AbstractPerFileMerger``. "
 
74
            "``breezy.merge.AbstractPerFileMerger``. "
75
75
            "Such objects will then be called per file "
76
76
            "that needs to be merged (including when one "
77
77
            "side has deleted the file and the other has changed it). "
90
90
 
91
91
 
92
92
class AbstractPerFileMerger(object):
93
 
    """PerFileMerger objects are used by plugins extending merge for bzrlib.
 
93
    """PerFileMerger objects are used by plugins extending merge for breezy.
94
94
 
95
 
    See ``bzrlib.plugins.news_merge.news_merge`` for an example concrete class.
 
95
    See ``breezy.plugins.news_merge.news_merge`` for an example concrete class.
96
96
    
97
97
    :ivar merger: The Merge3Merger performing the merge.
98
98
    """
104
104
    def merge_contents(self, merge_params):
105
105
        """Attempt to merge the contents of a single file.
106
106
        
107
 
        :param merge_params: A bzrlib.merge.MergeFileHookParams
 
107
        :param merge_params: A breezy.merge.MergeFileHookParams
108
108
        :return: A tuple of (status, chunks), where status is one of
109
109
            'not_applicable', 'success', 'conflicted', or 'delete'.  If status
110
110
            is 'success' or 'conflicted', then chunks should be an iterable of
172
172
    This is a base class for concrete custom file merging logic. Concrete
173
173
    classes should implement ``merge_text``.
174
174
 
175
 
    See ``bzrlib.plugins.news_merge.news_merge`` for an example concrete class.
 
175
    See ``breezy.plugins.news_merge.news_merge`` for an example concrete class.
176
176
    
177
177
    :ivar affected_files: The configured file paths to merge.
178
178
 
228
228
 
229
229
        This is called after checking that the merge should be performed in
230
230
        merge_contents, and it should behave as per
231
 
        ``bzrlib.merge.AbstractPerFileMerger.merge_contents``.
 
231
        ``breezy.merge.AbstractPerFileMerger.merge_contents``.
232
232
        """
233
233
        raise NotImplementedError(self.merge_text)
234
234
 
868
868
        finally:
869
869
            child_pb.finished()
870
870
        if self.change_reporter is not None:
871
 
            from bzrlib import delta
 
871
            from breezy import delta
872
872
            delta.report_changes(
873
873
                self.tt.iter_changes(), self.change_reporter)
874
874
        self.cook_conflicts(fs_conflicts)
1726
1726
        If conflicts are encountered, .BASE, .THIS. and .OTHER conflict files
1727
1727
        will be dumped, and a will be conflict noted.
1728
1728
        """
1729
 
        import bzrlib.patch
 
1729
        import breezy.patch
1730
1730
        temp_dir = osutils.mkdtemp(prefix="bzr-")
1731
1731
        try:
1732
1732
            new_file = osutils.pathjoin(temp_dir, "new")
1733
1733
            this = self.dump_file(temp_dir, "this", self.this_tree, file_id)
1734
1734
            base = self.dump_file(temp_dir, "base", self.base_tree, file_id)
1735
1735
            other = self.dump_file(temp_dir, "other", self.other_tree, file_id)
1736
 
            status = bzrlib.patch.diff3(new_file, this, base, other)
 
1736
            status = breezy.patch.diff3(new_file, this, base, other)
1737
1737
            if status not in (0, 1):
1738
1738
                raise errors.BzrError("Unhandled diff3 exit code")
1739
1739
            f = open(new_file, 'rb')
1931
1931
                    branch.get_revision_tree(base_revision))
1932
1932
    """
1933
1933
    if this_tree is None:
1934
 
        raise errors.BzrError("bzrlib.merge.merge_inner requires a this_tree "
 
1934
        raise errors.BzrError("breezy.merge.merge_inner requires a this_tree "
1935
1935
                              "parameter")
1936
1936
    merger = Merger(this_branch, other_tree, base_tree, this_tree=this_tree,
1937
1937
                    pb=pb, change_reporter=change_reporter)
1968
1968
 
1969
1969
 
1970
1970
def get_merge_type_registry():
1971
 
    """Merge type registry was previously in bzrlib.option
 
1971
    """Merge type registry was previously in breezy.option
1972
1972
 
1973
1973
    This method provides a backwards compatible way to retrieve it.
1974
1974
    """
2349
2349
        return all_texts
2350
2350
 
2351
2351
    def _build_weave(self):
2352
 
        from bzrlib import weave
 
2352
        from breezy import weave
2353
2353
        self._weave = weave.Weave(weave_name='in_memory_weave',
2354
2354
                                  allow_reserved=True)
2355
2355
        parent_map = self._find_recursive_lcas()