def pre_process(self): self._start_time = time.time() self._load_info_and_params() if self.total_commits: self.note("Starting import of %d commits ..." % (self.total_commits,)) else: self.note("Starting import ...") self.cache_mgr = cache_manager.CacheManager(self.info, self.verbose, self.inventory_cache_size) if self.params.get("import-marks") is not None: mark_info = marks_file.import_marks(self.params.get("import-marks")) if mark_info is not None: self.cache_mgr.marks = mark_info self.skip_total = False self.first_incremental_commit = True else: self.first_incremental_commit = False self.skip_total = self._init_id_map() if self.skip_total: self.note("Found %d commits already loaded - " "skipping over these ...", self.skip_total) self._revision_count = 0 # mapping of tag name to revision_id self.tags = {} # Create the revision store to use for committing, if any self.rev_store = self._revision_store_factory() # Disable autopacking if the repo format supports it. # THIS IS A HACK - there is no sanctioned way of doing this yet. if isinstance(self.repo, KnitPackRepository): self._original_max_pack_count = \ self.repo._pack_collection._max_pack_count def _max_pack_count_for_import(total_revisions): return total_revisions + 1 self.repo._pack_collection._max_pack_count = \ _max_pack_count_for_import else: self._original_max_pack_count = None # Make groupcompress use the fast algorithm during importing. # We want to repack at the end anyhow when more information # is available to do a better job of saving space. try: from bzrlib import groupcompress groupcompress._FAST = True except ImportError: pass # Create a write group. This is committed at the end of the import. # Checkpointing closes the current one and starts a new one. self.repo.start_write_group()
def __init__(self, source, outf, ref=None, checkpoint=-1, import_marks_file=None, export_marks_file=None, revision=None, verbose=False, plain_format=False, rewrite_tags=False, no_tags=False, baseline=False): """Export branch data in fast import format. :param plain_format: if True, 'classic' fast-import format is used without any extended features; if False, the generated data is richer and includes information like multiple authors, revision properties, etc. :param rewrite_tags: if True and if plain_format is set, tag names will be rewritten to be git-compatible. Otherwise tags which aren't valid for git will be skipped if plain_format is set. :param no_tags: if True tags won't be exported at all """ self.branch = source self.outf = outf self.ref = ref self.checkpoint = checkpoint self.import_marks_file = import_marks_file self.export_marks_file = export_marks_file self.revision = revision self.excluded_revisions = set() self.plain_format = plain_format self.rewrite_tags = rewrite_tags self.no_tags = no_tags self.baseline = baseline self._multi_author_api_available = hasattr(bzrlib.revision.Revision, 'get_apparent_authors') self.properties_to_exclude = ['authors', 'author'] # Progress reporting stuff self.verbose = verbose if verbose: self.progress_every = 100 else: self.progress_every = 1000 self._start_time = time.time() self._commit_total = 0 # Load the marks and initialise things accordingly self.revid_to_mark = {} self.branch_names = {} if self.import_marks_file: marks_info = marks_file.import_marks(self.import_marks_file) if marks_info is not None: self.revid_to_mark = dict((r, m) for m, r in marks_info.items())