~ubuntu-branches/debian/jessie/bzr-fastimport/jessie

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2010-11-06 18:40:27 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20101106184027-iclo8iim9equ6i8b
Tags: 0.9.0+bzr279-1
* New upstream snapshot.
* Bump standards version to 3.9.1 (no changes).
* Run testsuite during package build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
page on Launchpad, https://launchpad.net/bzr-fastimport.
80
80
"""
81
81
 
82
 
version_info = (0, 9, 0, 'dev', 0)
 
82
version_info = (0, 10, 0, 'dev', 0)
83
83
 
84
84
from bzrlib import bzrdir
85
85
from bzrlib.commands import Command, register_command
86
86
from bzrlib.option import Option, ListOption, RegistryOption
87
87
 
88
88
 
 
89
def load_fastimport():
 
90
    """Load the fastimport module or raise an appropriate exception."""
 
91
    try:
 
92
        import fastimport
 
93
    except ImportError, e:
 
94
        from bzrlib.errors import DependencyNotPresent
 
95
        raise DependencyNotPresent("fastimport", e)
 
96
 
 
97
 
89
98
def test_suite():
90
99
    import tests
91
100
    return tests.test_suite()
103
112
      destination is expected
104
113
    :param user_map: if not None, the file containing the user map.
105
114
    """
106
 
    import parser
 
115
    from fastimport import parser
107
116
    stream = _get_source_stream(source)
108
117
    user_mapper = _get_user_mapper(user_map)
109
118
    proc = processor_factory(control, params=params, verbose=verbose)
114
123
def _get_source_stream(source):
115
124
    if source == '-':
116
125
        import sys
 
126
        from fastimport import helpers
117
127
        stream = helpers.binary_stream(sys.stdin)
118
128
    elif source.endswith('.gz'):
119
129
        import gzip
346
356
        trees=False, count=-1, checkpoint=10000, autopack=4, inv_cache=-1,
347
357
        mode=None, import_marks=None, export_marks=None, format=None,
348
358
        user_map=None):
349
 
        from bzrlib.errors import BzrCommandError, NotBranchError
 
359
        load_fastimport()
350
360
        from bzrlib.plugins.fastimport.processors import generic_processor
351
361
        from bzrlib.plugins.fastimport.helpers import (
352
362
            open_destination_directory,
385
395
 
386
396
    def _generate_info(self, source):
387
397
        from cStringIO import StringIO
388
 
        import parser
389
 
        from bzrlib.plugins.fastimport.processors import info_processor
 
398
        from fastimport import parser
 
399
        from fastimport.processors import info_processor
390
400
        stream = _get_source_stream(source)
391
401
        output = StringIO()
392
402
        try:
491
501
    encoding_type = 'exact'
492
502
    def run(self, source, verbose=False, include_paths=None,
493
503
        exclude_paths=None, user_map=None):
494
 
        from bzrlib.plugins.fastimport.processors import filter_processor
 
504
        load_fastimport()
 
505
        from fastimport.processors import filter_processor
495
506
        params = {
496
507
            'include_paths': include_paths,
497
508
            'exclude_paths': exclude_paths,
498
509
            }
499
 
        return _run(source, filter_processor.FilterProcessor, None, params,
 
510
        return _run(source, filter_processor.FilterProcessor, params,
500
511
            verbose, user_map=user_map)
501
512
 
502
513
 
529
540
    takes_options = ['verbose']
530
541
    aliases = []
531
542
    def run(self, source, verbose=False):
532
 
        from bzrlib.plugins.fastimport.processors import info_processor
533
 
        return _run(source, info_processor.InfoProcessor, None, {}, verbose)
 
543
        load_fastimport()
 
544
        from fastimport.processors import info_processor
 
545
        return _run(source, info_processor.InfoProcessor, {}, verbose)
534
546
 
535
547
 
536
548
class cmd_fast_import_query(Command):
584
596
                     ]
585
597
    aliases = []
586
598
    def run(self, source, verbose=False, commands=None, commit_mark=None):
587
 
        from bzrlib.plugins.fastimport.processors import query_processor
 
599
        load_fastimport()
 
600
        from fastimport.processors import query_processor
588
601
        from bzrlib.plugins.fastimport import helpers
589
602
        params = helpers.defines_to_dict(commands) or {}
590
603
        if commit_mark:
591
604
            params['commit-mark'] = commit_mark
592
 
        return _run(source, query_processor.QueryProcessor, None, params,
 
605
        return _run(source, query_processor.QueryProcessor, params,
593
606
            verbose)
594
607
 
595
608
 
698
711
        git_branch="master", checkpoint=10000, marks=None,
699
712
        import_marks=None, export_marks=None, revision=None,
700
713
        plain=True):
 
714
        load_fastimport()
701
715
        from bzrlib.plugins.fastimport import bzr_exporter
702
716
 
703
 
        if marks:                                              
 
717
        if marks:
704
718
            import_marks = export_marks = marks
705
719
        exporter = bzr_exporter.BzrFastExporter(source,
706
720
            destination=destination,
763
777
    encoding_type = 'exact'
764
778
    def run(self, source, destination, verbose=False, trunk_only=False,
765
779
        encoding=None, sort=None):
 
780
        load_fastimport()
766
781
        from bzrlib.plugins.fastimport.exporters import fast_export_from
767
782
        custom = []
768
783
        if trunk_only:
820
835
    aliases = []
821
836
    encoding_type = 'exact'
822
837
    def run(self, source, destination, verbose=False):
 
838
        load_fastimport()
823
839
        from bzrlib.plugins.fastimport.exporters import fast_export_from
824
840
        fast_export_from(source, destination, 'hg', verbose)
825
841
 
846
862
    aliases = []
847
863
    encoding_type = 'exact'
848
864
    def run(self, source, destination, verbose=False):
 
865
        load_fastimport()
849
866
        from bzrlib.plugins.fastimport.exporters import fast_export_from
850
867
        fast_export_from(source, destination, 'git', verbose)
851
868
 
867
884
    aliases = []
868
885
    encoding_type = 'exact'
869
886
    def run(self, source, destination, verbose=False):
 
887
        load_fastimport()
870
888
        from bzrlib.plugins.fastimport.exporters import fast_export_from
871
889
        fast_export_from(source, destination, 'mtn', verbose)
872
890
 
882
900
    bzrp4 must be installed as its p4_fast_export.py module is used under
883
901
    the covers to do the export.  bzrp4 can be downloaded from
884
902
    https://launchpad.net/bzrp4/.
885
 
    
 
903
 
886
904
    The P4PORT environment variable must be set, and you must be logged
887
905
    into the Perforce server.
888
906
 
898
916
    aliases = []
899
917
    encoding_type = 'exact'
900
918
    def run(self, source, destination, verbose=False):
 
919
        load_fastimport()
901
920
        from bzrlib.plugins.fastimport.exporters import fast_export_from
902
921
        custom = []
903
922
        fast_export_from(source, destination, 'p4', verbose, custom)
936
955
    encoding_type = 'exact'
937
956
    def run(self, source, destination, verbose=False, trunk_path=None,
938
957
        branches_path=None, tags_path=None):
 
958
        load_fastimport()
939
959
        from bzrlib.plugins.fastimport.exporters import fast_export_from
940
960
        custom = []
941
961
        if trunk_path is not None: