bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
1 |
# Copyright (C) 2008 Canonical Ltd
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
|
0.64.81
by Ian Clatworthy
'bzr help fastimport' now provides useful help |
17 |
r"""FastImport Plugin |
18 |
=================
|
|
19 |
||
20 |
The fastimport plugin provides stream-based importing of data into Bazaar.
|
|
21 |
A bzr-fast-export.py script is also included providing exporting of data
|
|
22 |
out of Bazaar to the same format. As well as enabling interchange between
|
|
23 |
multiple VCS tools, fastimport/export can be useful for complex branch
|
|
24 |
operatons, e.g. partitioning off part of a code base in order to Open
|
|
25 |
Source it.
|
|
26 |
||
27 |
The normal import recipe is::
|
|
28 |
||
29 |
bzr init-repo .
|
|
30 |
front-end | bzr fast-import -
|
|
31 |
||
32 |
Numerous front-ends are provided in the exporters directory where
|
|
33 |
the plugin is installed. The list of known front-ends and their
|
|
34 |
status is documented on http://bazaar-vcs.org/BzrFastImport/FrontEnds.
|
|
35 |
For further details, see http://bazaar-vcs.org/BzrFastImport and the
|
|
36 |
online help for the commands::
|
|
37 |
||
38 |
bzr help fast-import
|
|
39 |
bzr help fast-import-info
|
|
40 |
bzr help fast-import-filter
|
|
41 |
||
42 |
To report bugs or publish enhancements, visit the bzr-fastimport project
|
|
43 |
page on Launchpad, https://launchpad.net/bzr-fastimport.
|
|
44 |
"""
|
|
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
45 |
|
46 |
||
47 |
from bzrlib.commands import Command, register_command |
|
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
48 |
from bzrlib.option import Option, ListOption |
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
49 |
|
50 |
||
51 |
def test_suite(): |
|
52 |
import tests |
|
53 |
return tests.test_suite() |
|
54 |
||
55 |
||
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
56 |
def _run(source, processor_factory, control, params, verbose): |
57 |
"""Create and run a processor. |
|
58 |
|
|
59 |
:param source: a filename or '-' for standard input
|
|
60 |
:param processor_factory: a callable for creating a processor
|
|
61 |
:param control: the BzrDir of the destination or None if no
|
|
62 |
destination is expected
|
|
63 |
"""
|
|
64 |
import parser |
|
65 |
if source == '-': |
|
66 |
import sys |
|
67 |
stream = sys.stdin |
|
|
0.65.6
by James Westby
Open the input in binary mode, as suggested by Paul Moore. |
68 |
try: |
69 |
import msvcrt |
|
70 |
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) |
|
71 |
except ImportError: |
|
72 |
pass
|
|
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
73 |
else: |
|
0.65.6
by James Westby
Open the input in binary mode, as suggested by Paul Moore. |
74 |
stream = open(source, "rb") |
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
75 |
proc = processor_factory(control, params=params, verbose=verbose) |
76 |
p = parser.ImportParser(stream, verbose=verbose) |
|
77 |
return proc.process(p.iter_commands) |
|
|
0.64.8
by Ian Clatworthy
custom parameters for processors |
78 |
|
79 |
||
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
80 |
class cmd_fast_import(Command): |
81 |
"""Backend for fast Bazaar data importers. |
|
82 |
||
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
83 |
This command reads a mixed command/data stream and
|
84 |
creates branches in the current repository accordingly.
|
|
85 |
To specify standard input as the input stream, use a
|
|
86 |
source name of '-'.
|
|
87 |
|
|
88 |
The usual recipe is::
|
|
89 |
||
90 |
bzr init-repo .
|
|
91 |
front-end | bzr fast-import -
|
|
92 |
||
93 |
If run inside a branch using a shared repository, then
|
|
94 |
the current branch is made the trunk and other branches,
|
|
95 |
if any, are created in sister directories. If run inside
|
|
96 |
a standalone tree, the current branch is also made the
|
|
97 |
trunk, but warnings are output about other branches found.
|
|
98 |
|
|
99 |
The stream format is upwardly compatible with git-fast-import
|
|
100 |
so existing front-ends for that tool can typically be reused
|
|
101 |
without changes. See http://bazaar-vcs.org/BzrFastImport for
|
|
102 |
links to matching exporters from Subversion, CVS, Git,
|
|
103 |
Mercurial, Darcs, Perforce and SCCS.
|
|
104 |
|
|
105 |
While reusing an existing format with existing frontends is
|
|
106 |
great, it does mean a slightly more complex recipe when
|
|
|
0.64.50
by Ian Clatworthy
cleanly restart after an interruption - basic mirroring |
107 |
importing large projects via exporters that reuse blob data
|
108 |
across commits, namely::
|
|
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
109 |
|
110 |
bzr init-repo .
|
|
111 |
front-end > xxx.fi
|
|
|
0.66.1
by Elliot Murphy
Fix typo in online help. |
112 |
bzr fast-import-info -v xxx.fi > xxx.cfg
|
113 |
bzr fast-import xxx.fi --info xxx.cfg
|
|
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
114 |
|
115 |
In this scenario, the xxx.cfg file generated by the first pass
|
|
116 |
holds caching hints that the second pass uses to lower memory
|
|
117 |
usage.
|
|
118 |
|
|
|
0.64.50
by Ian Clatworthy
cleanly restart after an interruption - basic mirroring |
119 |
At checkpoints and on completion, the commit-id -> revision-id
|
120 |
map is saved to a file called 'fastimport-id-map' in the control
|
|
121 |
directory for the repository (e.g. .bzr/repository). If the import
|
|
122 |
is interrupted or unexpectedly crashes, it can be started again
|
|
123 |
and this file will be used to skip over already loaded revisions.
|
|
124 |
As long as subsequent exports from the original source begin
|
|
125 |
with exactly the same revisions, you can use this feature to
|
|
126 |
maintain a mirror of a repository managed by a foreign tool.
|
|
127 |
If and when Bazaar is used to manage the repository, this file
|
|
128 |
can be safely deleted.
|
|
129 |
||
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
130 |
If you wish to write a custom exporter for your project, see
|
131 |
http://bazaar-vcs.org/BzrFastImport for the detailed protocol
|
|
132 |
specification. In many cases, exporters can be written quite
|
|
133 |
quickly using whatever scripting/programming language you like.
|
|
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
134 |
|
135 |
Examples::
|
|
136 |
||
137 |
cd /git/repo/path
|
|
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
138 |
git-fast-export --signed-tags=warn | bzr fast-import -
|
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
139 |
|
140 |
Import a Git repository into Bazaar.
|
|
141 |
||
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
142 |
svn-fast-export.py /svn/repo/path | bzr fast-import -
|
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
143 |
|
144 |
Import a Subversion repository into Bazaar.
|
|
145 |
||
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
146 |
hg-fast-export.py -r /hg/repo/path | bzr fast-import -
|
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
147 |
|
148 |
Import a Mercurial repository into Bazaar.
|
|
149 |
"""
|
|
150 |
hidden = True |
|
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
151 |
_see_also = ['fast-import-info', 'fast-import-filter'] |
152 |
takes_args = ['source'] |
|
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
153 |
takes_options = ['verbose', |
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
154 |
Option('info', type=str, |
155 |
help="Path to file containing caching hints.", |
|
156 |
),
|
|
157 |
Option('trees', |
|
158 |
help="Update working trees.", |
|
159 |
),
|
|
160 |
Option('checkpoint', type=int, |
|
161 |
help="Checkpoint automatically every N revisions.", |
|
162 |
),
|
|
163 |
Option('count', type=int, |
|
164 |
help="Import this many revisions then exit.", |
|
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
165 |
),
|
|
0.64.77
by Ian Clatworthy
add inv-fulltext option and improve speed |
166 |
Option('inv-fulltext', type=int, |
167 |
help="Inventory fulltext every N revisions.", |
|
168 |
),
|
|
|
0.64.44
by Ian Clatworthy
smart caching of serialised inventories |
169 |
Option('inv-cache', type=int, |
170 |
help="Number of inventories to cache.", |
|
171 |
),
|
|
|
0.64.47
by Ian Clatworthy
add option for enabling experimental stuff |
172 |
Option('experimental', |
173 |
help="Enable experimental features.", |
|
174 |
),
|
|
|
0.68.7
by Pieter de Bie
Add importing and exporting of marks to bzr-fastimport |
175 |
Option('import-marks', type=str, |
|
0.64.82
by Ian Clatworthy
Merge Pieter de Bie's export-fixes branch |
176 |
help="Import marks from file."), |
|
0.68.7
by Pieter de Bie
Add importing and exporting of marks to bzr-fastimport |
177 |
Option('export-marks', type=str, |
|
0.64.82
by Ian Clatworthy
Merge Pieter de Bie's export-fixes branch |
178 |
help="Export marks to file."), |
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
179 |
]
|
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
180 |
aliases = [] |
181 |
def run(self, source, verbose=False, info=None, trees=False, |
|
|
0.64.77
by Ian Clatworthy
add inv-fulltext option and improve speed |
182 |
checkpoint=10000, count=-1, inv_fulltext=200, inv_cache=10, |
|
0.64.82
by Ian Clatworthy
Merge Pieter de Bie's export-fixes branch |
183 |
experimental=True, import_marks=None, export_marks=None): |
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
184 |
from bzrlib import bzrdir |
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
185 |
from bzrlib.plugins.fastimport.processors import generic_processor |
186 |
control, relpath = bzrdir.BzrDir.open_containing('.') |
|
187 |
params = { |
|
188 |
'info': info, |
|
189 |
'trees': trees, |
|
190 |
'checkpoint': checkpoint, |
|
|
0.64.44
by Ian Clatworthy
smart caching of serialised inventories |
191 |
'count': count, |
|
0.64.77
by Ian Clatworthy
add inv-fulltext option and improve speed |
192 |
'inv-fulltext': inv_fulltext, |
|
0.64.44
by Ian Clatworthy
smart caching of serialised inventories |
193 |
'inv-cache': inv_cache, |
|
0.64.47
by Ian Clatworthy
add option for enabling experimental stuff |
194 |
'experimental': experimental, |
|
0.68.7
by Pieter de Bie
Add importing and exporting of marks to bzr-fastimport |
195 |
'import-marks': import_marks, |
196 |
'export-marks': export_marks, |
|
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
197 |
}
|
198 |
return _run(source, generic_processor.GenericProcessor, control, |
|
199 |
params, verbose) |
|
200 |
||
201 |
||
202 |
class cmd_fast_import_info(Command): |
|
203 |
"""Output information about a fast-import stream. |
|
204 |
||
205 |
This command reads a fast-import stream and outputs
|
|
206 |
statistics and interesting properties about what it finds.
|
|
207 |
When run in verbose mode, the information is output as a
|
|
208 |
configuration file that can be passed to fast-import to
|
|
209 |
assist it in intelligently caching objects.
|
|
210 |
||
211 |
To specify standard input as the input stream, use a source
|
|
212 |
name of '-'.
|
|
213 |
||
214 |
Examples::
|
|
215 |
||
216 |
front-end | bzr fast-import-info -
|
|
217 |
||
218 |
Display statistics about the import stream produced by front-end.
|
|
219 |
||
220 |
front-end | bzr fast-import-info -v - > front-end.cfg
|
|
221 |
||
222 |
Create a hints file for running fast-import on a large repository.
|
|
223 |
"""
|
|
224 |
hidden = True |
|
225 |
_see_also = ['fast-import'] |
|
226 |
takes_args = ['source'] |
|
227 |
takes_options = ['verbose'] |
|
228 |
aliases = [] |
|
229 |
def run(self, source, verbose=False): |
|
230 |
from bzrlib.plugins.fastimport.processors import info_processor |
|
231 |
return _run(source, info_processor.InfoProcessor, None, {}, verbose) |
|
232 |
||
233 |
||
234 |
class cmd_fast_import_filter(Command): |
|
235 |
"""Filter a fast-import stream displaying selected commands. |
|
236 |
||
237 |
To specify standard input as the input stream, use a source
|
|
238 |
name of '-'. To specify the commands to display, use the -C
|
|
239 |
option one or more times. To specify just some fields for
|
|
240 |
a command, use the syntax::
|
|
241 |
||
242 |
command=field1,...
|
|
243 |
||
244 |
By default, the nominated fields for the nominated commands
|
|
245 |
are displayed tab separated. To see the information in
|
|
246 |
a name:value format, use verbose mode.
|
|
247 |
||
248 |
Note: Binary fields (e.g. data for blobs) are masked out
|
|
249 |
so it is generally safe to view the output in a terminal.
|
|
250 |
||
251 |
Examples::
|
|
252 |
||
253 |
front-end > xxx.fi
|
|
254 |
bzr fast-import-filter xxx.fi -Creset -Ctag
|
|
255 |
||
256 |
Show all the fields of the reset and tag commands.
|
|
257 |
||
258 |
bzr fast-import-filter xxx.fi -Ccommit=mark,merge
|
|
259 |
||
260 |
Show the mark and merge fields of the commit commands.
|
|
261 |
"""
|
|
262 |
hidden = True |
|
263 |
_see_also = ['fast-import'] |
|
264 |
takes_args = ['source'] |
|
265 |
takes_options = ['verbose', |
|
266 |
ListOption('commands', short_name='C', type=str, |
|
267 |
help="Display fields for these commands." |
|
268 |
),
|
|
269 |
]
|
|
270 |
aliases = [] |
|
271 |
def run(self, source, verbose=False, commands=None): |
|
272 |
from bzrlib.plugins.fastimport.processors import filter_processor |
|
273 |
from bzrlib.plugins.fastimport import helpers |
|
274 |
params = helpers.defines_to_dict(commands) |
|
275 |
return _run(source, filter_processor.FilterProcessor, None, params, |
|
276 |
verbose) |
|
|
0.64.1
by Ian Clatworthy
1st cut: gfi parser + --info processing method |
277 |
|
278 |
||
279 |
register_command(cmd_fast_import) |
|
|
0.64.38
by Ian Clatworthy
clean-up doc ready for initial release |
280 |
register_command(cmd_fast_import_info) |
281 |
register_command(cmd_fast_import_filter) |