[BACK]Return to getlog.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / cvs

Annotation of src/usr.bin/cvs/getlog.c, Revision 1.63

1.63    ! joris       1: /*     $OpenBSD: getlog.c,v 1.62 2006/06/02 19:10:24 david 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"
                     23:
1.57      joris      24: #define LOG_REVSEP \
                     25: "----------------------------"
1.1       jfb        26:
1.57      joris      27: #define LOG_REVEND \
1.1       jfb        28:  "============================================================================="
                     29:
1.57      joris      30: int    cvs_getlog(int, char **);
                     31: void   cvs_log_local(struct cvs_file *);
                     32:
                     33: char   *logrev = NULL;
1.1       jfb        34:
1.29      jfb        35: struct cvs_cmd cvs_cmd_log = {
1.63    ! joris      36:        CVS_OP_LOG, 0, "log",
1.29      jfb        37:        { "lo" },
                     38:        "Print out history information for files",
                     39:        "[-bhlNRt] [-d dates] [-r revisions] [-s states] [-w logins]",
1.30      xsa        40:        "bd:hlNRr:s:tw:",
1.29      jfb        41:        NULL,
1.57      joris      42:        cvs_getlog
1.16      joris      43: };
                     44:
1.57      joris      45: int
                     46: cvs_getlog(int argc, char **argv)
1.1       jfb        47: {
1.16      joris      48:        int ch;
1.57      joris      49:        int flags;
                     50:        char *arg = ".";
                     51:        struct cvs_recursion cr;
1.1       jfb        52:
1.57      joris      53:        rcsnum_flags |= RCSNUM_NO_MAGIC;
                     54:        flags = CR_RECURSE_DIRS;
                     55:
                     56:        while ((ch = getopt(argc, argv, cvs_cmd_log.cmd_opts)) != -1) {
1.16      joris      57:                switch (ch) {
1.1       jfb        58:                case 'l':
1.57      joris      59:                        flags &= ~CR_RECURSE_DIRS;
1.1       jfb        60:                        break;
                     61:                case 'r':
1.57      joris      62:                        logrev = optarg;
1.25      xsa        63:                        break;
1.1       jfb        64:                default:
1.57      joris      65:                        fatal("%s", cvs_cmd_log.cmd_synopsis);
1.1       jfb        66:                }
                     67:        }
                     68:
1.57      joris      69:        argc -= optind;
                     70:        argv += optind;
1.6       jfb        71:
1.57      joris      72:        cr.enterdir = NULL;
                     73:        cr.leavedir = NULL;
                     74:        cr.remote = NULL;
                     75:        cr.local = cvs_log_local;
                     76:        cr.flags = flags;
                     77:
                     78:        if (argc > 0)
                     79:                cvs_file_run(argc, argv, &cr);
                     80:        else
                     81:                cvs_file_run(1, &arg, &cr);
1.5       jfb        82:
1.49      joris      83:        return (0);
1.6       jfb        84: }
1.5       jfb        85:
1.57      joris      86: void
                     87: cvs_log_local(struct cvs_file *cf)
1.1       jfb        88: {
1.57      joris      89:        u_int nrev;
1.20      jfb        90:        struct rcs_sym *sym;
1.57      joris      91:        struct rcs_lock *lkp;
1.1       jfb        92:        struct rcs_delta *rdp;
1.21      jfb        93:        struct rcs_access *acp;
1.57      joris      94:        char numb[32], timeb[32];
1.60      joris      95:
                     96:        cvs_log(LP_TRACE, "cvs_log_local(%s)", cf->file_path);
1.20      jfb        97:
1.61      joris      98:        cvs_file_classify(cf, NULL, 0);
1.39      xsa        99:
1.57      joris     100:        if (cf->file_status == FILE_UNKNOWN) {
                    101:                if (verbosity > 0)
                    102:                        cvs_log(LP_ERR, "nothing known about %s",
                    103:                            cf->file_path);
                    104:                return;
                    105:        } else if (cf->file_status == FILE_ADDED) {
1.39      xsa       106:                if (verbosity > 0)
1.62      david     107:                        cvs_log(LP_ERR, "%s has been added, but not committed",
1.57      joris     108:                            cf->file_path);
1.59      joris     109:                return;
                    110:        }
                    111:
                    112:        if (cf->file_type == CVS_DIR) {
                    113:                if (verbosity > 1)
                    114:                        cvs_log(LP_NOTICE, "Logging %s", cf->file_path);
1.57      joris     115:                return;
1.39      xsa       116:        }
                    117:
1.57      joris     118:        printf("\nRCS file: %s", cf->file_rpath);
                    119:        printf("\nWorking file: %s", cf->file_path);
                    120:        printf("\nhead:");
                    121:        if (cf->file_rcs->rf_head != NULL)
                    122:                printf(" %s", rcsnum_tostr(cf->file_rcs->rf_head,
                    123:                    numb, sizeof(numb)));
                    124:
                    125:        printf("\nbranch:");
                    126:        if (rcs_branch_get(cf->file_rcs) != NULL) {
                    127:                printf(" %s", rcsnum_tostr(rcs_branch_get(cf->file_rcs),
                    128:                    numb, sizeof(numb)));
1.20      jfb       129:        }
1.1       jfb       130:
1.57      joris     131:        printf("\nlocks: %s", (cf->file_rcs->rf_flags & RCS_SLOCK)
                    132:            ? "strict" : "");
                    133:        TAILQ_FOREACH(lkp, &(cf->file_rcs->rf_locks), rl_list)
                    134:                printf("\n\t%s: %s", lkp->rl_name,
                    135:                    rcsnum_tostr(lkp->rl_num, numb, sizeof(numb)));
1.20      jfb       136:
1.57      joris     137:        printf("\naccess list:\n");
                    138:        TAILQ_FOREACH(acp, &(cf->file_rcs->rf_access), ra_list)
                    139:                printf("\t%s\n", acp->ra_name);
1.20      jfb       140:
1.57      joris     141:        printf("symbolic names:\n");
                    142:        TAILQ_FOREACH(sym, &(cf->file_rcs->rf_symbols), rs_list) {
                    143:                printf("\t%s: %s\n", sym->rs_name,
                    144:                    rcsnum_tostr(sym->rs_num, numb, sizeof(numb)));
1.21      jfb       145:        }
                    146:
1.57      joris     147:        printf("keyword substitution: %s\n",
                    148:            cf->file_rcs->rf_expand == NULL ? "kv" : cf->file_rcs->rf_expand);
                    149:
                    150:        printf("total revisions: %u", cf->file_rcs->rf_ndelta);
1.20      jfb       151:
1.57      joris     152:        if (logrev != NULL)
1.58      joris     153:                nrev = cvs_revision_select(cf->file_rcs, logrev);
1.57      joris     154:        else
                    155:                nrev = cf->file_rcs->rf_ndelta;
1.21      jfb       156:
1.57      joris     157:        printf(";\tselected revisions: %u", nrev);
                    158:        printf("\n");
                    159:        printf("description:\n%s", cf->file_rcs->rf_desc);
1.1       jfb       160:
1.57      joris     161:        TAILQ_FOREACH(rdp, &(cf->file_rcs->rf_delta), rd_list) {
                    162:                if (logrev != NULL &&
1.58      joris     163:                    !(rdp->rd_flags & RCS_RD_SELECT))
1.57      joris     164:                        continue;
1.35      joris     165:
1.57      joris     166:                printf("%s\n", LOG_REVSEP);
1.1       jfb       167:
1.58      joris     168:                rcsnum_tostr(rdp->rd_num, numb, sizeof(numb));
1.57      joris     169:                printf("revision %s", numb);
1.20      jfb       170:
1.57      joris     171:                strftime(timeb, sizeof(timeb), "%Y/%m/%d %H:%M:%S",
                    172:                    &rdp->rd_date);
                    173:                printf("\ndate: %s;  author: %s;  state: %s;\n", timeb,
                    174:                    rdp->rd_author, rdp->rd_state);
                    175:                printf("%s", rdp->rd_log);
                    176:        }
1.20      jfb       177:
1.57      joris     178:        printf("%s\n", LOG_REVEND);
1.1       jfb       179: }