anchor.diff:          ProjectApps = rebar_state:project_apps(State),
   
           {Apps, State1} =
  -            lists:foldl(fun(Profile, {AppsAcc, StateAcc}) ->
  -                                Locks = rebar_state:get(StateAcc, {locks, Profile}, []),
  -                                {ok, NewApps, NewState} =
  -                                    handle_deps(Profile
  -                                               ,StateAcc
  -                                               ,rebar_state:get(StateAcc, {deps, Profile}, [])
  -                                               ,Locks),
  -                                {NewApps++AppsAcc, NewState}
  -                        end, {[], State}, lists:reverse(Profiles)),
  +            lists:foldl(fun deps_per_profile/2, {[], State}, lists:reverse(Profiles)),
   
           Source = ProjectApps ++ Apps,
           case find_cycles(Source) of
  
positive.code:                     end
              end
      end.
  
  -spec parse_deps(binary(), list(), list(), list(), integer()) -> {[rebar_app_info:t()], [pkg_dep()]}.
  parse_deps(DepsDir, Deps, State, Locks, Level) ->
  
negative.code: 
  -spec update_src_deps(atom(), non_neg_integer(), list(), list(), list(), rebar_state:t(), boolean(), sets:set(binary()), list()) -> {rebar_state:t(), list(), list(), sets:set(binary())}.
  update_src_deps(Profile, Level, SrcDeps, PkgDeps, SrcApps, State, Upgrade, Seen, Locks) ->
      case lists:foldl(
              fun(AppInfo, {SrcDepsAcc, PkgDepsAcc, SrcAppsAcc, StateAcc, SeenAcc, LocksAcc}) ->
                      update_src_dep(AppInfo, Profile, Level,
                                     SrcDepsAcc, PkgDepsAcc, SrcAppsAcc, StateAcc,
                                     Upgrade, SeenAcc, Locks, LocksAcc)
              end,
              {[], PkgDeps, SrcApps, State, Seen, Locks},
              rebar_utils:sort_deps(SrcDeps)) of
          {[], NewPkgDeps, NewSrcApps, State1, Seen1, _NewLocks} ->
              {State1, NewSrcApps, NewPkgDeps, Seen1};
          {NewSrcDeps, NewPkgDeps, NewSrcApps, State1, Seen1, NewLocks} ->
              update_src_deps(Profile, Level+1, NewSrcDeps, NewPkgDeps, NewSrcApps, State1, Upgrade, Seen1, NewLocks)
      end.
  
  update_src_dep(AppInfo, Profile, Level, SrcDeps, PkgDeps, SrcApps, State, Upgrade, Seen, BaseLocks, Locks) ->
      %% If not seen, add to list of locks to write out
      Name = rebar_app_info:name(AppInfo),
      case sets:is_element(Name, Seen) of
          true ->
              update_seen_src_dep(AppInfo, Level,
                                  SrcDeps, PkgDeps, SrcApps,
                                  State, Upgrade, Seen, BaseLocks, Locks);
          false ->
              update_unseen_src_dep(AppInfo, Profile, Level,
                                    SrcDeps, PkgDeps, SrcApps,
                                    State, Upgrade, Seen, Locks)
  
      end.
  
  update_seen_src_dep(AppInfo, Level, SrcDeps, PkgDeps, SrcApps, State, Upgrade, Seen, BaseLocks, Locks) ->
      Name = rebar_app_info:name(AppInfo),
      %% If seen from lock file don't print warning about skipping
      case lists:keymember(Name, 1, BaseLocks) of
          false ->
              warn_skip_deps(AppInfo);
          true ->
              ok
      end,
      %% scan for app children here if upgrading
      case Upgrade of
          false ->
              {SrcDeps, PkgDeps, SrcApps, State, Seen, Locks};
          true ->
              {NewSrcDeps, NewPkgDeps, NewSrcApps, NewState, NewLocks}
              = handle_dep(AppInfo, SrcDeps, PkgDeps, SrcApps,
                           Level, State, Locks),
              {NewSrcDeps, NewPkgDeps, NewSrcApps, NewState, Seen, NewLocks}
      end.
  
  update_unseen_src_dep(AppInfo, Profile, Level, SrcDeps, PkgDeps, SrcApps, State, Upgrade, Seen, Locks) ->
      {NewSeen, State1} = maybe_lock(Profile, AppInfo, Seen, State, Level),
      {NewSrcDeps, NewPkgDeps, NewSrcApps, State2, NewLocks}
      = case Upgrade of
          true ->
              handle_upgrade(AppInfo, SrcDeps, PkgDeps, SrcApps,
                             Level, State1, Locks);
          _ ->
              %% why do we use the old state there?
              maybe_fetch(AppInfo, false, Seen, State),
              handle_dep(AppInfo, SrcDeps, PkgDeps, SrcApps,
                         Level, State1, Locks)
      end,
      {NewSrcDeps, NewPkgDeps, NewSrcApps, State2, NewSeen, NewLocks}.
  
  handle_upgrade(AppInfo, SrcDeps, PkgDeps, SrcApps, Level, State, Locks) ->
      Name = rebar_app_info:name(AppInfo),
      case lists:keyfind(Name, 1, Locks) of
          false ->
              case maybe_fetch(AppInfo, true, sets:new(), State) of
                  true ->
                      handle_dep(AppInfo, SrcDeps, PkgDeps, SrcApps,
                                 Level, State, Locks);
  
                  false ->
                      {[AppInfo|SrcDeps], PkgDeps, SrcApps, State, Locks}
  