anchor.diff:  add_to_backups(Files) ->
       gen_server:cast(wrangler_backup_server, {add_backups, Files}).
   
  +%% recover backups for the whole composite refactoring.
   recover_backups() ->
       gen_server:call(wrangler_backup_server, recover_backups).
   
  +%% recover backups for an atomic composite refactoring.
  +rollback_atomic_cr(Pid) ->
  +    gen_server:call(wrangler_backup_server, {rollback_atomic_cr, Pid}).
  +
   reset_backups()->
       gen_server:cast(wrangler_backup_server, reset_backups).
  +
  +add_atomic_cr_start_point(Pid)->
  +    gen_server:cast(wrangler_backup_server, {atomic_cr_starts, Pid}).
   %%====================================================================
   %% gen_server callbacks
   %%====================================================================
  
positive.code: -behaviour(gen_server).
  
  %% API
  -export([start_backup_server/0,add_to_backups/1, recover_backups/0, reset_backups/0]).
  
  %% gen_server callbacks
  -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
  
negative.code: %%                                      {stop, Reason, State}
  %% Description: Handling call messages
  %%--------------------------------------------------------------------
  handle_call(recover_backups, _From, _State=#state{backups=BackUps})->
      PreviewPairs = do_recover_backups(BackUps),
      {reply, {ok, PreviewPairs}, #state{}};
  handle_call({rollback_atomic_cr, Pid}, _From, State=#state{backups=BackUps}) ->
      case lists:member(Pid, BackUps) of
          false ->
              {reply, {ok, []}, State};
          true->
              {BackUps1, BackUps2} = lists:splitwith(fun(E)-> E/=Pid end, BackUps),
              lists:foreach(fun({{FileName, NewFileName, IsNew}, Content})->
                                    case IsNew of 
                                        true -> file:delete_file(NewFileName);
                                        false ->
                                            file:write_file(FileName, Content)
                                     end
                             end, BackUps1),
               {reply, {ok, []}, State#state{backups=tl(BackUps2)}}
       end.
  
  
  handle_cast(reset_backups, _State) ->
       {noreply, #state{}};
  handle_cast({add_backups,Files},State=#state{backups=BackUps}) ->
       NewBackUps = update_backups(Files, BackUps),
       {noreply, State#state{backups=NewBackUps}};
  handle_cast({atomic_cr_starts, Pid}, State=#state{backups=BackUps})->
       {noreply, State#state{backups=[Pid|BackUps]}}.
  
  
  update_backups([], BackUps) ->
      BackUps;
  update_backups([{FileName, NewFileName}|Fs], BackUps) ->
      update_backups([{FileName, NewFileName, false}|Fs], BackUps);
  update_backups([{FileName, NewFileName, true}|Fs], BackUps) ->
      update_backups(Fs, [{{FileName, NewFileName, true}, none}|BackUps]);
  update_backups([{FileName, NewFileName, false}|Fs], BackUps) ->
       {ok, Content} = file:read_file(FileName),
       update_backups(Fs, [{{FileName, NewFileName, false}, Content}|BackUps]).
  
  do_recover_backups(BackUps) ->
      do_recover_backups(lists:reverse(BackUps), [], []).
  do_recover_backups([], PreviewPairs, _RecoverdFiles) ->
       PreviewPairs;
  do_recover_backups([Pid|Fs], PreviewPairs, RecoveredFiles) when is_pid(Pid) ->
      do_recover_backups(Fs, PreviewPairs, RecoveredFiles);
  do_recover_backups([{{FileName, NewFileName, false}, Content}|Fs], PreviewPairs, RecoveredFiles) ->
      SwpFileName = filename:join([filename:rootname(NewFileName) ++ ".erl.swp"]),
      case filelib:is_regular(SwpFileName) of 
          true -> 
              %% make sure only the lastest version is copied to the .swp file.
              ok;
          _ ->
              file:copy(FileName, SwpFileName) 
      end,
      %% make sure only the oldest version is copied to the file.
      NewRecoveredFiles=case lists:member(FileName, RecoveredFiles) of 
                            true ->
                                RecoveredFiles;
                            false ->
                                file:write_file(FileName, Content),
                                [FileName|RecoveredFiles]
                        end,
      NewPreviewPairs=update_preview_pairs({FileName, NewFileName, SwpFileName}, PreviewPairs),
      do_recover_backups(Fs, NewPreviewPairs, NewRecoveredFiles);  
  do_recover_backups([{{FileName, NewFileName, true}, _Content}|Fs], PreviewPairs,RecoveredFiles) ->
      SwpFileName = filename:join([filename:rootname(NewFileName) ++ ".erl.swp"]),
      file:copy(FileName, SwpFileName),
      NewPreviewPairs=[{{FileName, NewFileName, true}, SwpFileName}|PreviewPairs],
      do_recover_backups(Fs, NewPreviewPairs,[FileName| RecoveredFiles]).
  
  update_preview_pairs({FileName, NewFileName, SwpFileName},PreviewPairs) ->
      case [FName||{{_F, FName, _IsNew},_Swp}<-PreviewPairs, FName==FileName] of 
          [] -> [{{FileName, NewFileName, false}, SwpFileName}|PreviewPairs];
          _ ->
  