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
1=== modified file 'cmds.py'
2--- cmds.py 2012-03-22 16:37:43 +0000
3+++ cmds.py 2012-09-06 16:54:18 +0000
4@@ -682,12 +682,15 @@
5 help="Export an 'absolute' baseline commit prior to"
6 "the first relative commit",
7 ),
8+ Option('no-tags',
9+ help="Don't export tags"
10+ ),
11 ]
12 encoding_type = 'exact'
13 def run(self, source=None, destination=None, verbose=False,
14 git_branch="master", checkpoint=10000, marks=None,
15 import_marks=None, export_marks=None, revision=None,
16- plain=True, rewrite_tag_names=False, baseline=False):
17+ plain=True, rewrite_tag_names=False, no_tags=False, baseline=False):
18 load_fastimport()
19 from bzrlib.branch import Branch
20 from bzrlib.plugins.fastimport import exporter
21@@ -704,5 +707,5 @@
22 outf=outf, ref="refs/heads/%s" % git_branch, checkpoint=checkpoint,
23 import_marks_file=import_marks, export_marks_file=export_marks,
24 revision=revision, verbose=verbose, plain_format=plain,
25- rewrite_tags=rewrite_tag_names, baseline=baseline)
26+ rewrite_tags=rewrite_tag_names, no_tags=no_tags, baseline=baseline)
27 return exporter.run()
28
29=== modified file 'exporter.py'
30--- exporter.py 2012-02-28 16:16:13 +0000
31+++ exporter.py 2012-09-06 16:54:18 +0000
32@@ -149,7 +149,7 @@
33 def __init__(self, source, outf, ref=None, checkpoint=-1,
34 import_marks_file=None, export_marks_file=None, revision=None,
35 verbose=False, plain_format=False, rewrite_tags=False,
36- baseline=False):
37+ no_tags=False, baseline=False):
38 """Export branch data in fast import format.
39
40 :param plain_format: if True, 'classic' fast-import format is
41@@ -160,6 +160,7 @@
42 will be rewritten to be git-compatible.
43 Otherwise tags which aren't valid for git will be skipped if
44 plain_format is set.
45+ :param no_tags: if True tags won't be exported at all
46 """
47 self.branch = source
48 self.outf = outf
49@@ -171,6 +172,7 @@
50 self.excluded_revisions = set()
51 self.plain_format = plain_format
52 self.rewrite_tags = rewrite_tags
53+ self.no_tags = no_tags
54 self.baseline = baseline
55 self._multi_author_api_available = hasattr(bzrlib.revision.Revision,
56 'get_apparent_authors')
57@@ -236,7 +238,7 @@
58 self.emit_baseline(interesting.pop(0), self.ref)
59 for revid in interesting:
60 self.emit_commit(revid, self.ref)
61- if self.branch.supports_tags():
62+ if self.branch.supports_tags() and not self.no_tags:
63 self.emit_tags()
64 finally:
65 self.branch.repository.unlock()
66
67=== modified file 'tests/test_commands.py'
68--- tests/test_commands.py 2012-03-01 21:17:18 +0000
69+++ tests/test_commands.py 2012-09-06 16:54:18 +0000
70@@ -134,6 +134,16 @@
71 # "bad Tag" should be exported as bad_Tag
72 self.assertNotEqual(-1, data.find("reset refs/tags/bad_Tag"))
73
74+ def test_no_tags(self):
75+ tree = self.make_branch_and_tree("br")
76+ tree.commit("pointless")
77+ self.assertTrue(tree.branch.supports_tags())
78+ rev_id = tree.branch.dotted_revno_to_revision_id((1,))
79+ tree.branch.tags.set_tag("someTag", rev_id)
80+
81+ data = self.run_bzr("fast-export --plain --no-tags br")[0]
82+ self.assertEqual(-1, data.find("reset refs/tags/someTag"))
83+
84 def test_baseline_option(self):
85 tree = self.make_branch_and_tree("bl")
86

Subscribers

People subscribed via source and target branches