Merge lp:~jelmer/brz/supports-rename-tracking into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/supports-rename-tracking
Merge into: lp:brz
Prerequisite: lp:~jelmer/brz/find-previous-paths
Diff against target: 122 lines (+48/-10)
5 files modified
breezy/tests/matchers.py (+11/-1)
breezy/tests/per_branch/test_commit.py (+15/-6)
breezy/tests/per_tree/test_tree.py (+9/-1)
breezy/tests/per_workingtree/test_check_state.py (+5/-2)
breezy/tree.py (+8/-0)
To merge this branch: bzr merge lp:~jelmer/brz/supports-rename-tracking
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+341565@code.launchpad.net

This proposal supersedes a proposal from 2018-03-14.

Commit message

Add a flag for Trees to indicate whether they support rename tracking.

Description of the change

Add a flag for Trees to indicate whether they support rename tracking.

For now, this just causes tests to stop expecting rename tracking. In the future, this can be used to determine whether rename guessing should be used (e.g. for git).

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

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/tests/matchers.py'
2--- breezy/tests/matchers.py 2018-03-23 23:31:30 +0000
3+++ breezy/tests/matchers.py 2018-03-23 23:31:30 +0000
4@@ -200,7 +200,13 @@
5 """Get the (path, previous_path) pairs for the current tree."""
6 with tree.lock_read(), self.previous_tree.lock_read():
7 for path, ie in tree.iter_entries_by_dir():
8- previous_path = find_previous_path(tree, self.previous_tree, path)
9+ if tree.supports_rename_tracking():
10+ previous_path = find_previous_path(tree, self.previous_tree, path)
11+ else:
12+ if self.previous_tree.is_versioned(path):
13+ previous_path = path
14+ else:
15+ previous_path = None
16 if previous_path:
17 kind = self.previous_tree.kind(previous_path)
18 if kind == 'directory':
19@@ -242,6 +248,10 @@
20 entries = list(self._strip_unreferenced_directories(self.previous_entries))
21 else:
22 entries = self.previous_entries
23+ if not tree.supports_rename_tracking():
24+ entries = [
25+ (path, path if self.previous_tree.is_versioned(path) else None)
26+ for (path, previous_path) in entries]
27 return Equals(entries).match(actual)
28
29
30
31=== modified file 'breezy/tests/per_branch/test_commit.py'
32--- breezy/tests/per_branch/test_commit.py 2018-01-12 08:52:43 +0000
33+++ breezy/tests/per_branch/test_commit.py 2018-03-23 23:31:30 +0000
34@@ -194,7 +194,8 @@
35 dir_id = tree.path2id('dir')
36 tree.add('dir/subfile')
37 dir_subfile_id = tree.path2id('dir/subfile')
38- tree.mkdir('to_be_unversioned')
39+ tree.put_file_bytes_non_atomic('to_be_unversioned', 'blah')
40+ tree.add(['to_be_unversioned'])
41 to_be_unversioned_id = tree.path2id('to_be_unversioned')
42 tree.put_file_bytes_non_atomic('dir/subfile', 'def')
43 revid1 = tree.commit('first revision')
44@@ -212,11 +213,19 @@
45 revid2 = tree.commit('second revision')
46
47 expected_delta = delta.TreeDelta()
48- expected_delta.added = [('added_dir', added_dir_id, 'directory')]
49- expected_delta.removed = [('to_be_unversioned',
50- to_be_unversioned_id, 'directory')]
51- expected_delta.renamed = [('dir/subfile', 'dir/subfile_renamed',
52- dir_subfile_id, 'file', False, False)]
53+ if tree.has_versioned_directories():
54+ expected_delta.added.append(('added_dir', added_dir_id, 'directory'))
55+ if tree.supports_rename_tracking():
56+ expected_delta.removed = [('to_be_unversioned',
57+ to_be_unversioned_id, 'file')]
58+ expected_delta.renamed = [('dir/subfile', 'dir/subfile_renamed',
59+ dir_subfile_id, 'file', False, False)]
60+ else:
61+ expected_delta.added.append(('dir/subfile_renamed',
62+ tree.path2id('dir/subfile_renamed'), 'file'))
63+ expected_delta.removed = [
64+ ('dir/subfile', dir_subfile_id, 'file'),
65+ ('to_be_unversioned', to_be_unversioned_id, 'file')]
66 expected_delta.modified=[('rootfile', rootfile_id, 'file', True,
67 False)]
68 self.assertEqual([('pre_commit', 1, revid1, 2, revid2,
69
70=== modified file 'breezy/tests/per_tree/test_tree.py'
71--- breezy/tests/per_tree/test_tree.py 2018-03-02 00:38:34 +0000
72+++ breezy/tests/per_tree/test_tree.py 2018-03-23 23:31:30 +0000
73@@ -359,4 +359,12 @@
74 def test_has_versioned_directories(self):
75 work_tree = self.make_branch_and_tree('tree')
76 tree = self._convert_tree(work_tree)
77- self.assertSubset([tree.has_versioned_directories()], (True, False))
78+ self.assertIn(tree.has_versioned_directories(), (True, False))
79+
80+
81+class TestSupportsRenameTracking(TestCaseWithTree):
82+
83+ def test_supports_rename_tracking(self):
84+ work_tree = self.make_branch_and_tree('tree')
85+ tree = self._convert_tree(work_tree)
86+ self.assertSubset([tree.supports_rename_tracking()], (True, False))
87
88=== modified file 'breezy/tests/per_workingtree/test_check_state.py'
89--- breezy/tests/per_workingtree/test_check_state.py 2017-05-21 18:10:28 +0000
90+++ breezy/tests/per_workingtree/test_check_state.py 2018-03-23 23:31:30 +0000
91@@ -81,8 +81,11 @@
92 tree = self.make_initial_tree()
93 foo_id = tree.path2id('foo')
94 tree.rename_one('foo', 'baz')
95- self.assertEqual(None, tree.path2id('foo'))
96- self.assertEqual(foo_id, tree.path2id('baz'))
97+ self.assertFalse(tree.is_versioned('foo'))
98+ if tree.supports_rename_tracking():
99+ self.assertEqual(foo_id, tree.path2id('baz'))
100+ else:
101+ self.assertTrue(tree.is_versioned('baz'))
102 tree.reset_state()
103 # After reset, we should have forgotten about the rename, but we won't
104 # have
105
106=== modified file 'breezy/tree.py'
107--- breezy/tree.py 2018-03-23 23:31:30 +0000
108+++ breezy/tree.py 2018-03-23 23:31:30 +0000
109@@ -108,6 +108,14 @@
110 trees or versioned trees.
111 """
112
113+ def supports_rename_tracking(self):
114+ """Whether this tree supports rename tracking.
115+
116+ This defaults to True, but some implementations may want to override
117+ it.
118+ """
119+ return True
120+
121 def has_versioned_directories(self):
122 """Whether this tree can contain explicitly versioned directories.
123

Subscribers

People subscribed via source and target branches