[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.59

1.59    ! joris       1: /*     $OpenBSD: getlog.c,v 1.58 2006/05/28 21:35:58 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.20      jfb        96:
1.57      joris      97:        cvs_file_classify(cf, 0);
1.39      xsa        98:
1.57      joris      99:        if (cf->file_status == FILE_UNKNOWN) {
                    100:                if (verbosity > 0)
                    101:                        cvs_log(LP_ERR, "nothing known about %s",
                    102:                            cf->file_path);
                    103:                return;
                    104:        } else if (cf->file_status == FILE_ADDED) {
1.39      xsa       105:                if (verbosity > 0)
1.57      joris     106:                        cvs_log(LP_ERR, "%s has been added, but not commited",
                    107:                            cf->file_path);
1.59    ! joris     108:                return;
        !           109:        }
        !           110:
        !           111:        if (cf->file_type == CVS_DIR) {
        !           112:                if (verbosity > 1)
        !           113:                        cvs_log(LP_NOTICE, "Logging %s", cf->file_path);
1.57      joris     114:                return;
1.39      xsa       115:        }
                    116:
1.57      joris     117:        printf("\nRCS file: %s", cf->file_rpath);
                    118:        printf("\nWorking file: %s", cf->file_path);
                    119:        printf("\nhead:");
                    120:        if (cf->file_rcs->rf_head != NULL)
                    121:                printf(" %s", rcsnum_tostr(cf->file_rcs->rf_head,
                    122:                    numb, sizeof(numb)));
                    123:
                    124:        printf("\nbranch:");
                    125:        if (rcs_branch_get(cf->file_rcs) != NULL) {
                    126:                printf(" %s", rcsnum_tostr(rcs_branch_get(cf->file_rcs),
                    127:                    numb, sizeof(numb)));
1.20      jfb       128:        }
1.1       jfb       129:
1.57      joris     130:        printf("\nlocks: %s", (cf->file_rcs->rf_flags & RCS_SLOCK)
                    131:            ? "strict" : "");
                    132:        TAILQ_FOREACH(lkp, &(cf->file_rcs->rf_locks), rl_list)
                    133:                printf("\n\t%s: %s", lkp->rl_name,
                    134:                    rcsnum_tostr(lkp->rl_num, numb, sizeof(numb)));
1.20      jfb       135:
1.57      joris     136:        printf("\naccess list:\n");
                    137:        TAILQ_FOREACH(acp, &(cf->file_rcs->rf_access), ra_list)
                    138:                printf("\t%s\n", acp->ra_name);
1.20      jfb       139:
1.57      joris     140:        printf("symbolic names:\n");
                    141:        TAILQ_FOREACH(sym, &(cf->file_rcs->rf_symbols), rs_list) {
                    142:                printf("\t%s: %s\n", sym->rs_name,
                    143:                    rcsnum_tostr(sym->rs_num, numb, sizeof(numb)));
1.21      jfb       144:        }
                    145:
1.57      joris     146:        printf("keyword substitution: %s\n",
                    147:            cf->file_rcs->rf_expand == NULL ? "kv" : cf->file_rcs->rf_expand);
                    148:
                    149:        printf("total revisions: %u", cf->file_rcs->rf_ndelta);
1.20      jfb       150:
1.57      joris     151:        if (logrev != NULL)
1.58      joris     152:                nrev = cvs_revision_select(cf->file_rcs, logrev);
1.57      joris     153:        else
                    154:                nrev = cf->file_rcs->rf_ndelta;
1.21      jfb       155:
1.57      joris     156:        printf(";\tselected revisions: %u", nrev);
                    157:        printf("\n");
                    158:        printf("description:\n%s", cf->file_rcs->rf_desc);
1.1       jfb       159:
1.57      joris     160:        TAILQ_FOREACH(rdp, &(cf->file_rcs->rf_delta), rd_list) {
                    161:                if (logrev != NULL &&
1.58      joris     162:                    !(rdp->rd_flags & RCS_RD_SELECT))
1.57      joris     163:                        continue;
1.35      joris     164:
1.57      joris     165:                printf("%s\n", LOG_REVSEP);
1.1       jfb       166:
1.58      joris     167:                rcsnum_tostr(rdp->rd_num, numb, sizeof(numb));
1.57      joris     168:                printf("revision %s", numb);
1.20      jfb       169:
1.57      joris     170:                strftime(timeb, sizeof(timeb), "%Y/%m/%d %H:%M:%S",
                    171:                    &rdp->rd_date);
                    172:                printf("\ndate: %s;  author: %s;  state: %s;\n", timeb,
                    173:                    rdp->rd_author, rdp->rd_state);
                    174:                printf("%s", rdp->rd_log);
                    175:        }
1.20      jfb       176:
1.57      joris     177:        printf("%s\n", LOG_REVEND);
1.1       jfb       178: }