Annotation of src/usr.bin/cvs/getlog.c, Revision 1.60
1.60 ! joris 1: /* $OpenBSD: getlog.c,v 1.59 2006/05/29 06:29:49 joris Exp $ */
1.1 jfb 2: /*
1.57 joris 3: * Copyright (c) 2006 Joris Vink <joris@openbsd.org>
1.1 jfb 4: *
1.57 joris 5: * Permission to use, copy, modify, and distribute this software for any
6: * purpose with or without fee is hereby granted, provided that the above
7: * copyright notice and this permission notice appear in all copies.
1.1 jfb 8: *
1.57 joris 9: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1 jfb 16: */
17:
1.51 xsa 18: #include "includes.h"
1.1 jfb 19:
20: #include "cvs.h"
1.57 joris 21: #include "diff.h"
1.1 jfb 22: #include "log.h"
1.3 jfb 23: #include "proto.h"
1.1 jfb 24:
1.57 joris 25: #define LOG_REVSEP \
26: "----------------------------"
1.1 jfb 27:
1.57 joris 28: #define LOG_REVEND \
1.1 jfb 29: "============================================================================="
30:
1.57 joris 31: int cvs_getlog(int, char **);
32: void cvs_log_local(struct cvs_file *);
33:
34: char *logrev = NULL;
1.1 jfb 35:
1.29 jfb 36: struct cvs_cmd cvs_cmd_log = {
37: CVS_OP_LOG, CVS_REQ_LOG, "log",
38: { "lo" },
39: "Print out history information for files",
40: "[-bhlNRt] [-d dates] [-r revisions] [-s states] [-w logins]",
1.30 xsa 41: "bd:hlNRr:s:tw:",
1.29 jfb 42: NULL,
1.57 joris 43: cvs_getlog
1.16 joris 44: };
45:
1.57 joris 46: int
47: cvs_getlog(int argc, char **argv)
1.1 jfb 48: {
1.16 joris 49: int ch;
1.57 joris 50: int flags;
51: char *arg = ".";
52: struct cvs_recursion cr;
1.1 jfb 53:
1.57 joris 54: rcsnum_flags |= RCSNUM_NO_MAGIC;
55: flags = CR_RECURSE_DIRS;
56:
57: while ((ch = getopt(argc, argv, cvs_cmd_log.cmd_opts)) != -1) {
1.16 joris 58: switch (ch) {
1.1 jfb 59: case 'l':
1.57 joris 60: flags &= ~CR_RECURSE_DIRS;
1.1 jfb 61: break;
62: case 'r':
1.57 joris 63: logrev = optarg;
1.25 xsa 64: break;
1.1 jfb 65: default:
1.57 joris 66: fatal("%s", cvs_cmd_log.cmd_synopsis);
1.1 jfb 67: }
68: }
69:
1.57 joris 70: argc -= optind;
71: argv += optind;
1.6 jfb 72:
1.57 joris 73: cr.enterdir = NULL;
74: cr.leavedir = NULL;
75: cr.remote = NULL;
76: cr.local = cvs_log_local;
77: cr.flags = flags;
78:
79: if (argc > 0)
80: cvs_file_run(argc, argv, &cr);
81: else
82: cvs_file_run(1, &arg, &cr);
1.5 jfb 83:
1.49 joris 84: return (0);
1.6 jfb 85: }
1.5 jfb 86:
1.57 joris 87: void
88: cvs_log_local(struct cvs_file *cf)
1.1 jfb 89: {
1.57 joris 90: u_int nrev;
1.20 jfb 91: struct rcs_sym *sym;
1.57 joris 92: struct rcs_lock *lkp;
1.1 jfb 93: struct rcs_delta *rdp;
1.21 jfb 94: struct rcs_access *acp;
1.57 joris 95: char numb[32], timeb[32];
1.60 ! joris 96:
! 97: cvs_log(LP_TRACE, "cvs_log_local(%s)", cf->file_path);
1.20 jfb 98:
1.57 joris 99: cvs_file_classify(cf, 0);
1.39 xsa 100:
1.57 joris 101: if (cf->file_status == FILE_UNKNOWN) {
102: if (verbosity > 0)
103: cvs_log(LP_ERR, "nothing known about %s",
104: cf->file_path);
105: return;
106: } else if (cf->file_status == FILE_ADDED) {
1.39 xsa 107: if (verbosity > 0)
1.57 joris 108: cvs_log(LP_ERR, "%s has been added, but not commited",
109: cf->file_path);
1.59 joris 110: return;
111: }
112:
113: if (cf->file_type == CVS_DIR) {
114: if (verbosity > 1)
115: cvs_log(LP_NOTICE, "Logging %s", cf->file_path);
1.57 joris 116: return;
1.39 xsa 117: }
118:
1.57 joris 119: printf("\nRCS file: %s", cf->file_rpath);
120: printf("\nWorking file: %s", cf->file_path);
121: printf("\nhead:");
122: if (cf->file_rcs->rf_head != NULL)
123: printf(" %s", rcsnum_tostr(cf->file_rcs->rf_head,
124: numb, sizeof(numb)));
125:
126: printf("\nbranch:");
127: if (rcs_branch_get(cf->file_rcs) != NULL) {
128: printf(" %s", rcsnum_tostr(rcs_branch_get(cf->file_rcs),
129: numb, sizeof(numb)));
1.20 jfb 130: }
1.1 jfb 131:
1.57 joris 132: printf("\nlocks: %s", (cf->file_rcs->rf_flags & RCS_SLOCK)
133: ? "strict" : "");
134: TAILQ_FOREACH(lkp, &(cf->file_rcs->rf_locks), rl_list)
135: printf("\n\t%s: %s", lkp->rl_name,
136: rcsnum_tostr(lkp->rl_num, numb, sizeof(numb)));
1.20 jfb 137:
1.57 joris 138: printf("\naccess list:\n");
139: TAILQ_FOREACH(acp, &(cf->file_rcs->rf_access), ra_list)
140: printf("\t%s\n", acp->ra_name);
1.20 jfb 141:
1.57 joris 142: printf("symbolic names:\n");
143: TAILQ_FOREACH(sym, &(cf->file_rcs->rf_symbols), rs_list) {
144: printf("\t%s: %s\n", sym->rs_name,
145: rcsnum_tostr(sym->rs_num, numb, sizeof(numb)));
1.21 jfb 146: }
147:
1.57 joris 148: printf("keyword substitution: %s\n",
149: cf->file_rcs->rf_expand == NULL ? "kv" : cf->file_rcs->rf_expand);
150:
151: printf("total revisions: %u", cf->file_rcs->rf_ndelta);
1.20 jfb 152:
1.57 joris 153: if (logrev != NULL)
1.58 joris 154: nrev = cvs_revision_select(cf->file_rcs, logrev);
1.57 joris 155: else
156: nrev = cf->file_rcs->rf_ndelta;
1.21 jfb 157:
1.57 joris 158: printf(";\tselected revisions: %u", nrev);
159: printf("\n");
160: printf("description:\n%s", cf->file_rcs->rf_desc);
1.1 jfb 161:
1.57 joris 162: TAILQ_FOREACH(rdp, &(cf->file_rcs->rf_delta), rd_list) {
163: if (logrev != NULL &&
1.58 joris 164: !(rdp->rd_flags & RCS_RD_SELECT))
1.57 joris 165: continue;
1.35 joris 166:
1.57 joris 167: printf("%s\n", LOG_REVSEP);
1.1 jfb 168:
1.58 joris 169: rcsnum_tostr(rdp->rd_num, numb, sizeof(numb));
1.57 joris 170: printf("revision %s", numb);
1.20 jfb 171:
1.57 joris 172: strftime(timeb, sizeof(timeb), "%Y/%m/%d %H:%M:%S",
173: &rdp->rd_date);
174: printf("\ndate: %s; author: %s; state: %s;\n", timeb,
175: rdp->rd_author, rdp->rd_state);
176: printf("%s", rdp->rd_log);
177: }
1.20 jfb 178:
1.57 joris 179: printf("%s\n", LOG_REVEND);
1.1 jfb 180: }