Beispiel #1
0
  def _get_source_groups(self, svn_commit):
    """Return groups of sources for SVN_COMMIT.

    SVN_COMMIT is an instance of SVNSymbolCommit.  Yield tuples
    (source_lod, svn_revnum, cvs_symbols) where source_lod is the line
    of development and svn_revnum is the revision that should serve as
    a source, and cvs_symbols is a list of CVSSymbolItems that can be
    copied from that source.  The groups are returned in arbitrary
    order."""

    # Get a map {CVSSymbol : SVNRevisionRange}:
    range_map = self._symbolings_reader.get_range_map(svn_commit)

    # range_map, split up into one map per LOD; i.e., {LOD :
    # {CVSSymbol : SVNRevisionRange}}:
    lod_range_maps = {}

    for (cvs_symbol, range) in range_map.iteritems():
      lod_range_map = lod_range_maps.get(range.source_lod)
      if lod_range_map is None:
        lod_range_map = {}
        lod_range_maps[range.source_lod] = lod_range_map
      lod_range_map[cvs_symbol] = range

    for (lod, lod_range_map) in lod_range_maps.iteritems():
      while lod_range_map:
        revision_scores = RevisionScores(lod_range_map.values())
        (source_lod, revnum, score) = revision_scores.get_best_revnum()
        assert source_lod == lod
        cvs_symbols = []
        for (cvs_symbol, range) in lod_range_map.items():
          if revnum in range:
            cvs_symbols.append(cvs_symbol)
            del lod_range_map[cvs_symbol]
        yield (lod, revnum, cvs_symbols)
Beispiel #2
0
    def _get_source_groups(self, svn_commit):
        """Return groups of sources for SVN_COMMIT.

    SVN_COMMIT is an instance of SVNSymbolCommit.  Yield tuples
    (source_lod, svn_revnum, cvs_symbols) where source_lod is the line
    of development and svn_revnum is the revision that should serve as
    a source, and cvs_symbols is a list of CVSSymbolItems that can be
    copied from that source.  The groups are returned in arbitrary
    order."""

        # Get a map {CVSSymbol : SVNRevisionRange}:
        range_map = self._symbolings_reader.get_range_map(svn_commit)

        # range_map, split up into one map per LOD; i.e., {LOD :
        # {CVSSymbol : SVNRevisionRange}}:
        lod_range_maps = {}

        for (cvs_symbol, range) in range_map.iteritems():
            lod_range_map = lod_range_maps.get(range.source_lod)
            if lod_range_map is None:
                lod_range_map = {}
                lod_range_maps[range.source_lod] = lod_range_map
            lod_range_map[cvs_symbol] = range

        for (lod, lod_range_map) in lod_range_maps.iteritems():
            while lod_range_map:
                revision_scores = RevisionScores(lod_range_map.values())
                (source_lod, revnum, score) = revision_scores.get_best_revnum()
                assert source_lod == lod
                cvs_symbols = []
                for (cvs_symbol, range) in lod_range_map.items():
                    if revnum in range:
                        cvs_symbols.append(cvs_symbol)
                        del lod_range_map[cvs_symbol]
                yield (lod, revnum, cvs_symbols)
Beispiel #3
0
    def compute_best_source(self, preferred_source):
        """Determine the best source_lod and subversion revision number to copy.

    Return the best source found, as an SVNRevisionRange instance.  If
    PREFERRED_SOURCE is not None and its opening is among the sources
    with the best scores, return it; otherwise, return the oldest such
    revision on the first such source_lod (ordered by the natural LOD
    sort order).  The return value's source_lod is the best LOD to
    copy from, and its opening_revnum is the best SVN revision."""

        # Aggregate openings and closings from our rev tree
        svn_revision_ranges = self._get_revision_ranges(self._node_tree)

        # Score the lists
        revision_scores = RevisionScores(svn_revision_ranges)

        best_source_lod, best_revnum, best_score = \
            revision_scores.get_best_revnum()

        if (preferred_source is not None
                and revision_scores.get_score(preferred_source) == best_score):
            best_source_lod = preferred_source.source_lod
            best_revnum = preferred_source.opening_revnum

        if best_revnum == SVN_INVALID_REVNUM:
            raise FatalError(
                "failed to find a revision to copy from when copying %s" %
                self._symbol.name)

        return SVNRevisionRange(best_source_lod, best_revnum)
