Merge lp:~jelmer/brz/fix-spurious-343 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/fix-spurious-343
Merge into: lp:brz
Diff against target: 155 lines (+64/-27)
2 files modified
breezy/plugins/fastimport/exporter.py (+14/-13)
breezy/plugins/fastimport/tests/test_commands.py (+50/-14)
To merge this branch: bzr merge lp:~jelmer/brz/fix-spurious-343
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+360971@code.launchpad.net

Commit message

Fix an occasionally failing test.

Description of the change

Fix an occasionally failing test.

Order of output from iter_files_bytes is not guaranteed.

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

Changes here all look reasonable, though having a 1 and 2 expected output seems a little ugly.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/plugins/fastimport/exporter.py'
2--- breezy/plugins/fastimport/exporter.py 2018-11-26 21:11:19 +0000
3+++ breezy/plugins/fastimport/exporter.py 2018-12-18 23:13:08 +0000
4@@ -452,7 +452,7 @@
5 # Build and return the result
6 return commands.CommitCommand(git_ref, mark, author_info,
7 committer_info, revobj.message.encode(
8- "utf-8"), from_, merges, iter(file_cmds),
9+ "utf-8"), from_, merges, file_cmds,
10 more_authors=more_author_info, properties=properties)
11
12 def _get_revision_trees(self, parent, revision_id):
13@@ -477,7 +477,7 @@
14 tree_old, tree_new = self._get_revision_trees(parent, revision_id)
15 if not(tree_old and tree_new):
16 # Something is wrong with this revision - ignore the filecommands
17- return []
18+ return
19
20 changes = tree_new.changes_from(tree_old)
21
22@@ -489,13 +489,16 @@
23 file_cmds, rd_modifies, renamed = self._process_renames_and_deletes(
24 changes.renamed, changes.removed, revision_id, tree_old)
25
26+ for cmd in file_cmds:
27+ yield cmd
28+
29 # Map kind changes to a delete followed by an add
30 for path, id_, kind1, kind2 in changes.kind_changed:
31 path = self._adjust_path_for_renames(path, renamed, revision_id)
32 # IGC: I don't understand why a delete is needed here.
33 # In fact, it seems harmful? If you uncomment this line,
34 # please file a bug explaining why you needed to.
35- # file_cmds.append(commands.FileDeleteCommand(path))
36+ # yield commands.FileDeleteCommand(path)
37 my_modified.append((path, id_, kind2))
38
39 # Record modifications
40@@ -507,25 +510,23 @@
41 (path, helpers.kind_to_mode(
42 'file', tree_new.is_executable(path)))))
43 elif kind == 'symlink':
44- file_cmds.append(commands.FileModifyCommand(
45+ yield commands.FileModifyCommand(
46 path.encode("utf-8"),
47 helpers.kind_to_mode('symlink', False),
48- None, tree_new.get_symlink_target(path)))
49+ None, tree_new.get_symlink_target(path))
50 elif kind == 'directory':
51 if not self.plain_format:
52- file_cmds.append(
53- commands.FileModifyCommand(
54- path.encode("utf-8"),
55- helpers.kind_to_mode('directory', False), None,
56- None))
57+ yield commands.FileModifyCommand(
58+ path.encode("utf-8"),
59+ helpers.kind_to_mode('directory', False), None,
60+ None)
61 else:
62 self.warning("cannot export '%s' of kind %s yet - ignoring" %
63 (path, kind))
64 for (path, mode), chunks in tree_new.iter_files_bytes(
65 files_to_get):
66- file_cmds.append(commands.FileModifyCommand(
67- path.encode("utf-8"), mode, None, b''.join(chunks)))
68- return file_cmds
69+ yield commands.FileModifyCommand(
70+ path.encode("utf-8"), mode, None, b''.join(chunks))
71
72 def _process_renames_and_deletes(self, renames, deletes,
73 revision_id, tree_old):
74
75=== modified file 'breezy/plugins/fastimport/tests/test_commands.py'
76--- breezy/plugins/fastimport/tests/test_commands.py 2018-11-21 02:13:23 +0000
77+++ breezy/plugins/fastimport/tests/test_commands.py 2018-12-18 23:13:08 +0000
78@@ -59,19 +59,55 @@
79 self.assertIsNot(b"bla", stream.read())
80
81
82-fast_export_baseline_data = """reset refs/heads/master
83-commit refs/heads/master
84-mark :1
85-committer
86-data 15
87-add c, remove b
88-M 644 inline a
89-data 13
90-test 1
91-test 3
92-M 644 inline c
93-data 6
94-test 4
95+fast_export_baseline_data1 = """reset refs/heads/master
96+commit refs/heads/master
97+mark :1
98+committer
99+data 15
100+add c, remove b
101+M 644 inline a
102+data 13
103+test 1
104+test 3
105+M 644 inline c
106+data 6
107+test 4
108+commit refs/heads/master
109+mark :2
110+committer
111+data 14
112+modify a again
113+from :1
114+M 644 inline a
115+data 20
116+test 1
117+test 3
118+test 5
119+commit refs/heads/master
120+mark :3
121+committer
122+data 5
123+add d
124+from :2
125+M 644 inline d
126+data 6
127+test 6
128+"""
129+
130+
131+fast_export_baseline_data2 = """reset refs/heads/master
132+commit refs/heads/master
133+mark :1
134+committer
135+data 15
136+add c, remove b
137+M 644 inline c
138+data 6
139+test 4
140+M 644 inline a
141+data 13
142+test 1
143+test 3
144 commit refs/heads/master
145 mark :2
146 committer
147@@ -188,7 +224,7 @@
148 # followed by the deltas for 4 and 5
149 data = self.run_bzr("fast-export --baseline -r 3.. bl")[0]
150 data = re.sub('committer.*', 'committer', data)
151- self.assertEquals(fast_export_baseline_data, data)
152+ self.assertIn(data, (fast_export_baseline_data1, fast_export_baseline_data2))
153
154 # Also confirm that --baseline with no args is identical to full export
155 data1 = self.run_bzr("fast-export --baseline bl")[0]

Subscribers

People subscribed via source and target branches