Merge lp:~jelmer/bzr-cvsps-import/tags into lp:bzr-cvsps-import

Proposed by Jelmer Vernooij
Status: Merged
Approved by: John A Meinel
Approved revision: 67
Merged at revision: 67
Proposed branch: lp:~jelmer/bzr-cvsps-import/tags
Merge into: lp:bzr-cvsps-import
Diff against target: 165 lines (+45/-12)
2 files modified
__init__.py (+9/-2)
cvsps/importer.py (+36/-10)
To merge this branch: bzr merge lp:~jelmer/bzr-cvsps-import/tags
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+51479@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Re-import Toshio's patch to store CVS tags as Bazaar tags.

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2/28/2011 12:26 AM, Jelmer Vernooij wrote:
> Jelmer Vernooij has proposed merging lp:~jelmer/bzr-cvsps-import/tags into lp:bzr-cvsps-import.
>
> Requested reviews:
> Bazaar Developers (bzr)
> Related bugs:
> #128326 Patch to save dirstate tags instead of a tags/ directory
> https://bugs.launchpad.net/bugs/128326
>
> For more details, see:
> https://code.launchpad.net/~jelmer/bzr-cvsps-import/tags/+merge/51479
>
>

 merge: approve

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1tRCEACgkQJdeBCYSNAAPddQCfVql6a5FkZ/Hr0TFMoQj/MjRb
UxsAnR7IgZxLb97FI7tbS02oWSDt14Ic
=bITQ
-----END PGP SIGNATURE-----

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '__init__.py'
2--- __init__.py 2008-01-08 05:06:09 +0000
3+++ __init__.py 2011-02-27 23:26:13 +0000
4@@ -71,11 +71,13 @@
5 help='Use cvs to extract texts.'),
6 option.Option('use-rcs',
7 help='Use rcs to extract texts. (default)'),
8+ option.Option('tags-as-branches',
9+ help='Import CVS tags as Bazaar branches'),
10 ]
11
12 def run(self, cvsroot=None, module=None, output=None, cvsps_dump=None,
13 encoding=None, verify=True, use_cvs=False, use_rcs=False,
14- only_branches=None):
15+ only_branches=None, tags_as_branches=False):
16 from cvsps import importer
17
18 if cvsroot.startswith(':pserver:') or cvsroot.startswith(':ext:'):
19@@ -86,12 +88,17 @@
20 if not use_cvs and not use_rcs:
21 # Default is to use rcs, since it is slightly faster.
22 use_cvs = False
23+ if tags_as_branches:
24+ tag_style = 'branch'
25+ else:
26+ tag_style = 'tag'
27 importer = importer.Importer(cvsroot, module, output,
28 cvsps_dump=cvsps_dump,
29 encoding=encoding,
30 verify=verify,
31 use_cvs_for_text=use_cvs,
32- only_branches=only_branches)
33+ only_branches=only_branches,
34+ tag_style=tag_style)
35 importer.process()
36
37
38
39=== modified file 'cvsps/importer.py'
40--- cvsps/importer.py 2011-02-24 00:04:28 +0000
41+++ cvsps/importer.py 2011-02-27 23:26:13 +0000
42@@ -694,11 +694,12 @@
43 def __init__(self, bzr_repo, cvs_root, cvs_module, map_file,
44 verify=True, use_cvs_for_text=True,
45 file_id_map_file=None, only_branches=None,
46- cvs_fs_encoding=None):
47+ cvs_fs_encoding=None, tag_style='tag'):
48 self._bzr_repo = bzr_repo
49 self._map_file = map_file
50 self._cvs_root = cvs_root
51 self._cvs_module = cvs_module
52+ self._tag_style = tag_style
53 self._file_id_map_file = file_id_map_file
54 self._only_branches = only_branches
55 if self._only_branches is not None:
56@@ -727,7 +728,7 @@
57 self._n_existing_patches = 0
58 self._n_tags = 0
59
60- def handle_patchset(self, patchset):
61+ def handle_patchset(self, patchset, pb):
62 """Handle one of the patchsets from cvs to bzr"""
63
64 revision_id = self._map_file.get(patchset.num)
65@@ -762,7 +763,11 @@
66 self._n_patches += 1
67
68 if patchset.tag is not None:
69- self._handle_tag(patchset, revision_id)
70+ if self._tag_style == 'tag':
71+ self._handle_tag_tag(patchset, revision_id, pb)
72+ else:
73+ self._handle_tag_branch(patchset, revision_id)
74+
75 action += '+tag'
76
77 return revision_id, action
78@@ -973,8 +978,10 @@
79 os.makedirs(branch_path)
80
81 # Create a new one
82+ format = bzrdir.BzrDirFormat.get_default_format()
83 target_branch = bzrdir.BzrDir.create_branch_convenience(branch_path,
84- force_new_tree=False)
85+ force_new_tree=False,
86+ format=format)
87 self._set_repo(target_branch)
88 target_branch.lock_write()
89 self._cache_branch(patchset.branch, target_branch)
90@@ -1021,7 +1028,12 @@
91
92 return revision_id
93
94- def _handle_tag(self, patchset, revision_id):
95+ def _handle_tag_tag(self, patchset, revision_id, pb):
96+ """Create a tag with the given revision id."""
97+ self._cur_bzr_branch.tags.set_tag(patchset.tag, revision_id)
98+ self._n_tags += 1
99+
100+ def _handle_tag_branch(self, patchset, revision_id):
101 """Create a tag with the given revision id."""
102 tag_branch_path = self._get_tag_branch_path(patchset.tag)
103 try:
104@@ -1032,8 +1044,8 @@
105 tag_bzrdir_format = self._cur_bzr_branch.bzrdir.cloning_metadir()
106 tag_bzrdir = tag_bzrdir_format.initialize(tag_branch_path)
107
108- # Make sure that a new branch will get the same repository, so we don't
109- # have to worry about doing a fetch.
110+ # Make sure that a new branch will get the same repository, so we
111+ # don't have to worry about doing a fetch.
112 result_repo = tag_bzrdir.find_repository()
113 self._assert_same_repo(self._bzr_repo, result_repo)
114
115@@ -1116,10 +1128,11 @@
116
117 def __init__(self, cvsroot, cvs_module, output_base, cvsps_dump=None,
118 encoding=None, verify=True, use_cvs_for_text=True,
119- only_branches=None):
120+ only_branches=None, tag_style='tag'):
121 self._cvs_root = osutils.abspath(cvsroot)
122 self._cvs_module = cvs_module
123 self._use_cvs_for_text = use_cvs_for_text
124+ self._tag_style = tag_style
125 self._verify = verify
126 self._only_branches = only_branches
127
128@@ -1174,6 +1187,15 @@
129 a_bzrdir = bzrdir.BzrDir.open_from_transport(bzr_repo_transport)
130 except errors.NotBranchError:
131 return self._create_bzr_repo(bzr_repo_transport)
132+ if self._tag_style == 'tag' and (
133+ not a_bzrdir.find_branch_format().supports_tags()):
134+ newFormat = bzrdir.format_registry.get_default()
135+ converter = a_bzrdir._format.get_converter(newFormat)
136+ pb = ui.ui_factory.nested_progress_bar()
137+ try:
138+ a_bzrdir = converter.convert(a_bzrdir)
139+ finally:
140+ pb.finished()
141 return a_bzrdir.open_repository()
142
143 def _create_bzr_repo(self, a_transport):
144@@ -1215,7 +1237,7 @@
145 n_patchsets = len(patchsets)
146 for i, patchset in enumerate(patchsets):
147 try:
148- rev_id, action = cvs_to_bzr.handle_patchset(patchset)
149+ rev_id, action = cvs_to_bzr.handle_patchset(patchset, pb)
150 except KeyboardInterrupt:
151 if pb is not None:
152 pb.clear()
153@@ -1251,7 +1273,11 @@
154
155 def process(self):
156 """Start converting the repository."""
157- repo = self.open_or_create_bzr_repo()
158+ pb = ui.ui_factory.nested_progress_bar()
159+ try:
160+ repo = self.open_or_create_bzr_repo(pb=pb)
161+ finally:
162+ pb.finished()
163 # Maintain a repository wide lock for the whole transaction
164 # that should help cache stuff.
165 # TODO: jam 20061121 This may actually cache *too* much. Consider

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: