diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2006-05-28 07:56:45 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2006-05-28 07:56:45 +0000 |
commit | 4831b4d3284c7b84abbe3048e1a839fffe872acd (patch) | |
tree | 78f1692463445ef509f8144d4efd43f8a8a52670 | |
parent | 9b42ad54e3c5f0480a7e98dbd8762626296a4c6f (diff) |
allow commands to shut up the output from cvs_file_classify
if the commands want to output certain stuff themselfs
-rw-r--r-- | usr.bin/cvs/add.c | 96 | ||||
-rw-r--r-- | usr.bin/cvs/commit.c | 6 | ||||
-rw-r--r-- | usr.bin/cvs/diff.c | 4 | ||||
-rw-r--r-- | usr.bin/cvs/file.c | 34 | ||||
-rw-r--r-- | usr.bin/cvs/file.h | 4 | ||||
-rw-r--r-- | usr.bin/cvs/status.c | 4 | ||||
-rw-r--r-- | usr.bin/cvs/update.c | 6 |
7 files changed, 126 insertions, 28 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c new file mode 100644 index 00000000000..9980b34e50b --- /dev/null +++ b/usr.bin/cvs/add.c @@ -0,0 +1,96 @@ +/* $OpenBSD: add.c,v 1.43 2006/05/28 07:56:44 joris Exp $ */ +/* + * Copyright (c) 2006 Joris Vink <joris@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "includes.h" + +#include "cvs.h" +#include "diff.h" +#include "log.h" +#include "proto.h" + +int cvs_add(int, char **); +void cvs_add_local(struct cvs_file *); + +char *logmsg; + +struct cvs_cmd cvs_cmd_add = { + CVS_OP_ADD, CVS_REQ_ADD, "add", + { "ad", "new" }, + "Add a new file or directory to the repository", + "[-m message] ...", + "m", + NULL, + cvs_add +}; + +int +cvs_add(int argc, char **argv) +{ + int ch; + int flags; + char *arg = "."; + struct cvs_recursion cr; + + flags = CR_RECURSE_DIRS | CR_REPO; + + while ((ch = getopt(argc, argv, cvs_cmd_add.cmd_opts)) != -1) { + switch (ch) { + case 'm': + logmsg = xstrdup(optarg); + break; + default: + fatal("%s", cvs_cmd_add.cmd_synopsis); + } + } + + argc -= optind; + argv += optind; + + cr.enterdir = NULL; + cr.leavedir = NULL; + cr.local = cvs_add_local; + cr.remote = NULL; + cr.flags = flags; + + if (argc > 0) + cvs_file_run(argc, argv, &cr); + else + cvs_file_run(1, &arg, &cr); + + return (0); +} + +void +cvs_add_local(struct cvs_file *cf) +{ + cvs_log(LP_TRACE, "cvs_add_local(%s)", cf->file_path); + + cvs_file_classify(cf, 0); + + switch (cf->file_status) { + case FILE_ADDED: + cvs_log(LP_NOTICE, "%s has already been entered", + cf->file_path); + break; + case FILE_UNKNOWN: + cvs_log(LP_NOTICE, "%s is unknown to us so far", + cf->file_path); + break; + default: + break; + } +} diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c index 00d9bbb803f..b81e1f56cd3 100644 --- a/usr.bin/cvs/commit.c +++ b/usr.bin/cvs/commit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commit.c,v 1.61 2006/05/28 04:32:54 joris Exp $ */ +/* $OpenBSD: commit.c,v 1.62 2006/05/28 07:56:44 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -113,7 +113,7 @@ cvs_commit_check_conflicts(struct cvs_file *cf) * cvs_file_classify makes the noise for us * XXX - we want that? */ - cvs_file_classify(cf); + cvs_file_classify(cf, 1); if (cf->file_type == CVS_DIR) { if (verbosity > 1) @@ -153,7 +153,7 @@ cvs_commit_local(struct cvs_file *cf) CVSENTRIES *entlist; cvs_log(LP_TRACE, "cvs_commit_local(%s)", cf->file_path); - cvs_file_classify(cf); + cvs_file_classify(cf, 0); if (cf->file_status == FILE_MODIFIED || cf->file_status == FILE_REMOVED) diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c index d27f876ca84..ad29270dfd1 100644 --- a/usr.bin/cvs/diff.c +++ b/usr.bin/cvs/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.95 2006/05/27 21:11:11 joris Exp $ */ +/* $OpenBSD: diff.c,v 1.96 2006/05/28 07:56:44 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -124,7 +124,7 @@ cvs_diff_local(struct cvs_file *cf) return; } - cvs_file_classify(cf); + cvs_file_classify(cf, 0); if (cf->file_status == FILE_LOST) { cvs_log(LP_ERR, "cannot find file %s", cf->file_path); diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index aceb1372049..a52da5e95a4 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.142 2006/05/27 20:56:39 joris Exp $ */ +/* $OpenBSD: file.c,v 1.143 2006/05/28 07:56:44 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -531,12 +531,12 @@ cvs_file_freelist(struct cvs_flisthead *fl) } void -cvs_file_classify(struct cvs_file *cf) +cvs_file_classify(struct cvs_file *cf, int loud) { size_t len; time_t mtime; struct stat st; - int rflags, l, ismodified, rcsdead; + int rflags, l, ismodified, rcsdead, verbose; CVSENTRIES *entlist = NULL; const char *state; char *repo, *rcsfile, r1[16], r2[16]; @@ -548,6 +548,7 @@ cvs_file_classify(struct cvs_file *cf) return; } + verbose = (verbosity > 1 && loud == 1); entlist = cvs_ent_open(cf->file_wd); repo = xmalloc(MAXPATHLEN); @@ -625,12 +626,12 @@ cvs_file_classify(struct cvs_file *cf) if (cf->file_ent == NULL) { if (cf->file_rcs == NULL) { if (cf->fd == -1) { - if (verbosity > 1) + if (verbose) cvs_log(LP_NOTICE, "nothing known about '%s'", cf->file_path); } else { - if (verbosity > 1) + if (verbose) cvs_log(LP_NOTICE, "use add to create an entry for %s", cf->file_path); @@ -641,9 +642,10 @@ cvs_file_classify(struct cvs_file *cf) if (cf->fd == -1) { cf->file_status = FILE_UPTODATE; } else { - cvs_log(LP_NOTICE, - "use add to create an entry for %s", - cf->file_path); + if (verbose) + cvs_log(LP_NOTICE, + "use add to create an entry for %s", + cf->file_path); cf->file_status = FILE_UNKNOWN; } } else { @@ -651,7 +653,7 @@ cvs_file_classify(struct cvs_file *cf) } } else if (cf->file_ent->ce_status == CVS_ENT_ADDED) { if (cf->fd == -1) { - if (verbosity > 1) + if (verbose) cvs_log(LP_NOTICE, "warning: new-born %s has dissapeared", cf->file_path); @@ -659,7 +661,7 @@ cvs_file_classify(struct cvs_file *cf) } else if (cf->file_rcs == NULL || rcsdead == 1) { cf->file_status = FILE_ADDED; } else { - if (verbosity > 1) + if (verbose) cvs_log(LP_NOTICE, "conflict: %s already created by others", cf->file_path); @@ -667,7 +669,7 @@ cvs_file_classify(struct cvs_file *cf) } } else if (cf->file_ent->ce_status == CVS_ENT_REMOVED) { if (cf->fd != -1) { - if (verbosity > 1) + if (verbose) cvs_log(LP_NOTICE, "%s should be removed but is still there", cf->file_path); @@ -676,7 +678,7 @@ cvs_file_classify(struct cvs_file *cf) cf->file_status = FILE_REMOVE_ENTRY; } else { if (strcmp(r1, r2)) { - if (verbosity > 1) + if (verbose) cvs_log(LP_NOTICE, "conflict: removed %s was modified" " by a second party", @@ -689,7 +691,7 @@ cvs_file_classify(struct cvs_file *cf) } else if (cf->file_ent->ce_status == CVS_ENT_REG) { if (cf->file_rcs == NULL || rcsdead == 1) { if (cf->fd == -1) { - if (verbosity > 1) + if (verbose) cvs_log(LP_NOTICE, "warning: %s's entry exists but" " there is no longer a file" @@ -699,7 +701,7 @@ cvs_file_classify(struct cvs_file *cf) cf->file_status = FILE_REMOVE_ENTRY; } else { if (ismodified) { - if (verbosity > 1) + if (verbose) cvs_log(LP_NOTICE, "conflict: %s is no longer " "in the repository but is " @@ -707,7 +709,7 @@ cvs_file_classify(struct cvs_file *cf) cf->file_path); cf->file_status = FILE_CONFLICT; } else { - if (verbosity > 1) + if (verbose) cvs_log(LP_NOTICE, "%s is no longer in the " "repository", @@ -718,7 +720,7 @@ cvs_file_classify(struct cvs_file *cf) } } else { if (cf->fd == -1) { - if (verbosity > 1) + if (verbose) cvs_log(LP_NOTICE, "warning: %s was lost", cf->file_path); diff --git a/usr.bin/cvs/file.h b/usr.bin/cvs/file.h index 59b82304761..00bc0a47af5 100644 --- a/usr.bin/cvs/file.h +++ b/usr.bin/cvs/file.h @@ -1,4 +1,4 @@ -/* $OpenBSD: file.h,v 1.34 2006/05/27 03:30:30 joris Exp $ */ +/* $OpenBSD: file.h,v 1.35 2006/05/28 07:56:44 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -91,7 +91,7 @@ TAILQ_HEAD(ignore_head, cvs_ignpat); void cvs_file_init(void); void cvs_file_ignore(const char *, struct ignore_head *); -void cvs_file_classify(struct cvs_file *); +void cvs_file_classify(struct cvs_file *, int); void cvs_file_free(struct cvs_file *); void cvs_file_run(int, char **, struct cvs_recursion *); void cvs_file_walklist(struct cvs_flisthead *, struct cvs_recursion *); diff --git a/usr.bin/cvs/status.c b/usr.bin/cvs/status.c index 955f663fbc7..6b874f0bdee 100644 --- a/usr.bin/cvs/status.c +++ b/usr.bin/cvs/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.58 2006/05/27 15:14:27 joris Exp $ */ +/* $OpenBSD: status.c,v 1.59 2006/05/28 07:56:44 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -102,7 +102,7 @@ cvs_status_local(struct cvs_file *cf) cvs_log(LP_TRACE, "cvs_status_local(%s)", cf->file_path); - cvs_file_classify(cf); + cvs_file_classify(cf, 1); if (cf->file_type == CVS_DIR) { if (verbosity > 1) diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c index 324dac5ca41..d963c93143f 100644 --- a/usr.bin/cvs/update.c +++ b/usr.bin/cvs/update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: update.c,v 1.65 2006/05/28 01:24:28 joris Exp $ */ +/* $OpenBSD: update.c,v 1.66 2006/05/28 07:56:44 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -115,7 +115,7 @@ cvs_update_enterdir(struct cvs_file *cf) cvs_log(LP_TRACE, "cvs_update_enterdir(%s)", cf->file_path); - cvs_file_classify(cf); + cvs_file_classify(cf, 0); if (cf->file_status == DIR_CREATE && build_dirs == 1) { cvs_mkpath(cf->file_path); @@ -241,7 +241,7 @@ cvs_update_local(struct cvs_file *cf) * which is called from cvs_checkout_file(). */ bp = NULL; - cvs_file_classify(cf); + cvs_file_classify(cf, 1); switch (cf->file_status) { case FILE_UNKNOWN: |