FreeBSD/contrib/subversion/subversion/libsvn_wc/wc_db_update_move.c
/* Edit the file found at the move destination, which is initially at
 * the old state.  Merge the changes into the "working"/"actual" file.
 *
 * Merge the difference between OLD_VERSION and NEW_VERSION into
 * the working file at LOCAL_RELPATH.
 *
 * The term 'old' refers to the pre-update state, which is the state of
 * (some layer of) LOCAL_RELPATH while this function runs; and 'new'
 * refers to the post-update state, as found at the (base layer of) the
 * move source path while this function runs.
 *
 * LOCAL_RELPATH is a file in the working copy at WCROOT in DB, and
 * REPOS_RELPATH is the repository path it would be committed to.
 *
 * Use NOTIFY_FUNC and NOTIFY_BATON for notifications.
 * Set *WORK_ITEMS to any required work items, allocated in RESULT_POOL.
 * Use SCRATCH_POOL for temporary allocations. */
Edit the file found at the move destination, which is initially at
the old state.  Merge the changes into the "working"/"actual" file.

Merge the difference between OLD_VERSION and NEW_VERSION into
the working file at LOCAL_RELPATH.

The term 'old' refers to the pre-update state, which is the state of
(some layer of) LOCAL_RELPATH while this function runs; and 'new'
refers to the post-update state, as found at the (base layer of) the
move source path while this function runs.

LOCAL_RELPATH is a file in the working copy at WCROOT in DB, and
REPOS_RELPATH is the repository path it would be committed to.


