Merge lp:~jelmer/brz/fastexport-empty-parents into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 7197
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/fastexport-empty-parents
Merge into: lp:brz
Diff against target: 95 lines (+13/-22)
3 files modified
breezy/git/tests/test_git_remote_helper.py (+1/-0)
breezy/plugins/fastimport/exporter.py (+6/-16)
breezy/plugins/fastimport/tests/test_commands.py (+6/-6)
To merge this branch: bzr merge lp:~jelmer/brz/fastexport-empty-parents
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+358959@code.launchpad.net

Commit message

Don't create temporary branches in fastexport.

Description of the change

Don't create temporary branches in fastexport; instead, properly reset when starting a new branch.

(https://code.launchpad.net/~a-s-usov/bzr-fastimport/no-temp-branches/+merge/123127 updated for Breezy)

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

Thanks!

review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
7197. By Jelmer Vernooij

Fix test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/tests/test_git_remote_helper.py'
2--- breezy/git/tests/test_git_remote_helper.py 2018-11-11 04:08:32 +0000
3+++ breezy/git/tests/test_git_remote_helper.py 2018-11-21 03:39:52 +0000
4@@ -130,6 +130,7 @@
5 f = BytesIO()
6 self.helper.cmd_import(f, ["import", "refs/heads/master"])
7 self.assertEqual(
8+ b'reset refs/heads/master\n'
9 b'commit refs/heads/master\n'
10 b'mark :1\n'
11 b'committer Somebody <jrandom@example.com> 1330445983 +0000\n'
12
13=== modified file 'breezy/plugins/fastimport/exporter.py'
14--- breezy/plugins/fastimport/exporter.py 2018-11-16 18:40:46 +0000
15+++ breezy/plugins/fastimport/exporter.py 2018-11-21 03:39:52 +0000
16@@ -333,6 +333,7 @@
17 self.revid_to_mark[revid] = mark
18 file_cmds = self._get_filecommands(
19 breezy.revision.NULL_REVISION, revid)
20+ self.print_cmd(commands.ResetCommand(ref, None))
21 self.print_cmd(self._get_commit_command(ref, mark, revobj, file_cmds))
22
23 def emit_commit(self, revid, ref):
24@@ -355,16 +356,15 @@
25 ncommits = len(self.revid_to_mark)
26 nparents = len(revobj.parent_ids)
27 if nparents == 0:
28- if ncommits:
29- # This is a parentless commit but it's not the first one
30- # output. We need to create a new temporary branch for it
31- # otherwise git-fast-import will assume the previous commit
32- # was this one's parent
33- ref = self._next_tmp_ref()
34 parent = breezy.revision.NULL_REVISION
35 else:
36 parent = revobj.parent_ids[0]
37
38+ # For parentless commits we need to issue reset command first, otherwise
39+ # git-fast-import will assume previous commit was this one's parent
40+ if nparents == 0:
41+ self.print_cmd(commands.ResetCommand(ref, None))
42+
43 # Print the commit
44 mark = ncommits + 1
45 self.revid_to_mark[revid] = mark
46@@ -640,13 +640,3 @@
47 'valid in git.', git_ref)
48 continue
49 self.print_cmd(commands.ResetCommand(git_ref, b":%d" % mark))
50-
51- def _next_tmp_ref(self):
52- """Return a unique branch name. The name will start with "tmp"."""
53- prefix = 'tmp'
54- if prefix not in self.branch_names:
55- self.branch_names[prefix] = 0
56- else:
57- self.branch_names[prefix] += 1
58- prefix = '%s.%d' % (prefix, self.branch_names[prefix])
59- return 'refs/heads/%s' % prefix
60
61=== modified file 'breezy/plugins/fastimport/tests/test_commands.py'
62--- breezy/plugins/fastimport/tests/test_commands.py 2018-11-11 04:08:32 +0000
63+++ breezy/plugins/fastimport/tests/test_commands.py 2018-11-21 03:39:52 +0000
64@@ -59,7 +59,8 @@
65 self.assertIsNot(b"bla", stream.read())
66
67
68-fast_export_baseline_data = """commit refs/heads/master
69+fast_export_baseline_data = """reset refs/heads/master
70+commit refs/heads/master
71 mark :1
72 committer
73 data 15
74@@ -107,17 +108,16 @@
75 tree.commit("pointless")
76 data = self.run_bzr("fast-export br")[0]
77 self.assertTrue(data.startswith(
78- 'commit refs/heads/master\nmark :1\ncommitter'))
79+ 'reset refs/heads/master\n'
80+ 'commit refs/heads/master\n'
81+ 'mark :1\ncommitter'), data)
82
83 def test_file(self):
84 tree = self.make_branch_and_tree("br")
85 tree.commit("pointless")
86 data = self.run_bzr("fast-export br br.fi")[0]
87 self.assertEquals("", data)
88- try:
89- self.assertPathExists("br.fi")
90- except AttributeError: # bzr < 2.4
91- self.failUnlessExists("br.fi")
92+ self.assertPathExists("br.fi")
93
94 def test_tag_rewriting(self):
95 tree = self.make_branch_and_tree("br")

Subscribers

People subscribed via source and target branches