version 1.6, 2005/03/26 08:09:54 |
version 1.7, 2005/03/30 17:43:04 |
|
|
#include "proto.h" |
#include "proto.h" |
|
|
|
|
int cvs_tag_file (CVSFILE *, void *); |
int cvs_tag_file(CVSFILE *, void *); |
|
int cvs_tag_options(char *, int, char **, int *); |
|
int cvs_tag_sendflags(struct cvsroot *); |
|
|
|
static char *tag, *old_tag, *date; |
|
static int branch, delete; |
|
|
/* |
struct cvs_cmd_info cvs_tag = { |
* cvs_tag() |
cvs_tag_options, |
* |
cvs_tag_sendflags, |
* Handler for the `cvs tag' command. |
cvs_tag_file, |
* Returns 0 on success, or one of the known exit codes on error. |
NULL, NULL, |
*/ |
CF_SORT | CF_IGNORE | CF_RECURSE, |
|
CVS_REQ_TAG, |
|
CVS_CMD_ALLOWSPEC |
|
}; |
|
|
int |
int |
cvs_tag(int argc, char **argv) |
cvs_tag_options(char *opt, int argc, char **argv, int *arg) |
{ |
{ |
int ch, flags; |
int ch; |
struct cvsroot *root; |
|
char *tag, *old_tag, *date; |
|
int branch, delete; |
|
|
|
date = old_tag = NULL; |
date = old_tag = NULL; |
branch = delete = 0; |
branch = delete = 0; |
flags = CF_SORT|CF_IGNORE|CF_RECURSE; |
|
|
|
while ((ch = getopt(argc, argv, "bdD:lr:")) != -1) { |
while ((ch = getopt(argc, argv, opt)) != -1) { |
switch (ch) { |
switch (ch) { |
case 'b': |
case 'b': |
branch = 1; |
branch = 1; |
|
|
date = optarg; |
date = optarg; |
break; |
break; |
case 'l': |
case 'l': |
flags &= ~CF_RECURSE; |
cvs_tag.file_flags &= ~CF_RECURSE; |
break; |
break; |
case 'r': |
case 'r': |
old_tag = optarg; |
old_tag = optarg; |
|
|
} |
} |
} |
} |
|
|
|
*arg = optind; |
argc -= optind; |
argc -= optind; |
argv += optind; |
argv += optind; |
|
|
|
|
tag = argv[0]; |
tag = argv[0]; |
argc--; |
argc--; |
argv++; |
argv++; |
|
*arg += 1; |
} |
} |
|
|
if (branch && delete) { |
if (branch && delete) { |
|
|
return (-1); |
return (-1); |
} |
} |
|
|
if (argc == 0) |
return (0); |
cvs_files = cvs_file_get(".", flags); |
} |
else |
|
cvs_files = cvs_file_getspec(argv, argc, 0); |
|
if (cvs_files == NULL) |
|
return (EX_DATAERR); |
|
|
|
root = CVS_DIR_ROOT(cvs_files); |
int |
if (root == NULL) { |
cvs_tag_sendflags(struct cvsroot *root) |
cvs_log(LP_ERR, |
{ |
"No CVSROOT specified! Please use the `-d' option"); |
if (branch && (cvs_sendarg(root, "-b", 0) < 0)) |
cvs_log(LP_ERR, |
return (EX_PROTOCOL); |
"or set the CVSROOT environment variable."); |
|
return (EX_USAGE); |
|
} |
|
|
|
if (root->cr_method != CVS_METHOD_LOCAL) { |
if (delete && (cvs_sendarg(root, "-d", 0) < 0)) |
if (cvs_connect(root) < 0) |
return (EX_PROTOCOL); |
|
|
|
if (old_tag) { |
|
if ((cvs_sendarg(root, "-r", 0) < 0) || |
|
(cvs_sendarg(root, old_tag, 0) < 0)) |
return (EX_PROTOCOL); |
return (EX_PROTOCOL); |
if (branch && (cvs_sendarg(root, "-b", 0) < 0)) |
|
return (EX_PROTOCOL); |
|
if (delete && (cvs_sendarg(root, "-d", 0) < 0)) |
|
return (EX_PROTOCOL); |
|
if (old_tag) { |
|
if ((cvs_sendarg(root, "-r", 0) < 0) || |
|
(cvs_sendarg(root, old_tag, 0) < 0)) |
|
return (EX_PROTOCOL); |
|
} |
|
if (date) { |
|
if ((cvs_sendarg(root, "-D", 0) < 0) || |
|
(cvs_sendarg(root, date, 0) < 0)) |
|
return (EX_PROTOCOL); |
|
} |
|
if (cvs_sendarg(root, tag, 0) < 0) |
|
return (EX_PROTOCOL); |
|
} |
} |
|
|
cvs_file_examine(cvs_files, cvs_tag_file, NULL); |
if (date) { |
|
if ((cvs_sendarg(root, "-D", 0) < 0) || |
if (root->cr_method != CVS_METHOD_LOCAL) { |
(cvs_sendarg(root, date, 0) < 0)) |
if (cvs_senddir(root, cvs_files) < 0) |
|
return (EX_PROTOCOL); |
return (EX_PROTOCOL); |
if (cvs_sendreq(root, CVS_REQ_TAG, NULL) < 0) |
|
return (EX_PROTOCOL); |
|
} |
} |
|
|
|
if (cvs_sendarg(root, tag, 0) < 0) |
|
return (EX_PROTOCOL); |
|
|
return (0); |
return (0); |
} |
} |