=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/tag.c,v retrieving revision 1.51 retrieving revision 1.52 diff -c -r1.51 -r1.52 *** src/usr.bin/cvs/tag.c 2006/11/09 10:08:33 1.51 --- src/usr.bin/cvs/tag.c 2006/11/09 12:51:23 1.52 *************** *** 1,4 **** ! /* $OpenBSD: tag.c,v 1.51 2006/11/09 10:08:33 xsa Exp $ */ /* * Copyright (c) 2006 Xavier Santolaria * --- 1,4 ---- ! /* $OpenBSD: tag.c,v 1.52 2006/11/09 12:51:23 xsa Exp $ */ /* * Copyright (c) 2006 Xavier Santolaria * *************** *** 21,33 **** #include "log.h" #include "remote.h" void cvs_tag_local(struct cvs_file *); static int tag_del(struct cvs_file *); static int tag_add(struct cvs_file *); ! static int tag_delete = 0; ! static int tag_force_move = 0; static char *tag = NULL; static char *tag_date = NULL; static char *tag_name = NULL; --- 21,36 ---- #include "log.h" #include "remote.h" + #define T_CHECK_UPTODATE 0x01 + #define T_DELETE 0x02 + #define T_FORCE_MOVE 0x04 + void cvs_tag_local(struct cvs_file *); static int tag_del(struct cvs_file *); static int tag_add(struct cvs_file *); ! static int runflags = 0; static char *tag = NULL; static char *tag_date = NULL; static char *tag_name = NULL; *************** *** 54,67 **** while ((ch = getopt(argc, argv, cvs_cmd_tag.cmd_opts)) != -1) { switch (ch) { case 'D': tag_date = optarg; break; case 'd': ! tag_delete = 1; break; case 'F': ! tag_force_move = 1; break; case 'l': flags &= ~CR_RECURSE_DIRS; --- 57,73 ---- while ((ch = getopt(argc, argv, cvs_cmd_tag.cmd_opts)) != -1) { switch (ch) { + case 'c': + runflags |= T_CHECK_UPTODATE; + break; case 'D': tag_date = optarg; break; case 'd': ! runflags |= T_DELETE; break; case 'F': ! runflags |= T_FORCE_MOVE; break; case 'l': flags &= ~CR_RECURSE_DIRS; *************** *** 91,104 **** tag_name, RCS_SYM_INVALCHAR); if (tag_oldname != NULL) { ! if (tag_delete == 1) tag_oldname = NULL; else tag = tag_oldname; } if (tag_date != NULL) { ! if (tag_delete == 1) tag_date = NULL; else tag = tag_date; --- 97,110 ---- tag_name, RCS_SYM_INVALCHAR); if (tag_oldname != NULL) { ! if (runflags & T_DELETE) tag_oldname = NULL; else tag = tag_oldname; } if (tag_date != NULL) { ! if (runflags & T_DELETE) tag_date = NULL; else tag = tag_date; *************** *** 113,122 **** if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) { cr.fileproc = cvs_client_sendfile; ! if (tag_delete == 1) cvs_client_send_request("Argument -d"); ! if (tag_force_move == 1) cvs_client_send_request("Argument -F"); if (!(flags & CR_RECURSE_DIRS)) --- 119,131 ---- if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) { cr.fileproc = cvs_client_sendfile; ! if (runflags & T_CHECK_UPTODATE) ! cvs_client_send_request("Argument -c"); ! ! if (runflags & T_DELETE) cvs_client_send_request("Argument -d"); ! if (runflags & T_FORCE_MOVE) cvs_client_send_request("Argument -F"); if (!(flags & CR_RECURSE_DIRS)) *************** *** 155,161 **** if (cf->file_type == CVS_DIR) { if (verbosity > 1) { cvs_log(LP_NOTICE, "%s %s", ! (tag_delete == 1) ? "Untagging" : "Tagging", cf->file_path); } return; --- 164,170 ---- if (cf->file_type == CVS_DIR) { if (verbosity > 1) { cvs_log(LP_NOTICE, "%s %s", ! (runflags & T_DELETE) ? "Untagging" : "Tagging", cf->file_path); } return; *************** *** 163,169 **** cvs_file_classify(cf, tag, 0); ! if (tag_delete == 1) { if (tag_del(cf) == 0) { if (verbosity > 0) cvs_printf("D %s\n", cf->file_path); --- 172,188 ---- cvs_file_classify(cf, tag, 0); ! if (runflags & T_CHECK_UPTODATE) { ! if (cf->file_status != FILE_UPTODATE && ! cf->file_status != FILE_CHECKOUT && ! cf->file_status != FILE_PATCH) { ! cvs_log(LP_NOTICE, ! "%s is locally modified", cf->file_path); ! return; ! } ! } ! ! if (runflags & T_DELETE) { if (tag_del(cf) == 0) { if (verbosity > 0) cvs_printf("D %s\n", cf->file_path); *************** *** 240,252 **** } (void)rcsnum_tostr(trev, trevbuf, sizeof(trevbuf)); ! if (tag_force_move == 0) { cvs_printf("W %s : %s ", cf->file_path, tag_name); cvs_printf("already exists on version %s", trevbuf); cvs_printf(" : NOT MOVING tag to version %s\n", revbuf); return (-1); ! } else if (tag_force_move == 1) { sym = rcs_sym_get(cf->file_rcs, tag_name); rcsnum_cpy(cf->file_rcsrev, sym->rs_num, 0); cf->file_rcs->rf_flags &= ~RCS_SYNCED; --- 259,271 ---- } (void)rcsnum_tostr(trev, trevbuf, sizeof(trevbuf)); ! if (!(runflags & T_FORCE_MOVE)) { cvs_printf("W %s : %s ", cf->file_path, tag_name); cvs_printf("already exists on version %s", trevbuf); cvs_printf(" : NOT MOVING tag to version %s\n", revbuf); return (-1); ! } else if (runflags & T_FORCE_MOVE) { sym = rcs_sym_get(cf->file_rcs, tag_name); rcsnum_cpy(cf->file_rcsrev, sym->rs_num, 0); cf->file_rcs->rf_flags &= ~RCS_SYNCED;