2 * changelist.c: implementation of the 'changelist' command
4 * ====================================================================
5 * Copyright (c) 2006-2007 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
19 /* ==================================================================== */
25 #include "svn_client.h"
27 #include "svn_pools.h"
35 svn_client_add_to_changelist(const apr_array_header_t
*paths
,
36 const char *changelist_name
,
37 svn_client_ctx_t
*ctx
,
40 /* Someday this routine might be use a different underlying API to
41 to make the associations in a centralized database. */
43 return svn_wc_set_changelist(paths
, changelist_name
, NULL
,
44 ctx
->cancel_func
, ctx
->cancel_baton
,
45 ctx
->notify_func2
, ctx
->notify_baton2
, pool
);
50 svn_client_remove_from_changelist(const apr_array_header_t
*paths
,
51 const char *changelist_name
,
52 svn_client_ctx_t
*ctx
,
55 /* Someday this routine might be use a different underlying API to
56 remove the associations from a centralized database.
58 To that end, we should keep our semantics consistent. If
59 CHANGELIST_NAME is defined, then it's not enough to just "blank
60 out" any changelist name attached to each path's entry_t; we need
61 to verify that each incoming path is already a member of the
62 named changelist first... if not, then skip over it or show a
63 warning. This is what a centralized database would do.
65 If CHANGELIST_NAME is undefined, then we can be more lax and
66 remove the path from whatever changelist it's already a part of.
69 return svn_wc_set_changelist(paths
, NULL
, changelist_name
,
70 ctx
->cancel_func
, ctx
->cancel_baton
,
71 ctx
->notify_func2
, ctx
->notify_baton2
, pool
);
75 /* Entry-walker callback for svn_client_get_changelist*() below. */
79 svn_boolean_t store_paths
;
80 svn_changelist_receiver_t callback_func
;
82 apr_array_header_t
*path_list
;
83 const char *changelist_name
;
89 found_an_entry(const char *path
,
90 const svn_wc_entry_t
*entry
,
94 struct fe_baton
*b
= (struct fe_baton
*)baton
;
97 && (strcmp(entry
->changelist
, b
->changelist_name
) == 0))
99 if ((entry
->kind
== svn_node_file
)
100 || ((entry
->kind
== svn_node_dir
)
101 && (strcmp(entry
->name
, SVN_WC_ENTRY_THIS_DIR
) == 0)))
104 APR_ARRAY_PUSH(b
->path_list
, const char *) = apr_pstrdup(b
->pool
,
107 SVN_ERR(b
->callback_func(b
->callback_baton
, path
));
114 static const svn_wc_entry_callbacks2_t entry_callbacks
=
115 { found_an_entry
, svn_client__default_walker_error_handler
};
118 svn_client_get_changelist(apr_array_header_t
**paths
,
119 const char *changelist_name
,
120 const char *root_path
,
121 svn_client_ctx_t
*ctx
,
125 svn_wc_adm_access_t
*adm_access
;
127 feb
.store_paths
= TRUE
;
129 feb
.changelist_name
= changelist_name
;
130 feb
.path_list
= apr_array_make(pool
, 1, sizeof(const char *));
132 SVN_ERR(svn_wc_adm_probe_open3(&adm_access
, NULL
, root_path
,
133 FALSE
, /* no write lock */
134 -1, /* levels to lock == infinity */
135 ctx
->cancel_func
, ctx
->cancel_baton
, pool
));
137 SVN_ERR(svn_wc_walk_entries3(root_path
, adm_access
,
138 &entry_callbacks
, &feb
,
140 FALSE
, /* don't show hidden entries */
141 ctx
->cancel_func
, ctx
->cancel_baton
,
144 SVN_ERR(svn_wc_adm_close(adm_access
));
146 *paths
= feb
.path_list
;
152 svn_client_get_changelist_streamy(svn_changelist_receiver_t callback_func
,
153 void *callback_baton
,
154 const char *changelist_name
,
155 const char *root_path
,
156 svn_client_ctx_t
*ctx
,
160 svn_wc_adm_access_t
*adm_access
;
162 feb
.store_paths
= FALSE
;
163 feb
.callback_func
= callback_func
;
164 feb
.callback_baton
= callback_baton
;
166 feb
.changelist_name
= changelist_name
;
167 feb
.path_list
= apr_array_make(pool
, 1, sizeof(const char *));
169 SVN_ERR(svn_wc_adm_probe_open3(&adm_access
, NULL
, root_path
,
170 FALSE
, /* no write lock */
171 -1, /* levels to lock == infinity */
172 ctx
->cancel_func
, ctx
->cancel_baton
, pool
));
174 SVN_ERR(svn_wc_walk_entries3(root_path
, adm_access
,
175 &entry_callbacks
, &feb
,
177 FALSE
, /* don't show hidden entries */
178 ctx
->cancel_func
, ctx
->cancel_baton
,
181 SVN_ERR(svn_wc_adm_close(adm_access
));