Merge lp:~schwab-linux-m68k/bzr-fastimport/parentless into lp:bzr-fastimport

Proposed by Andreas Schwab
Status: Needs review
Proposed branch: lp:~schwab-linux-m68k/bzr-fastimport/parentless
Merge into: lp:bzr-fastimport
Diff against target: 46 lines (+1/-19)
1 file modified
exporter.py (+1/-19)
To merge this branch: bzr merge lp:~schwab-linux-m68k/bzr-fastimport/parentless
Reviewer Review Type Date Requested Status
Bazaar Developers Pending
Review via email: mp+105048@code.launchpad.net

Description of the change

The proper way to create a parentless commit is to emit a reset command for the branch
without a following from command. That obviates the need to invent a possibly conflicting
branch name.

To post a comment you must log in.

Unmerged revisions

357. By Andreas Schwab

Properly create parentless commit

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'exporter.py'
2--- exporter.py 2012-02-28 16:16:13 +0000
3+++ exporter.py 2012-05-08 09:49:19 +0000
4@@ -187,14 +187,11 @@
5
6 # Load the marks and initialise things accordingly
7 self.revid_to_mark = {}
8- self.branch_names = {}
9 if self.import_marks_file:
10 marks_info = marks_file.import_marks(self.import_marks_file)
11 if marks_info is not None:
12 self.revid_to_mark = dict((r, m) for m, r in
13 marks_info.items())
14- # These are no longer included in the marks file
15- #self.branch_names = marks_info[1]
16
17 def interesting_history(self):
18 if self.revision:
19@@ -339,12 +336,7 @@
20 ncommits = len(self.revid_to_mark)
21 nparents = len(revobj.parent_ids)
22 if nparents == 0:
23- if ncommits:
24- # This is a parentless commit but it's not the first one
25- # output. We need to create a new temporary branch for it
26- # otherwise git-fast-import will assume the previous commit
27- # was this one's parent
28- ref = self._next_tmp_ref()
29+ self.print_cmd(commands.ResetCommand(ref, None))
30 parent = bzrlib.revision.NULL_REVISION
31 else:
32 parent = revobj.parent_ids[0]
33@@ -617,13 +609,3 @@
34 'valid in git.', git_ref)
35 continue
36 self.print_cmd(commands.ResetCommand(git_ref, ":" + str(mark)))
37-
38- def _next_tmp_ref(self):
39- """Return a unique branch name. The name will start with "tmp"."""
40- prefix = 'tmp'
41- if prefix not in self.branch_names:
42- self.branch_names[prefix] = 0
43- else:
44- self.branch_names[prefix] += 1
45- prefix = '%s.%d' % (prefix, self.branch_names[prefix])
46- return 'refs/heads/%s' % prefix

Subscribers

People subscribed via source and target branches