Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d4b9e01f authored by Tao Bao's avatar Tao Bao Committed by Gerrit Code Review
Browse files

Merge "releasetools: Remove RemoveBackwardEdges()."

parents 81421ccf 5bab0dd1
Loading
Loading
Loading
Loading
+2 −48
Original line number Diff line number Diff line
@@ -270,7 +270,6 @@ class ImgdiffStats(object):
  USED_IMGDIFF_LARGE_APK = "Large APK files split and diff'd with imgdiff"

  # Reasons for not applying imgdiff on APKs.
  SKIPPED_TRIMMED = "Not used imgdiff due to trimmed RangeSet"
  SKIPPED_NONMONOTONIC = "Not used imgdiff due to having non-monotonic ranges"
  SKIPPED_SHARED_BLOCKS = "Not used imgdiff due to using shared blocks"
  SKIPPED_INCOMPLETE = "Not used imgdiff due to incomplete RangeSet"
@@ -279,7 +278,6 @@ class ImgdiffStats(object):
  REASONS = (
      USED_IMGDIFF,
      USED_IMGDIFF_LARGE_APK,
      SKIPPED_TRIMMED,
      SKIPPED_NONMONOTONIC,
      SKIPPED_SHARED_BLOCKS,
      SKIPPED_INCOMPLETE,
@@ -449,10 +447,6 @@ class BlockImageDiff(object):
      self.imgdiff_stats.Log(name, ImgdiffStats.SKIPPED_INCOMPLETE)
      return False

    if tgt_ranges.extra.get('trimmed') or src_ranges.extra.get('trimmed'):
      self.imgdiff_stats.Log(name, ImgdiffStats.SKIPPED_TRIMMED)
      return False

    reason = (ImgdiffStats.USED_IMGDIFF_LARGE_APK if large_apk
              else ImgdiffStats.USED_IMGDIFF)
    self.imgdiff_stats.Log(name, reason)
@@ -836,14 +830,10 @@ class BlockImageDiff(object):
                  str(xf.tgt_ranges), str(xf.src_ranges)))
          else:
            if xf.patch:
              # We have already generated the patch with imgdiff. Check if the
              # transfer is intact.
              # We have already generated the patch with imgdiff, while
              # splitting large APKs (i.e. in FindTransfers()).
              assert not self.disable_imgdiff
              imgdiff = True
              if (xf.src_ranges.extra.get('trimmed') or
                  xf.tgt_ranges.extra.get('trimmed')):
                imgdiff = False
                xf.patch = None
            else:
              imgdiff = self.CanUseImgdiff(
                  xf.tgt_name, xf.tgt_ranges, xf.src_ranges)
@@ -1045,42 +1035,6 @@ class BlockImageDiff(object):
    for i, xf in enumerate(L):
      xf.order = i

  def RemoveBackwardEdges(self):
    print("Removing backward edges...")
    in_order = 0
    out_of_order = 0
    lost_source = 0

    for xf in self.transfers:
      lost = 0
      size = xf.src_ranges.size()
      for u in xf.goes_before:
        # xf should go before u
        if xf.order < u.order:
          # it does, hurray!
          in_order += 1
        else:
          # it doesn't, boo.  trim the blocks that u writes from xf's
          # source, so that xf can go after u.
          out_of_order += 1
          assert xf.src_ranges.overlaps(u.tgt_ranges)
          xf.src_ranges = xf.src_ranges.subtract(u.tgt_ranges)
          xf.src_ranges.extra['trimmed'] = True

      if xf.style == "diff" and not xf.src_ranges:
        # nothing left to diff from; treat as new data
        xf.style = "new"

      lost = size - xf.src_ranges.size()
      lost_source += lost

    print(("  %d/%d dependencies (%.2f%%) were violated; "
           "%d source blocks removed.") %
          (out_of_order, in_order + out_of_order,
           (out_of_order * 100.0 / (in_order + out_of_order))
           if (in_order + out_of_order) else 0.0,
           lost_source))

  def ReverseBackwardEdges(self):
    """Reverse unsatisfying edges and compute pairs of stashed blocks.

+3 −11
Original line number Diff line number Diff line
@@ -229,13 +229,6 @@ class BlockImageDiffTest(unittest.TestCase):
            "/system/app/app2.apk", RangeSet("10-15"),
            RangeSet("15-20 30 10-14")))

    # At least one of the ranges has been modified.
    src_ranges = RangeSet("0-5")
    src_ranges.extra['trimmed'] = True
    self.assertFalse(
        block_image_diff.CanUseImgdiff(
            "/vendor/app/app3.apk", RangeSet("10-15"), src_ranges))

    # At least one of the ranges is incomplete.
    src_ranges = RangeSet("0-5")
    src_ranges.extra['incomplete'] = True
@@ -247,7 +240,6 @@ class BlockImageDiffTest(unittest.TestCase):
    self.assertDictEqual(
        {
            ImgdiffStats.SKIPPED_NONMONOTONIC: {'/system/app/app2.apk'},
            ImgdiffStats.SKIPPED_TRIMMED : {'/vendor/app/app3.apk'},
            ImgdiffStats.SKIPPED_INCOMPLETE: {'/vendor/app/app4.apk'},
        },
        block_image_diff.imgdiff_stats.stats)