releasetools: Fix a bug in ReviseStashSize().
We check the needed stash size in ReviseStashSize(), and may not generate a stash command if it would exceed the max allowed size. This CL fixes a bug when skipping a stash operation: we shouldn't update the 'stashes' map if a stash command won't be generated. Bug: 35313668 Test: Successfully generate the package that was failing due to the bug. Change-Id: If0a3a5fadda9b4a4edad66a2a5826b5f978400ae
This commit is contained in:
@@ -635,7 +635,7 @@ class BlockImageDiff(object):
|
|||||||
stash_map = {}
|
stash_map = {}
|
||||||
|
|
||||||
# Create the map between a stash and its def/use points. For example, for a
|
# Create the map between a stash and its def/use points. For example, for a
|
||||||
# given stash of (raw_id, sr), stashes[raw_id] = (sr, def_cmd, use_cmd).
|
# given stash of (raw_id, sr), stash_map[raw_id] = (sr, def_cmd, use_cmd).
|
||||||
for xf in self.transfers:
|
for xf in self.transfers:
|
||||||
# Command xf defines (stores) all the stashes in stash_before.
|
# Command xf defines (stores) all the stashes in stash_before.
|
||||||
for stash_raw_id, sr in xf.stash_before:
|
for stash_raw_id, sr in xf.stash_before:
|
||||||
@@ -672,20 +672,10 @@ class BlockImageDiff(object):
|
|||||||
# Check the post-command stashed_blocks.
|
# Check the post-command stashed_blocks.
|
||||||
stashed_blocks_after = stashed_blocks
|
stashed_blocks_after = stashed_blocks
|
||||||
if self.version == 2:
|
if self.version == 2:
|
||||||
assert stash_raw_id not in stashes
|
|
||||||
if free_stash_ids:
|
|
||||||
sid = heapq.heappop(free_stash_ids)
|
|
||||||
else:
|
|
||||||
sid = next_stash_id
|
|
||||||
next_stash_id += 1
|
|
||||||
stashes[stash_raw_id] = sid
|
|
||||||
stashed_blocks_after += sr.size()
|
stashed_blocks_after += sr.size()
|
||||||
else:
|
else:
|
||||||
sh = self.HashBlocks(self.src, sr)
|
sh = self.HashBlocks(self.src, sr)
|
||||||
if sh in stashes:
|
if sh not in stashes:
|
||||||
stashes[sh] += 1
|
|
||||||
else:
|
|
||||||
stashes[sh] = 1
|
|
||||||
stashed_blocks_after += sr.size()
|
stashed_blocks_after += sr.size()
|
||||||
|
|
||||||
if stashed_blocks_after > max_allowed:
|
if stashed_blocks_after > max_allowed:
|
||||||
@@ -695,6 +685,20 @@ class BlockImageDiff(object):
|
|||||||
replaced_cmds.append(use_cmd)
|
replaced_cmds.append(use_cmd)
|
||||||
print("%10d %9s %s" % (sr.size(), "explicit", use_cmd))
|
print("%10d %9s %s" % (sr.size(), "explicit", use_cmd))
|
||||||
else:
|
else:
|
||||||
|
# Update the stashes map.
|
||||||
|
if self.version == 2:
|
||||||
|
assert stash_raw_id not in stashes
|
||||||
|
if free_stash_ids:
|
||||||
|
sid = heapq.heappop(free_stash_ids)
|
||||||
|
else:
|
||||||
|
sid = next_stash_id
|
||||||
|
next_stash_id += 1
|
||||||
|
stashes[stash_raw_id] = sid
|
||||||
|
else:
|
||||||
|
if sh in stashes:
|
||||||
|
stashes[sh] += 1
|
||||||
|
else:
|
||||||
|
stashes[sh] = 1
|
||||||
stashed_blocks = stashed_blocks_after
|
stashed_blocks = stashed_blocks_after
|
||||||
|
|
||||||
# "move" and "diff" may introduce implicit stashes in BBOTA v3. Prior to
|
# "move" and "diff" may introduce implicit stashes in BBOTA v3. Prior to
|
||||||
|
Reference in New Issue
Block a user