~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to baz_import.py

  • Committer: Robert Collins
  • Date: 2005-10-24 07:17:53 UTC
  • mto: (147.1.42) (364.1.3 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: robertc@robertcollins.net-20051024071753-71716e85c23a7f93
Enable reuse of history on archive imports, just append the history locations to the command line

Show diffs side-by-side

added added

removed removed

Lines of Context:
694
694
 
695
695
 
696
696
class cmd_baz_import(Command):
697
 
    """Import an Arch or Baz archive into bzr branches."""
698
 
    takes_args = ['to_root_dir', 'from_archive']
 
697
    """Import an Arch or Baz archive into bzr branches.
 
698
    
 
699
    reuse_history allows you to specify any previous imports you 
 
700
    have done of different archives, which this archive has branches
 
701
    tagged from. This will dramatically reduce the time to convert 
 
702
    the archive as it will not have to convert the history already
 
703
    converted in that other branch.
 
704
    """
 
705
    takes_args = ['to_root_dir', 'from_archive', 'reuse_history*']
699
706
    takes_options = ['verbose']
700
707
 
701
708
    def printer(self, name):
702
709
        print name
703
710
 
704
 
    def run(self, to_root_dir, from_archive, verbose=False):
 
711
    def run(self, to_root_dir, from_archive, verbose=False,
 
712
            reuse_history_list=[]):
705
713
        to_root = str(os.path.realpath(to_root_dir))
706
714
        if not os.path.exists(to_root):
707
715
            os.mkdir(to_root)
708
 
        import_archive(to_root, from_archive, verbose, self.printer)
709
 
 
710
 
 
711
 
def import_archive(to_root, from_archive, verbose, printer):
 
716
        import_archive(to_root, from_archive, verbose, self.printer, 
 
717
                       reuse_history_list)
 
718
 
 
719
 
 
720
def import_archive(to_root, from_archive, verbose, printer,
 
721
                   reuse_history_from=[]):
 
722
    real_to = os.path.realpath(to_root)
 
723
    history_locations = [real_to] + reuse_history_from
712
724
    for version in pybaz.Archive(str(from_archive)).iter_versions():
713
725
        target = os.path.join(to_root, map_namespace(version))
714
726
        printer("importing %s into %s" % (version, target))
715
727
        if not os.path.exists(os.path.dirname(target)):
716
728
            os.makedirs(os.path.dirname(target))
717
729
        try:
718
 
            import_version(target, version, printer)
 
730
            import_version(target, version, printer,
 
731
                           reuse_history_from=reuse_history_from)
719
732
        except pybaz.errors.ExecProblem,e:
720
733
            if str(e).find('The requested revision cannot be built.') != -1:
721
734
                printer("Skipping version %s as it cannot be built due"