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 |
||
17 |
"""Fast, stream-based importing of data into Bazaar."""
|
|
18 |
||
19 |
||
20 |
from bzrlib.commands import Command, register_command |
|
21 |
from bzrlib.option import RegistryOption |
|
22 |
||
23 |
||
24 |
def test_suite(): |
|
25 |
import tests |
|
26 |
return tests.test_suite() |
|
27 |
||
28 |
||
29 |
class cmd_fast_import(Command): |
|
30 |
"""Backend for fast Bazaar data importers. |
|
31 |
||
32 |
This command reads a mixed command/data stream from standard
|
|
33 |
input and creates branches in the current repository. It is
|
|
34 |
designed to be stream compatible with git-fast-import so that
|
|
35 |
existing front-ends can be reused with a minimum of modifications.
|
|
36 |
Git 1.5.4 includes git-fast-export enabling conversion from git.
|
|
37 |
See http://git.or.cz/gitwiki/InterfacesFrontendsAndTools for
|
|
38 |
other front-ends including converters from Subversion, CVS,
|
|
39 |
Mercurial, Darcs, Perforce and SCCS. See
|
|
40 |
http://www.kernel.org/pub/software/scm/git/docs/git-fast-import.html
|
|
41 |
for the protocol specification. See the documentation shipped
|
|
42 |
with the bzr-fastimport plugin for the known limitations and
|
|
43 |
Bazaar-specific enhancements.
|
|
44 |
||
45 |
Examples::
|
|
46 |
||
47 |
cd /git/repo/path
|
|
48 |
git-fast-export --signed-tags=warn | bzr fast-import
|
|
49 |
||
50 |
Import a Git repository into Bazaar.
|
|
51 |
||
52 |
svn-fast-export.py /svn/repo/path | bzr fast-import
|
|
53 |
||
54 |
Import a Subversion repository into Bazaar.
|
|
55 |
||
56 |
hg-fast-export.py -r /hg/repo/path | bzr fast-import
|
|
57 |
||
58 |
Import a Mercurial repository into Bazaar.
|
|
59 |
"""
|
|
60 |
hidden = True |
|
61 |
takes_args = [] |
|
62 |
takes_options = ['verbose', |
|
63 |
RegistryOption.from_kwargs('method', |
|
64 |
'The way to process the data.', |
|
65 |
title='Processing Method', value_switches=True, enum_switch=False, |
|
66 |
generic="Import the data into any format (default)", |
|
67 |
info="Display information only - don't import it", |
|
68 |
),
|
|
69 |
]
|
|
70 |
aliases = ['fastimport'] |
|
71 |
def run(self, verbose=False, method='generic'): |
|
72 |
import sys |
|
73 |
from bzrlib import bzrdir |
|
74 |
import parser |
|
75 |
||
76 |
if method == 'info': |
|
77 |
from bzrlib.plugins.fastimport.processors import info_processor |
|
78 |
proc = info_processor.InfoProcessor() |
|
79 |
else: |
|
80 |
from bzrlib.plugins.fastimport.processors import generic_processor |
|
81 |
control, relpath = bzrdir.BzrDir.open_containing('.') |
|
82 |
target = control.open_repository() |
|
83 |
proc = generic_processor.GenericProcessor(target) |
|
84 |
||
85 |
# Note: might need to pass the parser to the processor so that the
|
|
86 |
# processor can be it's error reporting with source context
|
|
87 |
p = parser.ImportParser(sys.stdin, verbose=verbose) |
|
88 |
return proc.process(p.iter_commands) |
|
89 |
||
90 |
||
91 |
register_command(cmd_fast_import) |