changeset 716:0607a0504129

simplify code, handle delete of .hgsub* files fix files state hash map (there were incorrect ID used)
author eugene.petrenko@jetbrains.com
date Mon, 13 Jan 2014 19:03:17 +0100
parents be86907926ae
children c37903906fad
files mercurial-common/src/python/load-substates-command.py
diffstat 1 files changed, 11 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- 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]