~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to baz_import.py

  • Committer: Aaron Bentley
  • Date: 2006-03-11 15:42:15 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20060311154215-cd9599aa4e996ccf
Initial nested progressbar work.  (Need console fix)

Show diffs side-by-side

added added

removed removed

Lines of Context:
402
402
        print 'Tree is up-to-date with %s' % last_revision
403
403
        return
404
404
 
405
 
    progress_bar = bzrlib.ui.ui_factory.progress_bar()
 
405
    progress_bar = bzrlib.ui.ui_factory.nested_progress_bar()
406
406
    tempdir = tempfile.mkdtemp(prefix="baz2bzr-",
407
407
                               dir=os.path.dirname(output_dir))
408
408
    try:
426
426
                    sys.stdout.write('.')
427
427
        finally:
428
428
            if fancy:
429
 
                progress_bar.clear()
 
429
                progress_bar.finished()
430
430
            else:
431
431
                sys.stdout.write('\n')
432
432
 
812
812
            create_shared_repository(to_root)
813
813
        except NoRepositoryPresent:
814
814
            raise BzrCommandError("Can't create repository at existing branch.")
815
 
    for version in pybaz.Archive(str(from_archive)).iter_versions():
816
 
        if not selected(version):
817
 
            print "Skipping %s" % version
818
 
            continue
819
 
        target = os.path.join(to_root, map_namespace(version))
820
 
        printer("importing %s into %s" % (version, target))
821
 
        if not os.path.exists(os.path.dirname(target)):
822
 
            os.makedirs(os.path.dirname(target))
823
 
        try:
824
 
            import_version(target, version, printer,
825
 
                           reuse_history_from=reuse_history_from, 
826
 
                           standalone=standalone)
827
 
        except pybaz.errors.ExecProblem,e:
828
 
            if str(e).find('The requested revision cannot be built.') != -1:
829
 
                printer("Skipping version %s as it cannot be built due"
830
 
                        " to a missing parent archive." % version)
831
 
            else:
832
 
                raise
833
 
        except UserError, e:
834
 
            if str(e).find('already exists, and the last revision ') != -1:
835
 
                printer("Skipping version %s as it has had commits made"
836
 
                        " since it was converted to bzr." % version)
837
 
            else:
838
 
                raise
839
 
 
 
815
    versions = list(pybaz.Archive(str(from_archive)).iter_versions())
 
816
#    progress_bar = bzrlib.ui.ui_factory.nested_progress_bar()
 
817
    try:
 
818
        for num, version in enumerate(versions):
 
819
#            progress_bar.update("Branch", num, len(versions))
 
820
            if not selected(version):
 
821
                print "Skipping %s" % version
 
822
                continue
 
823
            target = os.path.join(to_root, map_namespace(version))
 
824
            printer("importing %s into %s" % (version, target))
 
825
            if not os.path.exists(os.path.dirname(target)):
 
826
                os.makedirs(os.path.dirname(target))
 
827
            try:
 
828
                import_version(target, version, printer,
 
829
                               reuse_history_from=reuse_history_from, 
 
830
                               standalone=standalone)
 
831
            except pybaz.errors.ExecProblem,e:
 
832
                if str(e).find('The requested revision cannot be built.') != -1:
 
833
                    printer("Skipping version %s as it cannot be built due"
 
834
                            " to a missing parent archive." % version)
 
835
                else:
 
836
                    raise
 
837
            except UserError, e:
 
838
                if str(e).find('already exists, and the last revision ') != -1:
 
839
                    printer("Skipping version %s as it has had commits made"
 
840
                            " since it was converted to bzr." % version)
 
841
                else:
 
842
                    raise
 
843
    finally:
 
844
        pass
 
845
#        progress_bar.finished()
840
846
 
841
847
def map_namespace(a_version):
842
848
    a_version = pybaz.Version("%s" % a_version)