Edit the file found at the move destination which is initially at the old state . Merge the changes into the " working " / " actual " file . Merge the difference between OLD_VERSION and NEW_VERSION into the working file at LOCAL_RELPATH . The term ' old ' refers to the pre - update state which is the state of ( some layer of ) LOCAL_RELPATH while this function runs ; and ' new ' refers to the post - update state as found at the ( base layer of ) the move source path while this function runs . LOCAL_RELPATH is a file in the working copy at WCROOT in DB and REPOS_RELPATH is the repository path it would be committed to .
static svn_error_t *
tc_editor_alter_file(node_move_baton_t *nmb,
                     const char *dst_relpath,
                     const svn_checksum_t *old_checksum,
                     const svn_checksum_t *new_checksum,
                     apr_hash_t *old_props,
                     apr_hash_t *new_props,
                     apr_pool_t *scratch_pool)
{
  update_move_baton_t *b = nmb->umb;
  working_node_version_t old_version, new_version;
  const char *local_abspath = svn_dirent_join(b->wcroot->abspath,
                                              dst_relpath,
                                              scratch_pool);
  const char *old_pristine_abspath;
  const char *new_pristine_abspath;
  svn_skel_t *conflict_skel = NULL;
  apr_hash_t *actual_props;
  apr_array_header_t *propchanges;
  enum svn_wc_merge_outcome_t merge_outcome;
  svn_wc_notify_state_t prop_state, content_state;
  svn_skel_t *work_item, *work_items = NULL;
  svn_node_kind_t wc_kind;
  svn_boolean_t obstructed = FALSE;
  SVN_ERR(mark_node_edited(nmb, scratch_pool));
  if (nmb->skip)
    return SVN_NO_ERROR;
  SVN_ERR(svn_io_check_path(local_abspath, &wc_kind, scratch_pool));
  if (wc_kind != svn_node_none && wc_kind != svn_node_file)
    {
      SVN_ERR(create_node_tree_conflict(&conflict_skel, nmb, dst_relpath,
                                        svn_node_file, svn_node_file,
                                        svn_wc_conflict_reason_obstructed,
                                        svn_wc_conflict_action_edit,
                                        NULL,
                                        scratch_pool, scratch_pool));
      obstructed = TRUE;
    }
  old_version.location_and_kind = b->old_version;
  new_version.location_and_kind = b->new_version;
  old_version.checksum = old_checksum;
  old_version.props = old_props;
  new_version.checksum = new_checksum;
  new_version.props = new_props;
  SVN_ERR(update_working_props(&prop_state, &conflict_skel, &propchanges,
                               &actual_props, b, dst_relpath,
                               &old_version, &new_version,
                               scratch_pool, scratch_pool));
  if (!obstructed
      && !svn_checksum_match(new_version.checksum, old_version.checksum))
    {
      svn_boolean_t is_locally_modified;
      SVN_ERR(svn_wc__internal_file_modified_p(&is_locally_modified,
                                               b->db, local_abspath,
                                               FALSE ,
                                               scratch_pool));
      if (!is_locally_modified)
        {
          SVN_ERR(svn_wc__wq_build_file_install(&work_item, b->db,
                                                local_abspath,
                                                NULL,
                                                FALSE ,
                                                TRUE  ,
                                                scratch_pool, scratch_pool));
          work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
          content_state = svn_wc_notify_state_changed;
        }
      else
        {
          SVN_ERR(svn_wc__db_pristine_get_path(&old_pristine_abspath,
                                               b->db, b->wcroot->abspath,
                                               old_version.checksum,
                                               scratch_pool, scratch_pool));
          SVN_ERR(svn_wc__db_pristine_get_path(&new_pristine_abspath,
                                               b->db, b->wcroot->abspath,
                                               new_version.checksum,
                                               scratch_pool, scratch_pool));
          SVN_ERR(svn_wc__internal_merge(&work_item, &conflict_skel,
                                         &merge_outcome, b->db,
                                         old_pristine_abspath,
                                         new_pristine_abspath,
                                         local_abspath,
                                         local_abspath,
                                         NULL, NULL, NULL, 
                                         actual_props,
                                         FALSE, 
                                         NULL, 
                                         NULL, 
                                         propchanges,
                                         b->cancel_func, b->cancel_baton,
                                         scratch_pool, scratch_pool));
          work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
          if (merge_outcome == svn_wc_merge_conflict)
            content_state = svn_wc_notify_state_conflicted;
          else
            content_state = svn_wc_notify_state_merged;
        }
    }
  else
    content_state = svn_wc_notify_state_unchanged;
  if (conflict_skel)
    {
      const char *move_dst_repos_relpath;
      SVN_ERR(svn_wc__db_depth_get_info(NULL, NULL, NULL,
                                        &move_dst_repos_relpath, NULL, NULL,
                                        NULL, NULL, NULL, NULL, NULL, NULL,
                                        NULL,
                                        b->wcroot, dst_relpath,
                                        b->dst_op_depth,
                                        scratch_pool, scratch_pool));
      SVN_ERR(create_conflict_markers(&work_item, local_abspath, b->db,
                                      move_dst_repos_relpath, conflict_skel,
                                      b->operation, &old_version, &new_version,
                                      svn_node_file, !obstructed,
                                      scratch_pool, scratch_pool));
      work_items = svn_wc__wq_merge(work_items, work_item, scratch_pool);
    }
  SVN_ERR(update_move_list_add(b->wcroot, dst_relpath, b->db,
                               svn_wc_notify_update_update,
                               svn_node_file,
                               content_state,
                               prop_state,
                               conflict_skel, work_items, scratch_pool));
  return SVN_NO_ERROR;
}
static svn_error_t * tc_editor_alter_file ( node_move_baton_t * nmb , const char * dst_relpath , const svn_checksum_t * old_checksum , const svn_checksum_t * new_checksum , apr_hash_t * old_props , apr_hash_t * new_props , apr_pool_t * scratch_pool ) { update_move_baton_t * b = nmb -> umb ; working_node_version_t old_version , new_version ; const char * local_abspath = svn_dirent_join ( b -> wcroot -> abspath , dst_relpath , scratch_pool ) ; const char * old_pristine_abspath ; const char * new_pristine_abspath ; svn_skel_t * conflict_skel = NULL ; apr_hash_t * actual_props ; apr_array_header_t * propchanges ; enum svn_wc_merge_outcome_t merge_outcome ; svn_wc_notify_state_t prop_state , content_state ; svn_skel_t * work_item , * work_items = NULL ; svn_node_kind_t wc_kind ; svn_boolean_t obstructed = FALSE ; SVN_ERR ( mark_node_edited ( nmb , scratch_pool ) ) ; if ( nmb -> skip ) return SVN_NO_ERROR ; SVN_ERR ( svn_io_check_path ( local_abspath , & wc_kind , scratch_pool ) ) ; if ( wc_kind != svn_node_none && wc_kind != svn_node_file ) { SVN_ERR ( create_node_tree_conflict ( & conflict_skel , nmb , dst_relpath , svn_node_file , svn_node_file , svn_wc_conflict_reason_obstructed , svn_wc_conflict_action_edit , NULL , scratch_pool , scratch_pool ) ) ; obstructed = TRUE ; } old_version . location_and_kind = b -> old_version ; new_version . location_and_kind = b -> new_version ; old_version . checksum = old_checksum ; old_version . props = old_props ; new_version . checksum = new_checksum ; new_version . props = new_props ; SVN_ERR ( update_working_props ( & prop_state , & conflict_skel , & propchanges , & actual_props , b , dst_relpath , & old_version , & new_version , scratch_pool , scratch_pool ) ) ; if ( ! obstructed && ! svn_checksum_match ( new_version . checksum , old_version . checksum ) ) { svn_boolean_t is_locally_modified ; SVN_ERR ( svn_wc__internal_file_modified_p ( & is_locally_modified , b -> db , local_abspath , FALSE , scratch_pool ) ) ; if ( ! is_locally_modified ) { SVN_ERR ( svn_wc__wq_build_file_install ( & work_item , b -> db , local_abspath , NULL , FALSE , TRUE , scratch_pool , scratch_pool ) ) ; work_items = svn_wc__wq_merge ( work_items , work_item , scratch_pool ) ; content_state = svn_wc_notify_state_changed ; } else { SVN_ERR ( svn_wc__db_pristine_get_path ( & old_pristine_abspath , b -> db , b -> wcroot -> abspath , old_version . checksum , scratch_pool , scratch_pool ) ) ; SVN_ERR ( svn_wc__db_pristine_get_path ( & new_pristine_abspath , b -> db , b -> wcroot -> abspath , new_version . checksum , scratch_pool , scratch_pool ) ) ; SVN_ERR ( svn_wc__internal_merge ( & work_item , & conflict_skel , & merge_outcome , b -> db , old_pristine_abspath , new_pristine_abspath , local_abspath , local_abspath , NULL , NULL , NULL , actual_props , FALSE , NULL , NULL , propchanges , b -> cancel_func , b -> cancel_baton , scratch_pool , scratch_pool ) ) ; work_items = svn_wc__wq_merge ( work_items , work_item , scratch_pool ) ; if ( merge_outcome == svn_wc_merge_conflict ) content_state = svn_wc_notify_state_conflicted ; else content_state = svn_wc_notify_state_merged ; } } else content_state = svn_wc_notify_state_unchanged ; if ( conflict_skel ) { const char * move_dst_repos_relpath ; SVN_ERR ( svn_wc__db_depth_get_info ( NULL , NULL , NULL , & move_dst_repos_relpath , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , b -> wcroot , dst_relpath , b -> dst_op_depth , scratch_pool , scratch_pool ) ) ; SVN_ERR ( create_conflict_markers ( & work_item , local_abspath , b -> db , move_dst_repos_relpath , conflict_skel , b -> operation , & old_version , & new_version , svn_node_file , ! obstructed , scratch_pool , scratch_pool ) ) ; work_items = svn_wc__wq_merge ( work_items , work_item , scratch_pool ) ; } SVN_ERR ( update_move_list_add ( b -> wcroot , dst_relpath , b -> db , svn_wc_notify_update_update , svn_node_file , content_state , prop_state , conflict_skel , work_items , scratch_pool ) ) ; return SVN_NO_ERROR ; }
Edit the file found at the move destination, which is initially at
 the old state.
Edit the file found at the move destination which is initially at the old state .
/* ### TODO: Only do this when there is no higher WORKING layer */ /* exact_comparison */ /* FIXME: use_commit_times? */ /* record_file_info */ /*
           * Run a 3-way merge to update the file, using the pre-update
           * pristine text as the merge base, the post-update pristine
           * text as the merge-left version, and the current content of the
           * moved-here working file as the merge-right version.
           */ /* diff labels */ /* dry-run */ /* diff3-cmd */ /* merge options */ /* If there are any conflicts to be stored, convert them into work items
   * too. */