def _update_branch(self, br, last_mark):
        """Update a branch with last revision and tag information.

        :return: whether the branch was changed or not
        """
        from fastimport.helpers import single_plural
        last_rev_id = self.cache_mgr.lookup_committish(last_mark)
        self.repo.lock_read()
        try:
            graph = self.repo.get_graph()
            revno = graph.find_distance_to_null(last_rev_id, [])
        finally:
            self.repo.unlock()
        existing_revno, existing_last_rev_id = br.last_revision_info()
        changed = False
        if revno != existing_revno or last_rev_id != existing_last_rev_id:
            br.set_last_revision_info(revno, last_rev_id)
            changed = True
        # apply tags known in this branch
        my_tags = {}
        if self.tags:
            graph = self.repo.get_graph()
            ancestry = [r for (r, ps) in graph.iter_ancestry([last_rev_id]) if ps is not None]
            for tag,rev in self.tags.items():
                if rev in ancestry:
                    my_tags[tag] = rev
            if my_tags:
                br.tags._set_tag_dict(my_tags)
                changed = True
        if changed:
            tagno = len(my_tags)
            note("\t branch %s now has %d %s and %d %s", br.nick,
                revno, single_plural(revno, "revision", "revisions"),
                tagno, single_plural(tagno, "tag", "tags"))
        return changed
 def dump_stats(self):
     time_required = progress.str_tdelta(time.time() - self._start_time)
     rc = self._revision_count - self.skip_total
     bc = self._branch_count
     wtc = self._tree_count
     self.note("Imported %d %s, updating %d %s and %d %s in %s",
         rc, helpers.single_plural(rc, "revision", "revisions"),
         bc, helpers.single_plural(bc, "branch", "branches"),
         wtc, helpers.single_plural(wtc, "tree", "trees"),
         time_required)
Exemple #3
0
    def _show_stats_for(self, dict, label, note=trace.note, tuple_key=False):
        """Dump statistics about a given dictionary.

        By the key and value need to support len().
        """
        count = len(dict)
        if tuple_key:
            size = sum(map(len, (''.join(k) for k in dict.keys())))
        else:
            size = sum(map(len, dict.keys()))
        size += sum(map(len, dict.values()))
        size = size * 1.0 / 1024
        unit = 'K'
        if size > 1024:
            size = size / 1024
            unit = 'M'
            if size > 1024:
                size = size / 1024
                unit = 'G'
        note("    %-12s: %8.1f %s (%d %s)" % (label, size, unit, count,
            single_plural(count, "item", "items")))
Exemple #4
0
 def dump_stats(self):
     time_required = progress.str_tdelta(time.time() - self._start_time)
     rc = len(self.revid_to_mark)
     self.note("Exported %d %s in %s",
         rc, single_plural(rc, "revision", "revisions"),
         time_required)