diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-12-19 09:21:35 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-12-19 09:21:35 +0000 |
commit | 26fdceb4942534da09ec2831801f8c803bb3cd8a (patch) | |
tree | 6faeac9c0e2fd758daf557866db778c53d2d109f /gnu | |
parent | eb4516b76efc86d0784c3c4b27f65a90d19b1d3d (diff) |
raw import of cvs-1.6
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/usr.bin/cvs/src/status.c | 260 |
1 files changed, 94 insertions, 166 deletions
diff --git a/gnu/usr.bin/cvs/src/status.c b/gnu/usr.bin/cvs/src/status.c index 7b64d30b4d8..d987a91ac8c 100644 --- a/gnu/usr.bin/cvs/src/status.c +++ b/gnu/usr.bin/cvs/src/status.c @@ -3,22 +3,28 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS source distribution. + * specified in the README file that comes with the CVS 1.4 kit. * * Status Information */ #include "cvs.h" -static Dtype status_dirproc PROTO ((void *callerdat, char *dir, - char *repos, char *update_dir, - List *entries)); -static int status_fileproc PROTO ((void *callerdat, struct file_info *finfo)); +#ifndef lint +static const char rcsid[] = "$CVSid: @(#)status.c 1.56 94/10/07 $"; +USE(rcsid); +#endif + +static Dtype status_dirproc PROTO((char *dir, char *repos, char *update_dir)); +static int status_fileproc PROTO((char *file, char *update_dir, + char *repository, List * entries, + List * srcfiles)); static int tag_list_proc PROTO((Node * p, void *closure)); static int local = 0; static int long_format = 0; -static RCSNode *xrcsnode; +static char *xfile; +static List *xsrcfiles; static const char *const status_usage[] = { @@ -26,12 +32,11 @@ static const char *const status_usage[] = "\t-v\tVerbose format; includes tag information for the file\n", "\t-l\tProcess this directory only (not recursive).\n", "\t-R\tProcess directories recursively.\n", - "(Specify the --help global option for a list of other help options)\n", NULL }; int -cvsstatus (argc, argv) +status (argc, argv) int argc; char **argv; { @@ -41,8 +46,8 @@ cvsstatus (argc, argv) if (argc == -1) usage (status_usage); - optind = 0; - while ((c = getopt (argc, argv, "+vlR")) != -1) + optind = 1; + while ((c = getopt (argc, argv, "vlR")) != -1) { switch (c) { @@ -67,46 +72,32 @@ cvsstatus (argc, argv) wrap_setup (); #ifdef CLIENT_SUPPORT - if (current_parsed_root->isremote) - { - start_server (); + if (client_active) { + start_server (); - ign_setup (); + ign_setup (); - if (long_format) - send_arg("-v"); - if (local) - send_arg("-l"); + if (long_format) + send_arg("-v"); + if (local) + send_arg("-l"); - /* For a while, we tried setting SEND_NO_CONTENTS here so this - could be a fast operation. That prevents the - server from updating our timestamp if the timestamp is - changed but the file is unmodified. Worse, it is user-visible - (shows "locally modified" instead of "up to date" if - timestamp is changed but file is not). And there is no good - workaround (you might not want to run "cvs update"; "cvs -n - update" doesn't update CVS/Entries; "cvs diff --brief" or - something perhaps could be made to work but somehow that - seems nonintuitive to me even if so). Given that timestamps - seem to have the potential to get munged for any number of - reasons, it seems better to not rely too much on them. */ + /* XXX This should only need to send file info; the file + contents themselves will not be examined. */ + send_files (argc, argv, local, 0); - send_files (argc, argv, local, 0, 0); + if (fprintf (to_server, "status\n") < 0) + error (1, errno, "writing to server"); + err = get_responses_and_close (); - send_file_names (argc, argv, SEND_EXPAND_WILD); - - send_to_server ("status\012", 0); - err = get_responses_and_close (); - - return err; + return err; } #endif /* start the recursion processor */ - err = start_recursion (status_fileproc, (FILESDONEPROC) NULL, - status_dirproc, (DIRLEAVEPROC) NULL, NULL, - argc, argv, local, - W_LOCAL, 0, 1, (char *) NULL, 1); + err = start_recursion (status_fileproc, (int (*) ()) NULL, status_dirproc, + (int (*) ()) NULL, argc, argv, local, + W_LOCAL, 0, 1, (char *) NULL, 1, 0); return (err); } @@ -116,17 +107,20 @@ cvsstatus (argc, argv) */ /* ARGSUSED */ static int -status_fileproc (callerdat, finfo) - void *callerdat; - struct file_info *finfo; +status_fileproc (file, update_dir, repository, entries, srcfiles) + char *file; + char *update_dir; + char *repository; + List *entries; + List *srcfiles; { Ctype status; char *sstat; Vers_TS *vers; - status = Classify_File (finfo, (char *) NULL, (char *) NULL, (char *) NULL, - 1, 0, &vers, 0); - sstat = "Classify Error"; + status = Classify_File (file, (char *) NULL, (char *) NULL, (char *) NULL, + 1, 0, repository, entries, srcfiles, &vers, + update_dir, 0); switch (status) { case T_UNKNOWN: @@ -135,13 +129,12 @@ status_fileproc (callerdat, finfo) case T_CHECKOUT: sstat = "Needs Checkout"; break; +#ifdef SERVER_SUPPORT case T_PATCH: sstat = "Needs Patch"; break; +#endif case T_CONFLICT: - /* I _think_ that "unresolved" is correct; that if it has - been resolved then the status will change. But I'm not - sure about that. */ sstat = "Unresolved Conflict"; break; case T_ADDED: @@ -152,7 +145,7 @@ status_fileproc (callerdat, finfo) break; case T_MODIFIED: if (vers->ts_conflict) - sstat = "File had conflicts on merge"; + sstat = "Unresolved Conflict"; else sstat = "Locally Modified"; break; @@ -165,66 +158,34 @@ status_fileproc (callerdat, finfo) case T_NEEDS_MERGE: sstat = "Needs Merge"; break; - case T_TITLE: - /* I don't think this case can occur here. Just print - "Classify Error". */ + default: + sstat = "Classify Error"; break; } - cvs_output ("\ -===================================================================\n", 0); + (void) printf ("===================================================================\n"); if (vers->ts_user == NULL) - { - cvs_output ("File: no file ", 0); - cvs_output (finfo->file, 0); - cvs_output ("\t\tStatus: ", 0); - cvs_output (sstat, 0); - cvs_output ("\n\n", 0); - } + (void) printf ("File: no file %s\t\tStatus: %s\n\n", file, sstat); else - { - char *buf; - buf = xmalloc (strlen (finfo->file) + strlen (sstat) + 80); - sprintf (buf, "File: %-17s\tStatus: %s\n\n", finfo->file, sstat); - cvs_output (buf, 0); - free (buf); - } + (void) printf ("File: %-17s\tStatus: %s\n\n", file, sstat); if (vers->vn_user == NULL) - { - cvs_output (" Working revision:\tNo entry for ", 0); - cvs_output (finfo->file, 0); - cvs_output ("\n", 0); - } + (void) printf (" Working revision:\tNo entry for %s\n", file); else if (vers->vn_user[0] == '0' && vers->vn_user[1] == '\0') - cvs_output (" Working revision:\tNew file!\n", 0); + (void) printf (" Working revision:\tNew file!\n"); #ifdef SERVER_SUPPORT else if (server_active) - { - cvs_output (" Working revision:\t", 0); - cvs_output (vers->vn_user, 0); - cvs_output ("\n", 0); - } + (void) printf (" Working revision:\t%s\n", vers->vn_user); #endif else - { - cvs_output (" Working revision:\t", 0); - cvs_output (vers->vn_user, 0); - cvs_output ("\t", 0); - cvs_output (vers->ts_rcs, 0); - cvs_output ("\n", 0); - } + (void) printf (" Working revision:\t%s\t%s\n", vers->vn_user, + vers->ts_rcs); if (vers->vn_rcs == NULL) - cvs_output (" Repository revision:\tNo revision control file\n", 0); + (void) printf (" Repository revision:\tNo revision control file\n"); else - { - cvs_output (" Repository revision:\t", 0); - cvs_output (vers->vn_rcs, 0); - cvs_output ("\t", 0); - cvs_output (vers->srcfile->path, 0); - cvs_output ("\n", 0); - } + (void) printf (" Repository revision:\t%s\t%s\n", vers->vn_rcs, + vers->srcfile->path); if (vers->entdata) { @@ -234,76 +195,56 @@ status_fileproc (callerdat, finfo) if (edata->tag) { if (vers->vn_rcs == NULL) - { - cvs_output (" Sticky Tag:\t\t", 0); - cvs_output (edata->tag, 0); - cvs_output (" - MISSING from RCS file!\n", 0); - } + (void) printf ( + " Sticky Tag:\t\t%s - MISSING from RCS file!\n", + edata->tag); else { - if (isdigit ((unsigned char) edata->tag[0])) - { - cvs_output (" Sticky Tag:\t\t", 0); - cvs_output (edata->tag, 0); - cvs_output ("\n", 0); - } + if (isdigit (edata->tag[0])) + (void) printf (" Sticky Tag:\t\t%s\n", edata->tag); else { - char *branch = NULL; - - if (RCS_nodeisbranch (finfo->rcs, edata->tag)) - branch = RCS_whatbranch(finfo->rcs, edata->tag); - - cvs_output (" Sticky Tag:\t\t", 0); - cvs_output (edata->tag, 0); - cvs_output (" (", 0); - cvs_output (branch ? "branch" : "revision", 0); - cvs_output (": ", 0); - cvs_output (branch ? branch : vers->vn_rcs, 0); - cvs_output (")\n", 0); - - if (branch) - free (branch); + int isbranch = RCS_isbranch (file, edata->tag, srcfiles); + + (void) printf (" Sticky Tag:\t\t%s (%s: %s)\n", + edata->tag, + isbranch ? "branch" : "revision", + isbranch ? + RCS_whatbranch(file, edata->tag, srcfiles) : + vers->vn_rcs); } } } else if (!really_quiet) - cvs_output (" Sticky Tag:\t\t(none)\n", 0); + (void) printf (" Sticky Tag:\t\t(none)\n"); if (edata->date) - { - cvs_output (" Sticky Date:\t\t", 0); - cvs_output (edata->date, 0); - cvs_output ("\n", 0); - } + (void) printf (" Sticky Date:\t\t%s\n", edata->date); else if (!really_quiet) - cvs_output (" Sticky Date:\t\t(none)\n", 0); + (void) printf (" Sticky Date:\t\t(none)\n"); if (edata->options && edata->options[0]) - { - cvs_output (" Sticky Options:\t", 0); - cvs_output (edata->options, 0); - cvs_output ("\n", 0); - } + (void) printf (" Sticky Options:\t%s\n", edata->options); else if (!really_quiet) - cvs_output (" Sticky Options:\t(none)\n", 0); - } + (void) printf (" Sticky Options:\t(none)\n"); - if (long_format && vers->srcfile) - { - List *symbols = RCS_symbols(vers->srcfile); - - cvs_output ("\n Existing Tags:\n", 0); - if (symbols) + if (long_format && vers->srcfile) { - xrcsnode = finfo->rcs; - (void) walklist (symbols, tag_list_proc, NULL); + List *symbols = RCS_symbols(vers->srcfile); + + (void) printf ("\n Existing Tags:\n"); + if (symbols) + { + xfile = file; + xsrcfiles = srcfiles; + (void) walklist (symbols, tag_list_proc, NULL); + } + else + (void) printf ("\tNo Tags Exist\n"); } - else - cvs_output ("\tNo Tags Exist\n", 0); } - cvs_output ("\n", 0); + (void) printf ("\n"); freevers_ts (&vers); return (0); } @@ -313,12 +254,10 @@ status_fileproc (callerdat, finfo) */ /* ARGSUSED */ static Dtype -status_dirproc (callerdat, dir, repos, update_dir, entries) - void *callerdat; +status_dirproc (dir, repos, update_dir) char *dir; char *repos; char *update_dir; - List *entries; { if (!quiet) error (0, 0, "Examining %s", update_dir); @@ -333,22 +272,11 @@ tag_list_proc (p, closure) Node *p; void *closure; { - char *branch = NULL; - char *buf; - - if (RCS_nodeisbranch (xrcsnode, p->key)) - branch = RCS_whatbranch(xrcsnode, p->key) ; - - buf = xmalloc (80 + strlen (p->key) - + (branch ? strlen (branch) : strlen (p->data))); - sprintf (buf, "\t%-25s\t(%s: %s)\n", p->key, - branch ? "branch" : "revision", - branch ? branch : p->data); - cvs_output (buf, 0); - free (buf); - - if (branch) - free (branch); + int isbranch = RCS_isbranch (xfile, p->key, xsrcfiles); + (void) printf ("\t%-25.25s\t(%s: %s)\n", p->key, + isbranch ? "branch" : "revision", + isbranch ? RCS_whatbranch(xfile, p->key, xsrcfiles) : + p->data); return (0); } |