Merge lp:~jelmer/bzr/merge-distinguish-working-tree into lp:bzr

Proposed by Jelmer Vernooij
Status: Superseded
Proposed branch: lp:~jelmer/bzr/merge-distinguish-working-tree
Merge into: lp:bzr
Diff against target: 130 lines (+25/-11)
3 files modified
bzrlib/merge.py (+16/-9)
bzrlib/tests/test_merge.py (+5/-2)
doc/en/release-notes/bzr-2.5.txt (+4/-0)
To merge this branch: bzr merge lp:~jelmer/bzr/merge-distinguish-working-tree
Reviewer Review Type Date Requested Status
Martin Packman (community) Needs Information
Review via email: mp+87301@code.launchpad.net

This proposal has been superseded by a proposal from 2012-01-03.

Description of the change

Properly distinguish the working tree (the tree to which we're going to be applying the found changes) from the this_tree in the merge.

This is required for some of the bzr-builddeb hooks I'm working on.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Proposal should have <lp:~jelmer/bzr/propagate-other-branch> as a prerequisite?

Without seeing how this will be hooked up outside merge I'm not clear on how the parts will interact.

+ self.working_tree.lock_tree_write()
+ operation.add_cleanup(self.working_tree.unlock)
+ self.this_tree.lock_read()
- self.this_tree.lock_tree_write()
         operation.add_cleanup(self.this_tree.unlock)

Can working_tree and this_tree be the same location? If so this won't work.

review: Needs Information

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/merge.py'
2--- bzrlib/merge.py 2011-12-20 13:13:25 +0000
3+++ bzrlib/merge.py 2012-01-02 22:55:26 +0000
4@@ -617,6 +617,7 @@
5 'interesting_ids': self.interesting_ids,
6 'interesting_files': self.interesting_files,
7 'this_branch': self.this_branch,
8+ 'other_branch': self.other_branch,
9 'do_merge': False}
10 if self.merge_type.requires_base:
11 kwargs['base_tree'] = self.base_tree
12@@ -725,7 +726,8 @@
13 interesting_ids=None, reprocess=False, show_base=False,
14 pb=None, pp=None, change_reporter=None,
15 interesting_files=None, do_merge=True,
16- cherrypick=False, lca_trees=None, this_branch=None):
17+ cherrypick=False, lca_trees=None, this_branch=None,
18+ other_branch=None):
19 """Initialize the merger object and perform the merge.
20
21 :param working_tree: The working tree to apply the merge to
22@@ -734,6 +736,7 @@
23 :param other_tree: The other tree to merge changes from
24 :param this_branch: The branch associated with this_tree. Defaults to
25 this_tree.branch if not supplied.
26+ :param other_branch: The branch associated with other_tree, if any.
27 :param interesting_ids: The file_ids of files that should be
28 participate in the merge. May not be combined with
29 interesting_files.
30@@ -761,10 +764,12 @@
31 this_branch = this_tree.branch
32 self.interesting_ids = interesting_ids
33 self.interesting_files = interesting_files
34- self.this_tree = working_tree
35+ self.working_tree = working_tree
36+ self.this_tree = this_tree
37 self.base_tree = base_tree
38 self.other_tree = other_tree
39 self.this_branch = this_branch
40+ self.other_branch = other_branch
41 self._raw_conflicts = []
42 self.cooked_conflicts = []
43 self.reprocess = reprocess
44@@ -786,7 +791,9 @@
45
46 def do_merge(self):
47 operation = cleanup.OperationWithCleanups(self._do_merge)
48- self.this_tree.lock_tree_write()
49+ self.working_tree.lock_tree_write()
50+ operation.add_cleanup(self.working_tree.unlock)
51+ self.this_tree.lock_read()
52 operation.add_cleanup(self.this_tree.unlock)
53 self.base_tree.lock_read()
54 operation.add_cleanup(self.base_tree.unlock)
55@@ -795,13 +802,13 @@
56 operation.run()
57
58 def _do_merge(self, operation):
59- self.tt = transform.TreeTransform(self.this_tree, None)
60+ self.tt = transform.TreeTransform(self.working_tree, None)
61 operation.add_cleanup(self.tt.finalize)
62 self._compute_transform()
63 results = self.tt.apply(no_conflicts=True)
64 self.write_modified(results)
65 try:
66- self.this_tree.add_conflicts(self.cooked_conflicts)
67+ self.working_tree.add_conflicts(self.cooked_conflicts)
68 except errors.UnsupportedOperation:
69 pass
70
71@@ -814,7 +821,7 @@
72 return operation.run_simple()
73
74 def _make_preview_transform(self):
75- self.tt = transform.TransformPreview(self.this_tree)
76+ self.tt = transform.TransformPreview(self.working_tree)
77 self._compute_transform()
78 return self.tt
79
80@@ -1119,14 +1126,14 @@
81 def write_modified(self, results):
82 modified_hashes = {}
83 for path in results.modified_paths:
84- file_id = self.this_tree.path2id(self.this_tree.relpath(path))
85+ file_id = self.working_tree.path2id(self.working_tree.relpath(path))
86 if file_id is None:
87 continue
88- hash = self.this_tree.get_file_sha1(file_id)
89+ hash = self.working_tree.get_file_sha1(file_id)
90 if hash is None:
91 continue
92 modified_hashes[file_id] = hash
93- self.this_tree.set_merge_modified(modified_hashes)
94+ self.working_tree.set_merge_modified(modified_hashes)
95
96 @staticmethod
97 def parent(entry, file_id):
98
99=== modified file 'bzrlib/tests/test_merge.py'
100--- bzrlib/tests/test_merge.py 2011-12-21 12:34:21 +0000
101+++ bzrlib/tests/test_merge.py 2012-01-02 22:55:26 +0000
102@@ -446,8 +446,11 @@
103 merger.merge_type = _mod_merge.Merge3Merger
104 tree_merger = merger.make_merger()
105 self.assertIs(_mod_merge.Merge3Merger, tree_merger.__class__)
106- self.assertEqual('rev2b', tree_merger.other_tree.get_revision_id())
107- self.assertEqual('rev1', tree_merger.base_tree.get_revision_id())
108+ self.assertEqual('rev2b',
109+ tree_merger.other_tree.get_revision_id())
110+ self.assertEqual('rev1',
111+ tree_merger.base_tree.get_revision_id())
112+ self.assertEqual(other_tree.branch, tree_merger.other_branch)
113
114 def test_make_preview_transform(self):
115 this_tree = self.make_branch_and_tree('this')
116
117=== modified file 'doc/en/release-notes/bzr-2.5.txt'
118--- doc/en/release-notes/bzr-2.5.txt 2011-12-22 18:52:58 +0000
119+++ doc/en/release-notes/bzr-2.5.txt 2012-01-02 22:55:26 +0000
120@@ -144,6 +144,10 @@
121
122 * Lazy imports can now only be absolute. (Jelmer Vernooij)
123
124+* Merge3Mergers now have an optional ``other_branch`` argument
125+ which contains the branch from which the ``other_tree``
126+ was obtained, if any. (Jelmer Vernooij)
127+
128 * New HPSS call ``BzrDir.checkout_metadir``. (Jelmer Vernooij, #894459)
129
130 * New HPSS call ``VersionedFileRepository.get_inventories``,