~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/libsvn_client/commit_util.c

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2014-05-20 22:45:32 UTC
  • mfrom: (0.2.12)
  • Revision ID: package-import@ubuntu.com-20140520224532-4fec3gohdzyy692g
Tags: 1.8.9-1
* New upstream release
* Merge changes from Ubuntu:
  - Add DEB-8 test for Apache functionality
  - debian/rules: Create pot file on build.
  - debian/rules: Ensure the doxygen output directory exists
  - Move svn2cl to subversion-tools' Suggests on Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
892
892
  if (matches_changelists
893
893
      && (is_harvest_root || baton->changelists)
894
894
      && state_flags
895
 
      && is_added
 
895
      && (is_added || (is_deleted && is_op_root && status->copied))
896
896
      && baton->danglers)
897
897
    {
898
898
      /* If a node is added, its parent must exist in the repository at the
966
966
  void *cancel_baton;
967
967
  svn_client__check_url_kind_t check_url_func;
968
968
  void *check_url_baton;
 
969
  svn_client__committables_t *committables;
969
970
};
970
971
 
971
972
/* Helper for the commit harvesters */
972
973
static svn_error_t *
973
974
handle_descendants(void *baton,
974
 
                       const void *key, apr_ssize_t klen, void *val,
975
 
                       apr_pool_t *pool)
 
975
                   const void *key, apr_ssize_t klen, void *val,
 
976
                   apr_pool_t *pool)
