/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/tests/test_merge.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-07-28 02:47:10 UTC
  • mfrom: (7519.1.1 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200728024710-a2ylds219f1lsl62
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/388173

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
import contextlib
17
18
import os
18
19
 
19
20
from .. import (
20
21
    branch as _mod_branch,
21
 
    cleanup,
22
22
    conflicts,
23
23
    errors,
24
24
    memorytree,
37
37
from ..errors import UnrelatedBranches, NoCommits
38
38
from ..merge import transform_tree, merge_inner, _PlanMerge
39
39
from ..osutils import basename, pathjoin, file_kind
40
 
from ..sixish import int2byte
41
40
from . import (
42
41
    features,
43
42
    TestCaseWithMemoryTransport,
146
145
        merger = _mod_merge.Merge3Merger(wt, wt, wt.basis_tree(), other_tree,
147
146
                                         this_branch=wt.branch,
148
147
                                         do_merge=False)
149
 
        with transform.TransformPreview(wt) as merger.tt:
 
148
        with wt.preview_transform() as merger.tt:
150
149
            merger._compute_transform()
151
150
            new_root_id = merger.tt.final_file_id(merger.tt.root)
152
151
            self.assertEqual(wt.path2id(''), new_root_id)
565
564
        self.plan_merge_vf.fallback_versionedfiles.append(self.vf)
566
565
 
567
566
    def add_version(self, key, parents, text):
568
 
        self.vf.add_lines(key, parents, [int2byte(
569
 
            c) + b'\n' for c in bytearray(text)])
 
567
        self.vf.add_lines(
 
568
            key, parents, [bytes([c]) + b'\n' for c in bytearray(text)])
570
569
 
571
570
    def add_rev(self, prefix, revision_id, parents, text):
572
571
        self.add_version((prefix, revision_id), [(prefix, p) for p in parents],
574
573
 
575
574
    def add_uncommitted_version(self, key, parents, text):
576
575
        self.plan_merge_vf.add_lines(key, parents,
577
 
                                     [int2byte(c) + b'\n' for c in bytearray(text)])
 
576
                                     [bytes([c]) + b'\n' for c in bytearray(text)])
578
577
 
579
578
    def setup_plan_merge(self):
580
579
        self.add_rev(b'root', b'A', [], b'abc')
2260
2259
        builder.build_snapshot([b'C-id', b'B-id'], [], revision_id=b'E-id')
2261
2260
        # Have to use a real WT, because BranchBuilder doesn't support exec bit
2262
2261
        wt = self.get_wt_from_builder(builder)
2263
 
        with wt.get_transform() as tt:
 
2262
        with wt.transform() as tt:
2264
2263
            tt.set_executability(True, tt.trans_id_tree_path('foo'))
2265
2264
            tt.apply()
2266
2265
        self.assertTrue(wt.is_executable('foo'))
3179
3178
        :param merge_as: the path in a tree to add the new directory as.
3180
3179
        :returns: the conflicts from 'do_merge'.
3181
3180
        """
3182
 
        with cleanup.ExitStack() as stack:
 
3181
        with contextlib.ExitStack() as stack:
3183
3182
            # Open and lock the various tree and branch objects
3184
3183
            wt, subdir_relpath = WorkingTree.open_containing(merge_as)
3185
3184
            stack.enter_context(wt.lock_write())