Beispiel #4
0
  def compute_best_source(self, preferred_source):
    """Determine the best source_lod and subversion revision number to copy.

    Return the best source found, as an SVNRevisionRange instance.  If
    PREFERRED_SOURCE is not None and its opening is among the sources
    with the best scores, return it; otherwise, return the oldest such
    revision on the first such source_lod (ordered by the natural LOD
    sort order).  The return value's source_lod is the best LOD to
    copy from, and its opening_revnum is the best SVN revision."""

    # Aggregate openings and closings from our rev tree
    svn_revision_ranges = self._get_revision_ranges(self._node_tree)

    # Score the lists
    revision_scores = RevisionScores(svn_revision_ranges)

    best_source_lod, best_revnum, best_score = \
        revision_scores.get_best_revnum()

    if (
        preferred_source is not None
        and revision_scores.get_score(preferred_source) == best_score
        ):
      best_source_lod = preferred_source.source_lod
      best_revnum = preferred_source.opening_revnum

    if best_revnum == SVN_INVALID_REVNUM:
      raise FatalError(
          "failed to find a revision to copy from when copying %s"
          % self._symbol.name
          )

    return SVNRevisionRange(best_source_lod, best_revnum)
Beispiel #5
0
  def _get_source_groups(self, svn_commit):
    """Return groups of sources for SVN_COMMIT.

    SVN_COMMIT is an instance of SVNSymbolCommit.  Return a list of tuples
    (svn_revnum, source_lod, cvs_symbols) where svn_revnum is the revision
    that should serve as a source, source_lod is the CVS line of
    development, and cvs_symbols is a list of CVSSymbolItems that can be
    copied from that source.  The list is in arbitrary order."""

    # Get a map {CVSSymbol : SVNRevisionRange}:
    range_map = self._symbolings_reader.get_range_map(svn_commit)

    # range_map, split up into one map per LOD; i.e., {LOD :
    # {CVSSymbol : SVNRevisionRange}}:
    lod_range_maps = {}

    for (cvs_symbol, range) in range_map.iteritems():
      lod_range_map = lod_range_maps.get(range.source_lod)
      if lod_range_map is None:
        lod_range_map = {}
        lod_range_maps[range.source_lod] = lod_range_map
      lod_range_map[cvs_symbol] = range

    # Sort the sources so that the branch that serves most often as
    # parent is processed first:
    lod_ranges = lod_range_maps.items()
    lod_ranges.sort(
        lambda (lod1,lod_range_map1),(lod2,lod_range_map2):
        -cmp(len(lod_range_map1), len(lod_range_map2)) or cmp(lod1, lod2)
        )

    source_groups = []
    for (lod, lod_range_map) in lod_ranges:
      while lod_range_map:
        revision_scores = RevisionScores(lod_range_map.values())
        (source_lod, revnum, score) = revision_scores.get_best_revnum()
        assert source_lod == lod
        cvs_symbols = []
        for (cvs_symbol, range) in lod_range_map.items():
          if revnum in range:
            cvs_symbols.append(cvs_symbol)
            del lod_range_map[cvs_symbol]
        source_groups.append((revnum, lod, cvs_symbols))

    return source_groups
Beispiel #6
0
  def _get_source_groups(self, svn_commit):
    """Return groups of sources for SVN_COMMIT.

    SVN_COMMIT is an instance of SVNSymbolCommit.  Return a list of tuples
    (svn_revnum, source_lod, cvs_symbols) where svn_revnum is the revision
    that should serve as a source, source_lod is the CVS line of
    development, and cvs_symbols is a list of CVSSymbolItems that can be
    copied from that source.  The list is in arbitrary order."""

    # Get a map {CVSSymbol : SVNRevisionRange}:
    range_map = self._symbolings_reader.get_range_map(svn_commit)

    # range_map, split up into one map per LOD; i.e., {LOD :
    # {CVSSymbol : SVNRevisionRange}}:
    lod_range_maps = {}

    for (cvs_symbol, range) in range_map.iteritems():
      lod_range_map = lod_range_maps.get(range.source_lod)
      if lod_range_map is None:
        lod_range_map = {}
        lod_range_maps[range.source_lod] = lod_range_map
      lod_range_map[cvs_symbol] = range

    # Sort the sources so that the branch that serves most often as
    # parent is processed first:
    lod_ranges = lod_range_maps.items()
    lod_ranges.sort(
        lambda (lod1,lod_range_map1),(lod2,lod_range_map2):
        -cmp(len(lod_range_map1), len(lod_range_map2)) or cmp(lod1, lod2)
        )

    source_groups = []
    for (lod, lod_range_map) in lod_ranges:
      while lod_range_map:
        revision_scores = RevisionScores(lod_range_map.values())
        (source_lod, revnum, score) = revision_scores.get_best_revnum()
        assert source_lod == lod
        cvs_symbols = []
        for (cvs_symbol, range) in lod_range_map.items():
          if revnum in range:
            cvs_symbols.append(cvs_symbol)
            del lod_range_map[cvs_symbol]
        source_groups.append((revnum, lod, cvs_symbols))

    return source_groups