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 
00151 int au__action(struct estat *sts)
00152 {
00153     int status;
00154     int old;
00155     int mask=RF_ADD | RF_UNVERSION;
00156 
00157 
00158     status=0;
00159 
00160     
00161 
00162 
00163 
00164     BUG_ON( action->i_val != RF_UNVERSION && action->i_val != RF_ADD );
00165 
00166     old=sts->flags & mask;
00167     
00168 
00169     sts->flags = (sts->flags & ~mask) | action->i_val;
00170     DEBUGP("changing flags: has now %X", sts->flags);
00171     STOPIF( st__status(sts), NULL);
00172 
00173     
00174 
00175 
00176 
00177 
00178 
00179 
00180     if (((sts->flags ^ old) & mask) == mask)
00181     {
00182         if (!sts->repos_rev) 
00183             STOPIF( ops__delete_entry(sts->parent, sts, 
00184                         UNKNOWN_INDEX, UNKNOWN_INDEX), 
00185                     NULL);
00186         else
00187             sts->flags &= ~mask;
00188     }
00189 
00190     if (sts->flags & RF_ADD)
00191     {
00192         
00193         STOPIF( ign__is_ignore(sts, &old), NULL);
00194         
00195 
00196 
00197         STOPIF( ops__apply_group(sts, NULL, NULL), NULL);
00198 
00199         
00200 
00201         sts->to_be_ignored=0;
00202     }
00203 
00204     if ((sts->flags & mask) == RF_ADD)
00205         sts->url=current_url;
00206 
00207 
00208 ex:
00209     return status;
00210 }
00211 
00212 
00215 int au__prepare_for_added(void)
00216 {
00217     int status;
00218 
00219     STOPIF( url__load_list(NULL, 0), NULL);
00220     STOPIF( url__mark_todo(), NULL);
00221     STOPIF_CODE_ERR( url__parm_list_used>1, EINVAL,
00222             "!At most a single destination URL may be given.");
00223 
00224     if (url__parm_list_used)
00225     {
00226         STOPIF(url__find_by_name(url__parm_list[0], ¤t_url), 
00227                 "!No URL with name \"%s\" defined.", url__parm_list[0]);
00228         DEBUGP("URL to add to: %s", current_url->url);
00229     }
00230     else
00231         current_url=NULL;
00232 
00233     
00234     STOPIF( ign__load_list(NULL), NULL);
00235 
00236 ex:
00237     return status;
00238 }
00239 
00240 
00243 int au__work(struct estat *root, int argc, char *argv[])
00244 {
00245     int status;
00246     char **normalized;
00247 
00248 
00249     
00250     opt_recursive=-1;
00251     
00252 
00253 
00254     STOPIF( waa__find_common_base(argc, argv, &normalized), NULL);
00255 
00256     STOPIF( au__prepare_for_added(), NULL);
00257 
00258     STOPIF( waa__read_or_build_tree(root, argc, normalized, argv, 
00259                 NULL, 0), NULL);
00260 
00261     STOPIF( waa__output_tree(root), NULL);
00262 
00263 ex:
00264     return status;
00265 }
00266