00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <fcntl.h>
00010
00011 #include "global.h"
00012 #include "add_unvers.h"
00013 #include "status.h"
00014 #include "ignore.h"
00015 #include "warnings.h"
00016 #include "est_ops.h"
00017 #include "url.h"
00018 #include "helper.h"
00019 #include "waa.h"
00020
00021
00147 int au__action(struct estat *sts)
00148 {
00149 int status;
00150 int old;
00151 int mask=RF_ADD | RF_UNVERSION;
00152
00153
00154 status=0;
00155
00156
00157
00158
00159
00160 BUG_ON( action->i_val != RF_UNVERSION && action->i_val != RF_ADD );
00161
00162 old=sts->flags & mask;
00163
00164
00165 sts->flags = (sts->flags & ~mask) | action->i_val;
00166 DEBUGP("changing flags: has now %X", sts->flags);
00167 STOPIF( st__status(sts), NULL);
00168
00169
00170
00171
00172
00173
00174
00175
00176 if (((sts->flags ^ old) & mask) == mask)
00177 {
00178 if (!sts->repos_rev)
00179 STOPIF( ops__delete_entry(sts->parent, sts,
00180 UNKNOWN_INDEX, UNKNOWN_INDEX),
00181 NULL);
00182 else
00183 sts->flags &= ~mask;
00184 }
00185
00186 if (sts->flags & RF_ADD)
00187 {
00188
00189 STOPIF( ign__is_ignore(sts, &old), NULL);
00190
00191
00192
00193 STOPIF( ops__apply_group(sts, NULL, NULL), NULL);
00194
00195
00196
00197 sts->to_be_ignored=0;
00198 }
00199
00200 if ((sts->flags & mask) == RF_ADD)
00201 sts->url=current_url;
00202
00203
00204 ex:
00205 return status;
00206 }
00207
00208
00211 int au__prepare_for_added(void)
00212 {
00213 int status;
00214
00215 STOPIF( url__load_list(NULL, 0), NULL);
00216 STOPIF( url__mark_todo(), NULL);
00217 STOPIF_CODE_ERR( url__parm_list_used>1, EINVAL,
00218 "!At most a single destination URL may be given.");
00219
00220 if (url__parm_list_used)
00221 {
00222 STOPIF(url__find_by_name(url__parm_list[0], ¤t_url),
00223 "!No URL with name \"%s\" defined.", url__parm_list[0]);
00224 DEBUGP("URL to add to: %s", current_url->url);
00225 }
00226 else
00227 current_url=NULL;
00228
00229
00230 STOPIF( ign__load_list(NULL), NULL);
00231
00232 ex:
00233 return status;
00234 }
00235
00236
00239 int au__work(struct estat *root, int argc, char *argv[])
00240 {
00241 int status;
00242 char **normalized;
00243
00244
00245
00246 opt_recursive=-1;
00247
00248
00249
00250 STOPIF( waa__find_common_base(argc, argv, &normalized), NULL);
00251
00252 STOPIF( au__prepare_for_added(), NULL);
00253
00254 STOPIF( waa__read_or_build_tree(root, argc, normalized, argv,
00255 NULL, 0), NULL);
00256
00257 STOPIF( waa__output_tree(root), NULL);
00258
00259 ex:
00260 return status;
00261 }
00262