def _find_shallow(store, heads, depth):
 parents = {}
 def get_parents(sha):
  result = parents.get(sha, None)
  if (not result):
   result = store[sha].parents
   parents[sha] = result
  return result
 todo = []
 for head_sha in heads:
  obj = store.peel_sha(head_sha)
  if isinstance(obj, Commit):
   todo.append((obj.id, 1))
 not_shallow = set()
 shallow = set()
 while todo:
  (sha, cur_depth) = todo.pop()
  if (cur_depth < depth):
   not_shallow.add(sha)
   new_depth = (cur_depth + 1)
   todo.extend(((p, new_depth) for p in get_parents(sha)))
  else:
   shallow.add(sha)
 return (shallow, not_shallow)

def _find_shallow ( store , heads , depth ) : parents = { } def get_parents ( sha ) : result = parents . get ( sha , None ) if ( not result ) : result = store [ sha ] . parents parents [ sha ] = result return result todo = [ ] for head_sha in heads : obj = store . peel_sha ( head_sha ) if isinstance ( obj , Commit ) : todo . append ( ( obj . id , 1 ) ) not_shallow = set ( ) shallow = set ( ) while todo : ( sha , cur_depth ) = todo . pop ( ) if ( cur_depth < depth ) : not_shallow . add ( sha ) new_depth = ( cur_depth + 1 ) todo . extend ( ( ( p , new_depth ) for p in get_parents ( sha ) ) ) else : shallow . add ( sha ) return ( shallow , not_shallow )
find shallow commits according to a given depth .