976
977
{
977
978
  struct handle_descendants_baton *hdb = baton;
978
979
  apr_array_header_t *commit_items = val;
979
980
  apr_pool_t *iterpool = svn_pool_create(pool);
 
981
  const char *repos_root_url = key;
980
982
  int i;
981
983
 
982
984
  for (i = 0; i < commit_items->nelts; i++)
1002
1004
 
1003
1005
      for (j = 0; j < absent_descendants->nelts; j++)
1004
1006
        {
1005
 
          int k;
1006
 
          svn_boolean_t found_item = FALSE;
1007
1007
          svn_node_kind_t kind;
 
1008
          svn_client_commit_item3_t *desc_item;
1008
1009
          const char *relpath = APR_ARRAY_IDX(absent_descendants, j,
1009
1010
                                              const char *);
1010
1011
          const char *local_abspath = svn_dirent_join(item->path, relpath,
1011
1012
                                                      iterpool);
1012
1013
 
1013
 
          /* If the path has a commit operation, we do nothing.
1014
 
             (It will be deleted by the operation) */
1015
 
          for (k = 0; k < commit_items->nelts; k++)
1016
 
            {
1017
 
              svn_client_commit_item3_t *cmt_item =
1018
 
                 APR_ARRAY_IDX(commit_items, k, svn_client_commit_item3_t *);
1019
 
 
1020
 
              if (! strcmp(cmt_item->path, local_abspath))
1021
 
                {
1022
 
                  found_item = TRUE;
1023
 
                  break;
1024
 
                }
1025
 
            }
1026
 
 
1027
 
          if (found_item)
1028
 
            continue; /* We have an explicit delete or replace for this path */
1029
 
 
1030
1014
          /* ### Need a sub-iterpool? */
1031
1015
 
 
1016
 
 
1017
          /* We found a 'not present' descendant during a copy (at op_depth>0),
 
1018
             this is most commonly caused by copying some mixed revision tree.
 
1019
 
 
1020
             In this case not present can imply that the node does not exist
 
1021
             in the parent revision, or that the node does. But we want to copy
 
1022
             the working copy state in which it does not exist, but might be
 
1023
             replaced. */
 
1024
 
 
1025
          desc_item = svn_hash_gets(hdb->committables->by_path, local_abspath);
 
1026
 
 
1027
          /* If the path has a commit operation (possibly at an higher
 
1028
             op_depth, we might want to turn an add in a replace. */
 
1029
          if (desc_item)
 
1030
            {
 
1031
              const char *dir;
 
1032
              svn_boolean_t found_intermediate = FALSE;
 
1033
 
 
1034
              if (desc_item->state_flags & SVN_CLIENT_COMMIT_ITEM_DELETE)
 
1035
                continue; /* We already have a delete or replace */
 
1036
              else if (!(desc_item->state_flags & SVN_CLIENT_COMMIT_ITEM_ADD))
 
1037
                continue; /* Not a copy/add, just a modification */
 
1038
 
 
1039
              dir = svn_dirent_dirname(local_abspath, iterpool);
 
1040
 
 
1041
              while (strcmp(dir, item->path))
 
1042
                {
 
1043
                  svn_client_commit_item3_t *i_item;
 
1044
 
 
1045
                  i_item = svn_hash_gets(hdb->committables->by_path, dir);
 
1046
 
 
1047
                  if (i_item)
 
1048
                    {
 
1049
                      if ((i_item->state_flags & SVN_CLIENT_COMMIT_ITEM_DELETE)
 
1050
                          || (i_item->state_flags & SVN_CLIENT_COMMIT_ITEM_ADD))
 
1051
                        {
 
1052
                          found_intermediate = TRUE;
 
1053
                          break;
 
1054
                        }
 
1055
                    }
 
1056
                  dir = svn_dirent_dirname(dir, iterpool);
 
1057
                }
 
1058
 
 
1059
              if (found_intermediate)
 
1060
                continue; /* Some intermediate ancestor is an add or delete */
 
1061
 
 
1062
              /* Fall through to detect if we need to turn the add in a
 
1063
                 replace. */
 
1064
            }
 
1065
 
1032
1066
          if (hdb->check_url_func)
1033
1067
            {
1034
1068
              const char *from_url = svn_path_url_add_component2(
1045
1079
          else
1046
1080
            kind = svn_node_unknown; /* 'Ok' for a delete of something */
1047
1081
 
1048
 
          {
1049
 
            /* Add a new commit item that describes the delete */
1050
 
            apr_pool_t *result_pool = commit_items->pool;
1051
 
            svn_client_commit_item3_t *new_item
1052
 
                  = svn_client_commit_item3_create(result_pool);
1053
 
 
1054
 
            new_item->path = svn_dirent_join(item->path, relpath,
1055
 
                                             result_pool);
1056
 
            new_item->kind = kind;
1057
 
            new_item->url = svn_path_url_add_component2(item->url, relpath,
1058
 
                                                        result_pool);
1059
 
            new_item->revision = SVN_INVALID_REVNUM;
1060
 
            new_item->state_flags = SVN_CLIENT_COMMIT_ITEM_DELETE;
1061
 
            new_item->incoming_prop_changes = apr_array_make(result_pool, 1,
1062
 
                                                 sizeof(svn_prop_t *));
1063
 
 
1064
 
            APR_ARRAY_PUSH(commit_items, svn_client_commit_item3_t *)
1065
 
                  = new_item;
1066
 
          }
 
1082
          if (desc_item)
 
1083
            {
 
1084
              /* Extend the existing add/copy item to create a replace */
 
1085
              desc_item->state_flags |= SVN_CLIENT_COMMIT_ITEM_DELETE;
 
1086
              continue;
 
1087
            }
 
1088
 
 
1089
          /* Add a new commit item that describes the delete */
 
1090
 
 
1091
          SVN_ERR(add_committable(hdb->committables,
 
1092
                                  svn_dirent_join(item->path, relpath,
 
1093
                                                  iterpool),
 
1094
                                  kind,
 
1095
                                  repos_root_url,
 
1096
                                  svn_uri_skip_ancestor(
 
1097
                                        repos_root_url,
 
1098
                                        svn_path_url_add_component2(item->url,
 
1099
                                                                    relpath,
 
1100
                                                                    iterpool),
 
1101
                                        iterpool),
 
1102
                                  SVN_INVALID_REVNUM,
 
1103
                                  NULL /* copyfrom_relpath */,
 
1104
                                  SVN_INVALID_REVNUM,
 
1105
                                  NULL /* moved_from_abspath */,
 
1106
                                  SVN_CLIENT_COMMIT_ITEM_DELETE,
 
1107
                                  NULL /* lock tokens */,
 
1108
                                  NULL /* lock */,
 
1109
                                  commit_items->pool,
 
1110
                                  iterpool));
1067
1111
        }
1068
1112
      }
1069
1113
 
1181
1225
  hdb.cancel_baton = ctx->cancel_baton;
1182
1226
  hdb.check_url_func = check_url_func;
1183
1227
  hdb.check_url_baton = check_url_baton;
 
1228
  hdb.committables = *committables;
1184
1229
 
1185
1230
  SVN_ERR(svn_iter_apr_hash(NULL, (*committables)->by_repository,
1186
1231
                            handle_descendants, &hdb, iterpool));
1274
1319
  hdb.cancel_baton = btn->ctx->cancel_baton;
1275
1320
  hdb.check_url_func = btn->check_url_func;
1276
1321
  hdb.check_url_baton = btn->check_url_baton;
 
1322
  hdb.committables = btn->committables;
1277
1323
 
1278
1324
  SVN_ERR(svn_iter_apr_hash(NULL, btn->committables->by_repository,
1279
1325
                            handle_descendants, &hdb, pool));