Merge lp:~a-s-usov/bzr-fastimport/no-tags into lp:bzr-fastimport

Proposed by Alex Usov on 2012-09-06
Status: Merged
Approved by: Richard Wilbur on 2014-04-16
Approved revision: 358
Merged at revision: 358
Proposed branch: lp:~a-s-usov/bzr-fastimport/no-tags
Merge into: lp:bzr-fastimport
Diff against target: 85 lines (+19/-4)
3 files modified
cmds.py (+5/-2)
exporter.py (+4/-2)
tests/test_commands.py (+10/-0)
To merge this branch: bzr merge lp:~a-s-usov/bzr-fastimport/no-tags
Reviewer Review Type Date Requested Status
Richard Wilbur 2012-09-06 Approve on 2014-04-16
Review via email: mp+123125@code.launchpad.net

Description of the Change

The way how bazaar handles tags is quite different from both git & mercurial (per-branch vs per-repo).
And the way fast-export emits tags right now -- unconditional reset & new ref may result in clashes when few different branches are imported into single git/hg repo.

Adds a flag to fast-export to not export tags.

To post a comment you must log in.
Richard Wilbur (richard-wilbur) wrote :

Looks like a good solution to the differing tag schemes. Thanks for coding it up with a test.
+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cmds.py'
--- cmds.py 2012-03-22 16:37:43 +0000
+++ cmds.py 2012-09-06 16:54:18 +0000
@@ -682,12 +682,15 @@
682 help="Export an 'absolute' baseline commit prior to"682 help="Export an 'absolute' baseline commit prior to"
683 "the first relative commit",683 "the first relative commit",
684 ),684 ),
685 Option('no-tags',
686 help="Don't export tags"
687 ),
685 ]688 ]
686 encoding_type = 'exact'689 encoding_type = 'exact'
687 def run(self, source=None, destination=None, verbose=False,690 def run(self, source=None, destination=None, verbose=False,
688 git_branch="master", checkpoint=10000, marks=None,691 git_branch="master", checkpoint=10000, marks=None,
689 import_marks=None, export_marks=None, revision=None,692 import_marks=None, export_marks=None, revision=None,
690 plain=True, rewrite_tag_names=False, baseline=False):693 plain=True, rewrite_tag_names=False, no_tags=False, baseline=False):
691 load_fastimport()694 load_fastimport()
692 from bzrlib.branch import Branch695 from bzrlib.branch import Branch
693 from bzrlib.plugins.fastimport import exporter696 from bzrlib.plugins.fastimport import exporter
@@ -704,5 +707,5 @@
704 outf=outf, ref="refs/heads/%s" % git_branch, checkpoint=checkpoint,707 outf=outf, ref="refs/heads/%s" % git_branch, checkpoint=checkpoint,
705 import_marks_file=import_marks, export_marks_file=export_marks,708 import_marks_file=import_marks, export_marks_file=export_marks,
706 revision=revision, verbose=verbose, plain_format=plain,709 revision=revision, verbose=verbose, plain_format=plain,
707 rewrite_tags=rewrite_tag_names, baseline=baseline)710 rewrite_tags=rewrite_tag_names, no_tags=no_tags, baseline=baseline)
708 return exporter.run()711 return exporter.run()
709712
=== modified file 'exporter.py'
--- exporter.py 2012-02-28 16:16:13 +0000
+++ exporter.py 2012-09-06 16:54:18 +0000
@@ -149,7 +149,7 @@
149 def __init__(self, source, outf, ref=None, checkpoint=-1,149 def __init__(self, source, outf, ref=None, checkpoint=-1,
150 import_marks_file=None, export_marks_file=None, revision=None,150 import_marks_file=None, export_marks_file=None, revision=None,
151 verbose=False, plain_format=False, rewrite_tags=False,151 verbose=False, plain_format=False, rewrite_tags=False,
152 baseline=False):152 no_tags=False, baseline=False):
153 """Export branch data in fast import format.153 """Export branch data in fast import format.
154154
155 :param plain_format: if True, 'classic' fast-import format is155 :param plain_format: if True, 'classic' fast-import format is
@@ -160,6 +160,7 @@
160 will be rewritten to be git-compatible.160 will be rewritten to be git-compatible.
161 Otherwise tags which aren't valid for git will be skipped if161 Otherwise tags which aren't valid for git will be skipped if
162 plain_format is set.162 plain_format is set.
163 :param no_tags: if True tags won't be exported at all
163 """164 """
164 self.branch = source165 self.branch = source
165 self.outf = outf166 self.outf = outf
@@ -171,6 +172,7 @@
171 self.excluded_revisions = set()172 self.excluded_revisions = set()
172 self.plain_format = plain_format173 self.plain_format = plain_format
173 self.rewrite_tags = rewrite_tags174 self.rewrite_tags = rewrite_tags
175 self.no_tags = no_tags
174 self.baseline = baseline176 self.baseline = baseline
175 self._multi_author_api_available = hasattr(bzrlib.revision.Revision,177 self._multi_author_api_available = hasattr(bzrlib.revision.Revision,
176 'get_apparent_authors')178 'get_apparent_authors')
@@ -236,7 +238,7 @@
236 self.emit_baseline(interesting.pop(0), self.ref)238 self.emit_baseline(interesting.pop(0), self.ref)
237 for revid in interesting:239 for revid in interesting:
238 self.emit_commit(revid, self.ref)240 self.emit_commit(revid, self.ref)
239 if self.branch.supports_tags():241 if self.branch.supports_tags() and not self.no_tags:
240 self.emit_tags()242 self.emit_tags()
241 finally:243 finally:
242 self.branch.repository.unlock()244 self.branch.repository.unlock()
243245
=== modified file 'tests/test_commands.py'
--- tests/test_commands.py 2012-03-01 21:17:18 +0000
+++ tests/test_commands.py 2012-09-06 16:54:18 +0000
@@ -134,6 +134,16 @@
134 # "bad Tag" should be exported as bad_Tag134 # "bad Tag" should be exported as bad_Tag
135 self.assertNotEqual(-1, data.find("reset refs/tags/bad_Tag"))135 self.assertNotEqual(-1, data.find("reset refs/tags/bad_Tag"))
136136
137 def test_no_tags(self):
138 tree = self.make_branch_and_tree("br")
139 tree.commit("pointless")
140 self.assertTrue(tree.branch.supports_tags())
141 rev_id = tree.branch.dotted_revno_to_revision_id((1,))
142 tree.branch.tags.set_tag("someTag", rev_id)
143
144 data = self.run_bzr("fast-export --plain --no-tags br")[0]
145 self.assertEqual(-1, data.find("reset refs/tags/someTag"))
146
137 def test_baseline_option(self):147 def test_baseline_option(self):
138 tree = self.make_branch_and_tree("bl")148 tree = self.make_branch_and_tree("bl")
139149

Subscribers

People subscribed via source and target branches