# HG changeset patch # User eugene.petrenko@jetbrains.com # Date 1389636197 -3600 # Node ID 0607a050412982a28351a5c301f0a55d5070830d # Parent be86907926ae5d18db439b022c6e12e2cdbe0e5f simplify code, handle delete of .hgsub* files fix files state hash map (there were incorrect ID used) diff -r be86907926ae -r 0607a0504129 mercurial-common/src/python/load-substates-command.py --- a/mercurial-common/src/python/load-substates-command.py Mon Jan 13 18:51:13 2014 +0100 +++ b/mercurial-common/src/python/load-substates-command.py Mon Jan 13 19:03:17 2014 +0100 @@ -50,33 +50,26 @@ commit_to_substates = {} def update_sub_states(ctx): - def filenode(ctx, filename): + def filenode(ctx, filename, i): if filename in ctx.files(): try: return node.hex(ctx.filenode(filename)) except: # file could have been deleted => so there would be no filenode for it + # this also means we should avoid parents as file source return NONE else: - return NONE - - def notnull(a, ctx, i): - if a != NONE: - return a - - for p in ctx.parents(): - if commit_to_substates.has_key(p): - v = commit_to_substates[p][i] - if v != NONE: - return v + for p in ctx.parents(): + if commit_to_substates.has_key(p.hex()): + v = commit_to_substates[p.hex()][i] + if v != NONE: + return v return NONE - best_sub = notnull(filenode(ctx, ".hgsub"), ctx, 0) - best_state = notnull(filenode(ctx, ".hgsubstate"), ctx, 1) - - commit_to_substates[ctx.node()] = (best_sub, best_state) - - return (best_sub, best_state) + best_sub = filenode(ctx, ".hgsub", 0) + best_state = filenode(ctx, ".hgsubstate", 1) + commit_to_substates[ctx.hex()] = (best_sub, best_state) + return best_sub, best_state for r in list(repo.changelog): ctx = repo[r]