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.
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.
705
takes_args = ['to_root_dir', 'from_archive', 'reuse_history*']
699
706
takes_options = ['verbose']
701
708
def printer(self, name):
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)
711
def import_archive(to_root, from_archive, verbose, printer):
716
import_archive(to_root, from_archive, verbose, self.printer,
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))
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"