version 1.17, 2005/02/27 00:22:08 |
version 1.18, 2005/03/30 17:43:04 |
|
|
#include "proto.h" |
#include "proto.h" |
|
|
|
|
int cvs_update_file (CVSFILE *, void *); |
int cvs_update_file(CVSFILE *, void *); |
int cvs_update_prune (CVSFILE *, void *); |
int cvs_update_prune(CVSFILE *, void *); |
|
int cvs_update_options(char *, int, char **, int *); |
|
|
|
struct cvs_cmd_info cvs_update = { |
|
cvs_update_options, |
|
NULL, |
|
cvs_update_file, |
|
NULL, NULL, |
|
CF_SORT | CF_RECURSE | CF_IGNORE | CF_KNOWN | CF_NOSYMS, |
|
CVS_REQ_UPDATE, |
|
CVS_CMD_ALLOWSPEC | CVS_CMD_SENDARGS2 | CVS_CMD_SENDDIR |
|
}; |
|
|
/* |
|
* cvs_update() |
|
* |
|
* Handle the `cvs update' command. |
|
* Returns 0 on success, or the appropriate exit code on error. |
|
*/ |
|
int |
int |
cvs_update(int argc, char **argv) |
cvs_update_options(char *opt, int argc, char **argv, int *arg) |
{ |
{ |
int i, ch, flags; |
int ch; |
struct cvsroot *root; |
|
|
|
flags = CF_SORT|CF_RECURSE|CF_IGNORE|CF_KNOWN|CF_NOSYMS; |
while ((ch = getopt(argc, argv, opt)) != -1) { |
|
|
while ((ch = getopt(argc, argv, "ACD:dflPpQqRr:")) != -1) { |
|
switch (ch) { |
switch (ch) { |
case 'A': |
case 'A': |
case 'C': |
case 'C': |
|
|
case 'f': |
case 'f': |
break; |
break; |
case 'l': |
case 'l': |
flags &= ~CF_RECURSE; |
cvs_update.file_flags &= ~CF_RECURSE; |
break; |
break; |
case 'P': |
case 'P': |
case 'p': |
case 'p': |
|
|
case 'q': |
case 'q': |
break; |
break; |
case 'R': |
case 'R': |
flags |= CF_RECURSE; |
cvs_update.file_flags |= CF_RECURSE; |
break; |
break; |
case 'r': |
case 'r': |
break; |
break; |
|
|
} |
} |
} |
} |
|
|
argc -= optind; |
*arg = optind; |
argv += optind; |
|
|
|
if (argc == 0) |
|
cvs_files = cvs_file_get(".", flags); |
|
else { |
|
/* don't perform ignore on explicitly listed files */ |
|
flags &= ~(CF_IGNORE | CF_RECURSE | CF_SORT); |
|
cvs_files = cvs_file_getspec(argv, argc, flags); |
|
} |
|
if (cvs_files == NULL) |
|
return (EX_DATAERR); |
|
|
|
root = CVS_DIR_ROOT(cvs_files); |
|
if (root == NULL) { |
|
cvs_log(LP_ERR, |
|
"No CVSROOT specified! Please use the `-d' option"); |
|
cvs_log(LP_ERR, |
|
"or set the CVSROOT environment variable."); |
|
return (EX_USAGE); |
|
} |
|
if ((root->cr_method != CVS_METHOD_LOCAL) && (cvs_connect(root) < 0)) |
|
return (EX_PROTOCOL); |
|
|
|
cvs_file_examine(cvs_files, cvs_update_file, NULL); |
|
|
|
if (root->cr_method != CVS_METHOD_LOCAL) { |
|
if (cvs_senddir(root, cvs_files) < 0) |
|
return (EX_PROTOCOL); |
|
|
|
for (i = 0; i < argc; i++) |
|
if (cvs_sendarg(root, argv[i], 0) < 0) |
|
return (EX_PROTOCOL); |
|
if (cvs_sendreq(root, CVS_REQ_UPDATE, NULL) < 0) |
|
return (EX_PROTOCOL); |
|
} |
|
|
|
return (0); |
return (0); |
} |
} |
|
|