/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: Jelmer Vernooij
  • Date: 2020-03-22 20:02:36 UTC
  • mto: (7490.7.7 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200322200236-fsbl91ktcn6fcbdd
Fix tests.

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